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

View File

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