File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -50,6 +50,9 @@ public String getUrl(String id, String baseUrl) throws ParsingException {
5050 * @return a {@link LinkHandler} complete with information
5151 */
5252 public LinkHandler fromUrl (final String url ) throws ParsingException {
53+ if (Utils .isNullOrEmpty (url )) {
54+ throw new IllegalArgumentException ("The url is null or empty" );
55+ }
5356 final String polishedUrl = Utils .followGoogleRedirectIfNeeded (url );
5457 final String baseUrl = Utils .getBaseUrl (polishedUrl );
5558 return fromUrl (polishedUrl , baseUrl );
Original file line number Diff line number Diff line change @@ -429,10 +429,17 @@ public static String[] getYoutubeMusicKeys() throws IOException, ReCaptchaExcept
429429 return youtubeMusicKeys = new String []{key , clientName , clientVersion };
430430 }
431431
432+
433+
432434 @ Nullable
433435 public static String getUrlFromNavigationEndpoint (JsonObject navigationEndpoint ) throws ParsingException {
434436 if (navigationEndpoint .has ("urlEndpoint" )) {
435437 String internUrl = navigationEndpoint .getObject ("urlEndpoint" ).getString ("url" );
438+ if (internUrl .startsWith ("https://www.youtube.com/redirect?" )) {
439+ // remove https://www.youtube.com part to fall in the next if block
440+ internUrl = internUrl .substring (23 );
441+ }
442+
436443 if (internUrl .startsWith ("/redirect?" )) {
437444 // q parameter can be the first parameter
438445 internUrl = internUrl .substring (10 );
@@ -450,6 +457,8 @@ public static String getUrlFromNavigationEndpoint(JsonObject navigationEndpoint)
450457 }
451458 } else if (internUrl .startsWith ("http" )) {
452459 return internUrl ;
460+ } else if (internUrl .startsWith ("/channel" ) || internUrl .startsWith ("/user" ) || internUrl .startsWith ("/watch" )) {
461+ return "https://www.youtube.com" + internUrl ;
453462 }
454463 } else if (navigationEndpoint .has ("browseEndpoint" )) {
455464 final JsonObject browseEndpoint = navigationEndpoint .getObject ("browseEndpoint" );
Original file line number Diff line number Diff line change @@ -224,7 +224,7 @@ public String getThumbnailUrl() throws ParsingException {
224224
225225 @ Nonnull
226226 @ Override
227- public Description getDescription () {
227+ public Description getDescription () throws ParsingException {
228228 assertPageFetched ();
229229 // description with more info on links
230230 try {
@@ -234,8 +234,15 @@ public Description getDescription() {
234234 // age-restricted videos cause a ParsingException here
235235 }
236236
237+ String description = playerResponse .getObject ("videoDetails" ).getString ("shortDescription" );
238+ if (description == null ) {
239+ final JsonObject descriptionObject = playerResponse .getObject ("microformat" )
240+ .getObject ("playerMicroformatRenderer" ).getObject ("description" );
241+ description = getTextFromObject (descriptionObject );
242+ }
243+
237244 // raw non-html description
238- return new Description (playerResponse . getObject ( "videoDetails" ). getString ( "shortDescription" ) , Description .PLAIN_TEXT );
245+ return new Description (description , Description .PLAIN_TEXT );
239246 }
240247
241248 @ Override
Original file line number Diff line number Diff line change @@ -69,7 +69,15 @@ public InfoItemsPage<StreamInfoItem> getPage(final Page page) {
6969 @ Nonnull
7070 @ Override
7171 public String getName () throws ParsingException {
72- String name = getTextFromObject (initialData .getObject ("header" ).getObject ("feedTabbedHeaderRenderer" ).getObject ("title" ));
72+ final JsonObject header = initialData .getObject ("header" );
73+ JsonObject title = null ;
74+ if (header .has ("feedTabbedHeaderRenderer" )) {
75+ title = header .getObject ("feedTabbedHeaderRenderer" ).getObject ("title" );
76+ } else if (header .has ("c4TabbedHeaderRenderer" )) {
77+ title = header .getObject ("c4TabbedHeaderRenderer" ).getObject ("title" );
78+ }
79+
80+ String name = getTextFromObject (title );
7381 if (!isNullOrEmpty (name )) {
7482 return name ;
7583 }
Original file line number Diff line number Diff line change @@ -26,16 +26,13 @@ public static void setUpClass() throws Exception {
2626 }
2727
2828 @ Test
29- @ Ignore ("TODO fix" )
3029 public void testStreamList () throws Exception {
3130 final List <StreamInfoItem > items = extractor .getInitialPage ().getItems ();
3231 assertEquals (100 , items .size ());
3332 for (final StreamInfoItem item : items ) {
3433 assertFalse (isNullOrEmpty (item .getName ()));
3534 assertTrue (item .getDuration () > 0 );
36- assertTrue (isNullOrEmpty (item .getUploaderName ())); // we do not get the uploader name
3735 assertTrue (item .getUploadDate ().offsetDateTime ().isBefore (OffsetDateTime .now ()));
38- assertTrue (item .getUploadDate ().offsetDateTime ().isAfter (OffsetDateTime .now ().minusYears (1 )));
3936 }
4037 }
4138
Original file line number Diff line number Diff line change @@ -101,7 +101,6 @@ public void testFeedUrl() throws ParsingException {
101101 }
102102
103103 @ Test
104- @ Ignore ("TODO fix" )
105104 public void testSubscriberCount () throws ParsingException {
106105 assertTrue ("Wrong subscriber count" , extractor .getSubscriberCount () >= 500 );
107106 }
Original file line number Diff line number Diff line change 44import org .junit .Ignore ;
55import org .junit .Test ;
66import org .schabi .newpipe .downloader .DownloaderTestImpl ;
7+ import org .schabi .newpipe .extractor .ExtractorAsserts ;
78import org .schabi .newpipe .extractor .NewPipe ;
89import org .schabi .newpipe .extractor .exceptions .ParsingException ;
910import org .schabi .newpipe .extractor .services .peertube .extractors .PeertubePlaylistExtractor ;
@@ -51,9 +52,8 @@ public void testGetUploaderName() throws ParsingException {
5152 }
5253
5354 @ Test
54- @ Ignore ("TODO fix" )
5555 public void testGetStreamCount () throws ParsingException {
56- assertEquals ( 35 , extractor .getStreamCount ());
56+ ExtractorAsserts . assertAtLeast ( 39 , extractor .getStreamCount ());
5757 }
5858
5959 @ Test
@@ -62,7 +62,6 @@ public void testGetSubChannelUrl() throws ParsingException {
6262 }
6363
6464 @ Test
65- @ Ignore ("TODO fix" )
6665 public void testGetSubChannelName () throws ParsingException {
6766 assertEquals ("SHOCKING !" , extractor .getSubChannelName ());
6867 }
Original file line number Diff line number Diff line change @@ -94,13 +94,6 @@ public void testGetLanguageInformation() throws ParsingException {
9494 @ Override public Locale expectedLanguageInfo () { return Locale .forLanguageTag ("en" ); }
9595 @ Override public List <String > expectedTags () { return Arrays .asList ("framasoft" , "peertube" ); }
9696 @ Override public int expectedStreamSegmentsCount () { return 0 ; }
97-
98- @ Override
99- @ Test
100- @ Ignore ("TODO fix" )
101- public void testSubChannelName () throws Exception {
102- super .testSubChannelName ();
103- }
10497 }
10598
10699 @ Ignore ("TODO fix" )
Original file line number Diff line number Diff line change @@ -42,7 +42,6 @@ public void testServiceId() {
4242 }
4343
4444 @ Test
45- @ Ignore ("TODO fix" )
4645 public void testName () {
4746 assertEquals ("THE PERFECT LUV TAPE®️" , extractor .getName ());
4847 }
Original file line number Diff line number Diff line change @@ -26,7 +26,6 @@ public static void setUp() throws Exception {
2626 }
2727
2828 @ Test (expected = IllegalArgumentException .class )
29- @ Ignore ("TODO fix" )
3029 public void getIdWithNullAsUrl () throws ParsingException {
3130 linkHandler .fromUrl (null ).getId ();
3231 }
You can’t perform that action at this time.
0 commit comments