Udio: add more logging when track can't be loaded
This commit is contained in:
1 parent
e778fa2874
commit
9aaa2edfa9
2 files changed
+11
-13
No files matched your search
@@ -91,6 +91,7 @@ public class UdioAudioSourceManager implements AudioSourceManager {
|
||||
JsonBrowser trackInfo = loadTrackInfoFromPageContent(content);
|
||||
|
||||
if (trackInfo == null) {
|
||||
log.debug("Udio HTML: {}", content);
|
||||
throw new FriendlyException("Udio: Failed to extract track information from web page.", SUSPICIOUS, null);
|
||||
}
|
||||
|
||||
@@ -110,21 +111,20 @@ public class UdioAudioSourceManager implements AudioSourceManager {
|
||||
|
||||
String json = DataFormatTools.extractBetween(content, "self.__next_f.push([1,\"8:", "\\n\"])");
|
||||
|
||||
if (json != null) {
|
||||
json = json.replace("\\", "");
|
||||
if (json == null) {
|
||||
log.error("Track JSON not found in page");
|
||||
return null;
|
||||
}
|
||||
|
||||
try {
|
||||
JsonBrowser parsedJson = JsonBrowser.parse(json);
|
||||
String unescapedJson = json.replace("\\", "");
|
||||
JsonBrowser parsedJson = JsonBrowser.parse(unescapedJson);
|
||||
|
||||
return parsedJson.index(3).get("children").index(3).get("children").index(3).get("track");
|
||||
} catch (JsonParseException e) {
|
||||
log.debug("Udio HTML: {}", content);
|
||||
|
||||
log.error("Failed to parse track JSON: {}", json);
|
||||
return null;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
return null;
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
@@ -44,8 +44,6 @@ public class UdioAudioTrack extends DelegatedAudioTrack {
|
||||
|
||||
@Override
|
||||
public void process(LocalAudioTrackExecutor localExecutor) throws Exception {
|
||||
|
||||
|
||||
try (HttpInterface httpInterface = sourceManager.getHttpInterface()) {
|
||||
String playbackUrl = loadPlaybackUrl(httpInterface);
|
||||
|
||||
@@ -58,7 +56,7 @@ public class UdioAudioTrack extends DelegatedAudioTrack {
|
||||
}
|
||||
|
||||
private String loadPlaybackUrl(HttpInterface httpInterface) throws IOException {
|
||||
JsonBrowser trackInfo = loadPlayerConfig(httpInterface);
|
||||
JsonBrowser trackInfo = loadTrackInfo(httpInterface);
|
||||
|
||||
if (trackInfo == null) {
|
||||
throw new FriendlyException("Udio: Failed to extract track information from web page.", SUSPICIOUS, null);
|
||||
@@ -67,7 +65,7 @@ public class UdioAudioTrack extends DelegatedAudioTrack {
|
||||
return trackInfo.get("song_path").text();
|
||||
}
|
||||
|
||||
private JsonBrowser loadPlayerConfig(HttpInterface httpInterface) throws IOException {
|
||||
private JsonBrowser loadTrackInfo(HttpInterface httpInterface) throws IOException {
|
||||
try (CloseableHttpResponse response = httpInterface.execute(new HttpGet(trackInfo.identifier))) {
|
||||
int statusCode = response.getStatusLine().getStatusCode();
|
||||
|
||||
|
||||
Reference in new issue
Block a user