Fix error when YT Music videos has no uploader URL
This commit is contained in:
parent
ac15df4548
commit
c7f7bd2442
|
@ -319,31 +319,32 @@ 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);
|
||||
}
|
||||
|
||||
if (url != null && !url.isEmpty()) {
|
||||
return url;
|
||||
final String url = getUrlFromNavigationEndpoint(navigationEndpoint);
|
||||
|
||||
if (url != null && !url.isEmpty()) {
|
||||
return url;
|
||||
}
|
||||
throw new ParsingException("Could not get uploader url");
|
||||
}
|
||||
throw new ParsingException("Could not get uploader url");
|
||||
}
|
||||
|
||||
@Override
|
||||
|
|
|
@ -132,7 +132,6 @@ public class YoutubeSearchExtractor extends SearchExtractor {
|
|||
}
|
||||
}
|
||||
|
||||
|
||||
private String getNextPageUrlFrom(final JsonArray continuations) throws ParsingException {
|
||||
if (continuations == null) {
|
||||
return "";
|
||||
|
|
Loading…
Reference in New Issue