Extract uploader url from certain YouTube Music videos
This commit is contained in:
parent
aa8cea47f3
commit
cf0f2aff3e
|
@ -394,12 +394,25 @@ public class YoutubeSearchExtractor extends SearchExtractor {
|
|||
|
||||
@Override
|
||||
public String getUploaderUrl() throws ParsingException {
|
||||
if (searchType.equals(MUSIC_VIDEOS)) return null;
|
||||
JsonObject navigationEndpoint = info.getArray("flexColumns")
|
||||
.getObject(1).getObject("musicResponsiveListItemFlexColumnRenderer")
|
||||
.getObject("text").getArray("runs").getObject(0).getObject("navigationEndpoint");
|
||||
if (navigationEndpoint == null) return null;
|
||||
String url = getUrlFromNavigationEndpoint(navigationEndpoint);
|
||||
String url = null;
|
||||
|
||||
if (searchType.equals(MUSIC_VIDEOS)) {
|
||||
JsonArray items = info.getObject("menu").getObject("menuRenderer").getArray("items");
|
||||
for (Object item : items) {
|
||||
JsonObject menuNavigationItemRenderer = ((JsonObject) item).getObject("menuNavigationItemRenderer");
|
||||
if (menuNavigationItemRenderer != null && menuNavigationItemRenderer.getObject("icon").getString("iconType").equals("ARTIST")) {
|
||||
url = getUrlFromNavigationEndpoint(menuNavigationItemRenderer.getObject("navigationEndpoint"));
|
||||
break;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
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;
|
||||
throw new ParsingException("Could not get uploader url");
|
||||
}
|
||||
|
|
|
@ -16,7 +16,7 @@ import javax.annotation.Nullable;
|
|||
import static java.util.Collections.singletonList;
|
||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||
|
||||
public class YoutubeSearchExtractorMusicTest {
|
||||
public class YoutubeMusicSearchExtractorTest {
|
||||
public static class MusicSongs extends DefaultSearchExtractorTest {
|
||||
private static SearchExtractor extractor;
|
||||
private static final String QUERY = "mocromaniac";
|
Loading…
Reference in New Issue