55import com .grack .nanojson .JsonParser ;
66import com .grack .nanojson .JsonParserException ;
77import com .grack .nanojson .JsonWriter ;
8+
89import org .schabi .newpipe .extractor .InfoItem ;
910import org .schabi .newpipe .extractor .StreamingService ;
1011import org .schabi .newpipe .extractor .downloader .Downloader ;
1920import org .schabi .newpipe .extractor .services .youtube .linkHandler .YoutubeParsingHelper ;
2021import org .schabi .newpipe .extractor .utils .Utils ;
2122
22- import javax .annotation .Nonnull ;
2323import java .io .IOException ;
2424import java .util .Collections ;
2525import java .util .HashMap ;
2626import java .util .List ;
2727import java .util .Map ;
2828
29+ import javax .annotation .Nonnull ;
30+
2931import static org .schabi .newpipe .extractor .services .youtube .linkHandler .YoutubeParsingHelper .fixThumbnailUrl ;
3032import static org .schabi .newpipe .extractor .services .youtube .linkHandler .YoutubeParsingHelper .getTextFromObject ;
3133import static org .schabi .newpipe .extractor .services .youtube .linkHandler .YoutubeParsingHelper .getUrlFromNavigationEndpoint ;
@@ -249,7 +251,7 @@ public String getUrl() throws ParsingException {
249251 public String getName () throws ParsingException {
250252 final String name = getTextFromObject (info .getArray ("flexColumns" ).getObject (0 )
251253 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
252- if (!name .isEmpty ()) {
254+ if (name != null && !name .isEmpty ()) {
253255 return name ;
254256 }
255257 throw new ParsingException ("Could not get name" );
@@ -259,7 +261,7 @@ public String getName() throws ParsingException {
259261 public long getDuration () throws ParsingException {
260262 final String duration = getTextFromObject (info .getArray ("flexColumns" ).getObject (3 )
261263 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
262- if (!duration .isEmpty ()) {
264+ if (duration != null && !duration .isEmpty ()) {
263265 return YoutubeParsingHelper .parseDurationString (duration );
264266 }
265267 throw new ParsingException ("Could not get duration" );
@@ -269,7 +271,7 @@ public long getDuration() throws ParsingException {
269271 public String getUploaderName () throws ParsingException {
270272 final String name = getTextFromObject (info .getArray ("flexColumns" ).getObject (1 )
271273 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
272- if (!name .isEmpty ()) {
274+ if (name != null && !name .isEmpty ()) {
273275 return name ;
274276 }
275277 throw new ParsingException ("Could not get uploader name" );
@@ -288,11 +290,13 @@ public String getUploaderUrl() throws ParsingException {
288290
289291 return null ;
290292 } else {
291- final JsonObject navigationEndpoint = info .getArray ("flexColumns" )
293+ final JsonObject navigationEndpointHolder = info .getArray ("flexColumns" )
292294 .getObject (1 ).getObject ("musicResponsiveListItemFlexColumnRenderer" )
293- .getObject ("text" ).getArray ("runs" ).getObject (0 ).getObject ("navigationEndpoint" );
295+ .getObject ("text" ).getArray ("runs" ).getObject (0 );
296+
297+ if (!navigationEndpointHolder .has ("navigationEndpoint" )) return null ;
294298
295- final String url = getUrlFromNavigationEndpoint (navigationEndpoint );
299+ final String url = getUrlFromNavigationEndpoint (navigationEndpointHolder . getObject ( " navigationEndpoint" ) );
296300
297301 if (url != null && !url .isEmpty ()) {
298302 return url ;
@@ -319,7 +323,7 @@ public long getViewCount() throws ParsingException {
319323 }
320324 final String viewCount = getTextFromObject (info .getArray ("flexColumns" ).getObject (2 )
321325 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
322- if (!viewCount .isEmpty ()) {
326+ if (viewCount != null && !viewCount .isEmpty ()) {
323327 return Utils .mixedNumberWordToLong (viewCount );
324328 }
325329 throw new ParsingException ("Could not get view count" );
@@ -359,7 +363,7 @@ public String getThumbnailUrl() throws ParsingException {
359363 public String getName () throws ParsingException {
360364 final String name = getTextFromObject (info .getArray ("flexColumns" ).getObject (0 )
361365 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
362- if (!name .isEmpty ()) {
366+ if (name != null && !name .isEmpty ()) {
363367 return name ;
364368 }
365369 throw new ParsingException ("Could not get name" );
@@ -378,7 +382,7 @@ public String getUrl() throws ParsingException {
378382 public long getSubscriberCount () throws ParsingException {
379383 final String viewCount = getTextFromObject (info .getArray ("flexColumns" ).getObject (2 )
380384 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
381- if (!viewCount .isEmpty ()) {
385+ if (viewCount != null && !viewCount .isEmpty ()) {
382386 return Utils .mixedNumberWordToLong (viewCount );
383387 }
384388 throw new ParsingException ("Could not get subscriber count" );
@@ -414,7 +418,7 @@ public String getThumbnailUrl() throws ParsingException {
414418 public String getName () throws ParsingException {
415419 final String name = getTextFromObject (info .getArray ("flexColumns" ).getObject (0 )
416420 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
417- if (!name .isEmpty ()) {
421+ if (name != null && !name .isEmpty ()) {
418422 return name ;
419423 }
420424 throw new ParsingException ("Could not get name" );
@@ -439,7 +443,7 @@ public String getUploaderName() throws ParsingException {
439443 name = getTextFromObject (info .getArray ("flexColumns" ).getObject (1 )
440444 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
441445 }
442- if (!name .isEmpty ()) {
446+ if (name != null && !name .isEmpty ()) {
443447 return name ;
444448 }
445449 throw new ParsingException ("Could not get uploader name" );
@@ -452,7 +456,7 @@ public long getStreamCount() throws ParsingException {
452456 }
453457 final String count = getTextFromObject (info .getArray ("flexColumns" ).getObject (2 )
454458 .getObject ("musicResponsiveListItemFlexColumnRenderer" ).getObject ("text" ));
455- if (!count .isEmpty ()) {
459+ if (count != null && !count .isEmpty ()) {
456460 if (count .contains ("100+" )) {
457461 return ITEM_COUNT_MORE_THAN_100 ;
458462 } else {
0 commit comments