Extract uploader url from certain YouTube Music videos
This commit is contained in:
		
							parent
							
								
									aa8cea47f3
								
							
						
					
					
						commit
						cf0f2aff3e
					
				
					 2 changed files with 20 additions and 7 deletions
				
			
		|  | @ -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; | ||||||
|                             JsonObject navigationEndpoint = info.getArray("flexColumns") | 
 | ||||||
|                                     .getObject(1).getObject("musicResponsiveListItemFlexColumnRenderer") |                             if (searchType.equals(MUSIC_VIDEOS)) { | ||||||
|                                     .getObject("text").getArray("runs").getObject(0).getObject("navigationEndpoint"); |                                 JsonArray items = info.getObject("menu").getObject("menuRenderer").getArray("items"); | ||||||
|                             if (navigationEndpoint == null) return null; |                                 for (Object item : items) { | ||||||
|                             String url = getUrlFromNavigationEndpoint(navigationEndpoint); |                                     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; |                             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…
	
	Add table
		Add a link
		
	
		Reference in a new issue