@@ -308,7 +308,9 @@ public InfoItemsPage<InfoItem> getPage(String pageUrl) throws IOException, Extra
308308 throw new ParsingException ("Could not parse JSON" , e );
309309 }
310310
311- if (ajaxJson .getObject ("continuationContents" ) == null ) return new InfoItemsPage <>(collector , null );
311+ if (ajaxJson .getObject ("continuationContents" ) == null ) {
312+ return InfoItemsPage .emptyPage ();
313+ }
312314
313315 JsonObject musicShelfContinuation = ajaxJson .getObject ("continuationContents" ).getObject ("musicShelfContinuation" );
314316
@@ -329,8 +331,7 @@ public InfoItemsPage<InfoItem> getPage(String pageUrl) throws IOException, Extra
329331
330332 private boolean isMusicSearch () {
331333 final List <String > contentFilters = getLinkHandler ().getContentFilters ();
332- if (contentFilters .size () > 0 && contentFilters .get (0 ).startsWith ("music_" )) return true ;
333- return false ;
334+ return contentFilters .size () > 0 && contentFilters .get (0 ).startsWith ("music_" );
334335 }
335336
336337 private void collectStreamsFrom (InfoItemsSearchCollector collector , JsonArray videos ) throws NothingFoundException , ParsingException {
@@ -391,6 +392,16 @@ public String getUploaderName() throws ParsingException {
391392 throw new ParsingException ("Could not get uploader name" );
392393 }
393394
395+ @ Override
396+ public String getUploaderUrl () throws ParsingException {
397+ if (searchType .equals (MUSIC_VIDEOS )) return null ;
398+ String url = getUrlFromNavigationEndpoint (info .getArray ("flexColumns" )
399+ .getObject (1 ).getObject ("musicResponsiveListItemFlexColumnRenderer" )
400+ .getObject ("text" ).getArray ("runs" ).getObject (0 ).getObject ("navigationEndpoint" ));
401+ if (url != null && !url .isEmpty ()) return url ;
402+ throw new ParsingException ("Could not get uploader url" );
403+ }
404+
394405 @ Override
395406 public String getTextualUploadDate () {
396407 return null ;
@@ -413,9 +424,12 @@ public long getViewCount() throws ParsingException {
413424 @ Override
414425 public String getThumbnailUrl () throws ParsingException {
415426 try {
416- // TODO: Don't simply get the first item, but look at all thumbnails and their resolution
417- return fixThumbnailUrl (info .getObject ("thumbnail" ).getObject ("musicThumbnailRenderer" )
418- .getObject ("thumbnail" ).getArray ("thumbnails" ).getObject (0 ).getString ("url" ));
427+ JsonArray thumbnails = info .getObject ("thumbnail" ).getObject ("musicThumbnailRenderer" )
428+ .getObject ("thumbnail" ).getArray ("thumbnails" );
429+ // the last thumbnail is the one with the highest resolution
430+ String url = thumbnails .getObject (thumbnails .size () - 1 ).getString ("url" );
431+
432+ return fixThumbnailUrl (url );
419433 } catch (Exception e ) {
420434 throw new ParsingException ("Could not get thumbnail url" , e );
421435 }
@@ -426,9 +440,12 @@ public String getThumbnailUrl() throws ParsingException {
426440 @ Override
427441 public String getThumbnailUrl () throws ParsingException {
428442 try {
429- // TODO: Don't simply get the first item, but look at all thumbnails and their resolution
430- return fixThumbnailUrl (info .getObject ("thumbnail" ).getObject ("musicThumbnailRenderer" )
431- .getObject ("thumbnail" ).getArray ("thumbnails" ).getObject (0 ).getString ("url" ));
443+ JsonArray thumbnails = info .getObject ("thumbnail" ).getObject ("musicThumbnailRenderer" )
444+ .getObject ("thumbnail" ).getArray ("thumbnails" );
445+ // the last thumbnail is the one with the highest resolution
446+ String url = thumbnails .getObject (thumbnails .size () - 1 ).getString ("url" );
447+
448+ return fixThumbnailUrl (url );
432449 } catch (Exception e ) {
433450 throw new ParsingException ("Could not get thumbnail url" , e );
434451 }
@@ -472,9 +489,12 @@ public String getDescription() {
472489 @ Override
473490 public String getThumbnailUrl () throws ParsingException {
474491 try {
475- // TODO: Don't simply get the first item, but look at all thumbnails and their resolution
476- return fixThumbnailUrl (info .getObject ("thumbnail" ).getObject ("musicThumbnailRenderer" )
477- .getObject ("thumbnail" ).getArray ("thumbnails" ).getObject (0 ).getString ("url" ));
492+ JsonArray thumbnails = info .getObject ("thumbnail" ).getObject ("musicThumbnailRenderer" )
493+ .getObject ("thumbnail" ).getArray ("thumbnails" );
494+ // the last thumbnail is the one with the highest resolution
495+ String url = thumbnails .getObject (thumbnails .size () - 1 ).getString ("url" );
496+
497+ return fixThumbnailUrl (url );
478498 } catch (Exception e ) {
479499 throw new ParsingException ("Could not get thumbnail url" , e );
480500 }
0 commit comments