Fix error when YT Music videos has no uploader URL

This commit is contained in:
wb9688 2020-04-01 10:17:34 +02:00
parent ac15df4548
commit c7f7bd2442
2 changed files with 10 additions and 10 deletions

View File

@ -319,31 +319,32 @@ public class YoutubeMusicSearchExtractor extends SearchExtractor {
@Override @Override
public String getUploaderUrl() throws ParsingException { public String getUploaderUrl() throws ParsingException {
String url = null;
if (searchType.equals(MUSIC_VIDEOS)) { if (searchType.equals(MUSIC_VIDEOS)) {
JsonArray items = info.getObject("menu").getObject("menuRenderer").getArray("items"); JsonArray items = info.getObject("menu").getObject("menuRenderer").getArray("items");
for (Object item : items) { for (Object item : items) {
final JsonObject menuNavigationItemRenderer = ((JsonObject) item).getObject("menuNavigationItemRenderer"); final JsonObject menuNavigationItemRenderer = ((JsonObject) item).getObject("menuNavigationItemRenderer");
if (menuNavigationItemRenderer != null && menuNavigationItemRenderer.getObject("icon").getString("iconType").equals("ARTIST")) { if (menuNavigationItemRenderer != null && menuNavigationItemRenderer.getObject("icon").getString("iconType").equals("ARTIST")) {
url = getUrlFromNavigationEndpoint(menuNavigationItemRenderer.getObject("navigationEndpoint")); return getUrlFromNavigationEndpoint(menuNavigationItemRenderer.getObject("navigationEndpoint"));
break;
} }
} }
return null;
} else { } else {
final JsonObject navigationEndpoint = info.getArray("flexColumns") final JsonObject navigationEndpoint = info.getArray("flexColumns")
.getObject(1).getObject("musicResponsiveListItemFlexColumnRenderer") .getObject(1).getObject("musicResponsiveListItemFlexColumnRenderer")
.getObject("text").getArray("runs").getObject(0).getObject("navigationEndpoint"); .getObject("text").getArray("runs").getObject(0).getObject("navigationEndpoint");
if (navigationEndpoint == null) { if (navigationEndpoint == null) {
return null; return null;
} }
url = getUrlFromNavigationEndpoint(navigationEndpoint);
}
if (url != null && !url.isEmpty()) { final String url = getUrlFromNavigationEndpoint(navigationEndpoint);
return url;
if (url != null && !url.isEmpty()) {
return url;
}
throw new ParsingException("Could not get uploader url");
} }
throw new ParsingException("Could not get uploader url");
} }
@Override @Override

View File

@ -132,7 +132,6 @@ public class YoutubeSearchExtractor extends SearchExtractor {
} }
} }
private String getNextPageUrlFrom(final JsonArray continuations) throws ParsingException { private String getNextPageUrlFrom(final JsonArray continuations) throws ParsingException {
if (continuations == null) { if (continuations == null) {
return ""; return "";