Skip to content

Commit e2f4ee4

Browse files
committed
[YouTube] Add a playlist with Shorts UI test
The system Shorts videos uploads playlist of the YouTube official channel has been chosen for this test.
1 parent e6f371f commit e2f4ee4

1 file changed

Lines changed: 115 additions & 0 deletions

File tree

extractor/src/test/java/org/schabi/newpipe/extractor/services/youtube/YoutubePlaylistExtractorTest.java

Lines changed: 115 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,7 @@
2828
import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubePlaylistExtractor;
2929
import org.schabi.newpipe.extractor.stream.Description;
3030
import org.schabi.newpipe.extractor.stream.StreamInfoItem;
31+
import org.schabi.newpipe.extractor.utils.Utils;
3132

3233
import java.io.IOException;
3334

@@ -416,6 +417,120 @@ public void testDescription() throws ParsingException {
416417
}
417418
}
418419

420+
static class ShortsUI implements BasePlaylistExtractorTest {
421+
422+
private static PlaylistExtractor extractor;
423+
424+
@BeforeAll
425+
static void setUp() throws Exception {
426+
YoutubeTestsUtils.ensureStateless();
427+
NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "shortsUI"));
428+
extractor = YouTube.getPlaylistExtractor(
429+
"https://www.youtube.com/playlist?list=UUSHBR8-60-B28hp2BmDPdntcQ");
430+
extractor.fetchPage();
431+
}
432+
433+
@Test
434+
@Override
435+
public void testServiceId() throws Exception {
436+
assertEquals(YouTube.getServiceId(), extractor.getServiceId());
437+
}
438+
439+
@Test
440+
@Override
441+
public void testName() throws Exception {
442+
assertEquals("Short videos", extractor.getName());
443+
}
444+
445+
@Test
446+
@Override
447+
public void testId() throws Exception {
448+
assertEquals("UUSHBR8-60-B28hp2BmDPdntcQ", extractor.getId());
449+
}
450+
451+
@Test
452+
@Override
453+
public void testUrl() throws Exception {
454+
assertEquals("https://www.youtube.com/playlist?list=UUSHBR8-60-B28hp2BmDPdntcQ",
455+
extractor.getUrl());
456+
}
457+
458+
@Test
459+
@Override
460+
public void testOriginalUrl() throws Exception {
461+
assertEquals("https://www.youtube.com/playlist?list=UUSHBR8-60-B28hp2BmDPdntcQ",
462+
extractor.getOriginalUrl());
463+
}
464+
465+
@Test
466+
@Override
467+
public void testRelatedItems() throws Exception {
468+
defaultTestRelatedItems(extractor);
469+
}
470+
471+
// TODO: enable test when continuations are available
472+
@Disabled("Shorts UI doesn't return any continuation, even if when there are more than 100 "
473+
+ "items: this is a bug on YouTube's side, which is not related to the requirement "
474+
+ "of a valid visitorData like it is for Shorts channel tab")
475+
@Test
476+
@Override
477+
public void testMoreRelatedItems() throws Exception {
478+
defaultTestMoreItems(extractor);
479+
}
480+
481+
@Test
482+
@Override
483+
public void testThumbnailUrl() throws Exception {
484+
final String thumbnailUrl = extractor.getThumbnailUrl();
485+
assertIsSecureUrl(thumbnailUrl);
486+
ExtractorAsserts.assertContains("yt", thumbnailUrl);
487+
}
488+
489+
@Test
490+
@Override
491+
public void testBannerUrl() throws Exception {
492+
final String thumbnailUrl = extractor.getThumbnailUrl();
493+
assertIsSecureUrl(thumbnailUrl);
494+
ExtractorAsserts.assertContains("yt", thumbnailUrl);
495+
}
496+
497+
@Test
498+
@Override
499+
public void testUploaderName() throws Exception {
500+
assertEquals("YouTube", extractor.getUploaderName());
501+
}
502+
503+
@Test
504+
@Override
505+
public void testUploaderAvatarUrl() throws Exception {
506+
final String uploaderAvatarUrl = extractor.getUploaderAvatarUrl();
507+
ExtractorAsserts.assertContains("yt", uploaderAvatarUrl);
508+
}
509+
510+
@Test
511+
@Override
512+
public void testStreamCount() throws Exception {
513+
ExtractorAsserts.assertGreater(250, extractor.getStreamCount());
514+
}
515+
516+
@Test
517+
@Override
518+
public void testUploaderVerified() throws Exception {
519+
// YouTube doesn't provide this information for playlists
520+
assertFalse(extractor.isUploaderVerified());
521+
}
522+
523+
@Test
524+
void getPlaylistType() throws ParsingException {
525+
assertEquals(PlaylistInfo.PlaylistType.NORMAL, extractor.getPlaylistType());
526+
}
527+
528+
@Test
529+
void testDescription() throws ParsingException {
530+
assertTrue(Utils.isNullOrEmpty(extractor.getDescription().getContent()));
531+
}
532+
}
533+
419534
public static class ContinuationsTests {
420535

421536
@BeforeAll

0 commit comments

Comments
 (0)