File tree Expand file tree Collapse file tree 2 files changed +19
-15
lines changed
extractor/src/main/java/org/schabi/newpipe/extractor/services/youtube Expand file tree Collapse file tree 2 files changed +19
-15
lines changed Original file line number Diff line number Diff line change @@ -746,16 +746,15 @@ public static Optional<String> getUrlFromNavigationEndpoint(
746746 }
747747 });
748748 })
749- .or (() -> {
750- final var watchEndpoint = navigationEndpoint .getObject ("watchEndpoint" );
751- final var videoId = watchEndpoint .getString (VIDEO_ID );
752- final var playlistId = watchEndpoint .getString ("playlistId" );
753- final var startTime = watchEndpoint .getInt ("startTimeSeconds" , -1 );
754- final String url = "https://www.youtube.com/watch?v=" + videoId
755- + (playlistId != null ? "&list=" + playlistId : "" )
756- + (startTime != -1 ? "&t=" + startTime : "" );
757- return Optional .of (url );
758- })
749+ .or (() -> Optional .ofNullable (navigationEndpoint .getObject ("watchEndpoint" , null ))
750+ .map (watchEndpoint -> {
751+ final var videoId = watchEndpoint .getString (VIDEO_ID );
752+ final var playlistId = watchEndpoint .getString ("playlistId" );
753+ final var startTime = watchEndpoint .getInt ("startTimeSeconds" , -1 );
754+ return "https://www.youtube.com/watch?v=" + videoId
755+ + (playlistId != null ? "&list=" + playlistId : "" )
756+ + (startTime != -1 ? "&t=" + startTime : "" );
757+ }))
759758 .or (() -> {
760759 final var playlistId = navigationEndpoint .getObject ("watchPlaylistEndpoint" )
761760 .getString ("playlistId" );
Original file line number Diff line number Diff line change @@ -88,15 +88,20 @@ public String getUploaderUrl() throws ParsingException {
8888 if (searchType .equals (MUSIC_VIDEOS )) {
8989 return getMusicUploaderUrlFromMenu (songOrVideoInfoItem ).orElse (null );
9090 } else {
91- final JsonObject holder = songOrVideoInfoItem .getArray ("flexColumns" )
91+ final var endpoint = songOrVideoInfoItem .getArray ("flexColumns" )
9292 .getObject (1 )
9393 .getObject ("musicResponsiveListItemFlexColumnRenderer" )
9494 .getObject ("text" )
9595 .getArray ("runs" )
96- .getObject (0 );
97-
98- return getUrlFromNavigationEndpoint (holder .getObject ("navigationEndpoint" ))
99- .orElseThrow (() -> new ParsingException ("Could not get uploader URL" ));
96+ .getObject (0 )
97+ .getObject ("navigationEndpoint" );
98+
99+ if (!endpoint .isEmpty ()) {
100+ return getUrlFromNavigationEndpoint (endpoint )
101+ .orElseThrow (() -> new ParsingException ("Could not get uploader URL" ));
102+ } else {
103+ return null ;
104+ }
100105 }
101106 }
102107
You can’t perform that action at this time.
0 commit comments