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
|
@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
|
||||||
|
|
|
@ -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 "";
|
||||||
|
|
Loading…
Reference in New Issue