mirror of
https://github.com/TeamNewPipe/NewPipeExtractor.git
synced 2024-12-14 14:20:33 +05:30
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
|
@Override
|
||||||
public String getUploaderUrl() throws ParsingException {
|
public String getUploaderUrl() throws ParsingException {
|
||||||
if (searchType.equals(MUSIC_VIDEOS)) return null;
|
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")
|
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) return null;
|
if (navigationEndpoint == null) return null;
|
||||||
String url = getUrlFromNavigationEndpoint(navigationEndpoint);
|
url = getUrlFromNavigationEndpoint(navigationEndpoint);
|
||||||
|
}
|
||||||
|
|
||||||
if (url != null && !url.isEmpty()) 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");
|
||||||
}
|
}
|
||||||
|
@ -16,7 +16,7 @@ import javax.annotation.Nullable;
|
|||||||
import static java.util.Collections.singletonList;
|
import static java.util.Collections.singletonList;
|
||||||
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
import static org.schabi.newpipe.extractor.ServiceList.YouTube;
|
||||||
|
|
||||||
public class YoutubeSearchExtractorMusicTest {
|
public class YoutubeMusicSearchExtractorTest {
|
||||||
public static class MusicSongs extends DefaultSearchExtractorTest {
|
public static class MusicSongs extends DefaultSearchExtractorTest {
|
||||||
private static SearchExtractor extractor;
|
private static SearchExtractor extractor;
|
||||||
private static final String QUERY = "mocromaniac";
|
private static final String QUERY = "mocromaniac";
|
Loading…
Reference in New Issue
Block a user