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);
|
JsonBrowser trackInfo = loadTrackInfoFromPageContent(content);
|
||||||
|
|
||||||
if (trackInfo == null) {
|
if (trackInfo == null) {
|
||||||
|
log.debug("Udio HTML: {}", content);
|
||||||
throw new FriendlyException("Udio: Failed to extract track information from web page.", SUSPICIOUS, null);
|
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\"])");
|
String json = DataFormatTools.extractBetween(content, "self.__next_f.push([1,\"8:", "\\n\"])");
|
||||||
|
|
||||||
if (json != null) {
|
if (json == null) {
|
||||||
json = json.replace("\\", "");
|
log.error("Track JSON not found in page");
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
|
||||||
try {
|
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");
|
return parsedJson.index(3).get("children").index(3).get("children").index(3).get("track");
|
||||||
} catch (JsonParseException e) {
|
} catch (JsonParseException e) {
|
||||||
log.debug("Udio HTML: {}", content);
|
log.error("Failed to parse track JSON: {}", json);
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
return null;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -44,8 +44,6 @@ public class UdioAudioTrack extends DelegatedAudioTrack {
|
|||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void process(LocalAudioTrackExecutor localExecutor) throws Exception {
|
public void process(LocalAudioTrackExecutor localExecutor) throws Exception {
|
||||||
|
|
||||||
|
|
||||||
try (HttpInterface httpInterface = sourceManager.getHttpInterface()) {
|
try (HttpInterface httpInterface = sourceManager.getHttpInterface()) {
|
||||||
String playbackUrl = loadPlaybackUrl(httpInterface);
|
String playbackUrl = loadPlaybackUrl(httpInterface);
|
||||||
|
|
||||||
@@ -58,7 +56,7 @@ public class UdioAudioTrack extends DelegatedAudioTrack {
|
|||||||
}
|
}
|
||||||
|
|
||||||
private String loadPlaybackUrl(HttpInterface httpInterface) throws IOException {
|
private String loadPlaybackUrl(HttpInterface httpInterface) throws IOException {
|
||||||
JsonBrowser trackInfo = loadPlayerConfig(httpInterface);
|
JsonBrowser trackInfo = loadTrackInfo(httpInterface);
|
||||||
|
|
||||||
if (trackInfo == null) {
|
if (trackInfo == null) {
|
||||||
throw new FriendlyException("Udio: Failed to extract track information from web page.", SUSPICIOUS, 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();
|
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))) {
|
try (CloseableHttpResponse response = httpInterface.execute(new HttpGet(trackInfo.identifier))) {
|
||||||
int statusCode = response.getStatusLine().getStatusCode();
|
int statusCode = response.getStatusLine().getStatusCode();
|
||||||
|
|
||||||
|
|||||||
Reference in new issue
Block a user