|
5 | 5 | import org.schabi.newpipe.DownloaderTestImpl; |
6 | 6 | import org.schabi.newpipe.extractor.NewPipe; |
7 | 7 | import org.schabi.newpipe.extractor.channel.ChannelExtractor; |
| 8 | +import org.schabi.newpipe.extractor.channel.ChannelInfo; |
8 | 9 | import org.schabi.newpipe.extractor.exceptions.ContentNotAvailableException; |
9 | 10 | import org.schabi.newpipe.extractor.exceptions.ParsingException; |
10 | 11 | import org.schabi.newpipe.extractor.services.BaseChannelExtractorTest; |
11 | 12 | import org.schabi.newpipe.extractor.services.youtube.extractors.YoutubeChannelExtractor; |
12 | 13 |
|
| 14 | +import java.util.List; |
| 15 | + |
13 | 16 | import static org.junit.Assert.*; |
| 17 | +import static org.schabi.newpipe.extractor.ExtractorAsserts.assertEmpty; |
14 | 18 | import static org.schabi.newpipe.extractor.ExtractorAsserts.assertIsSecureUrl; |
15 | 19 | import static org.schabi.newpipe.extractor.ServiceList.YouTube; |
16 | 20 | import static org.schabi.newpipe.extractor.services.DefaultTests.*; |
@@ -505,6 +509,97 @@ public void testSubscriberCount() throws Exception { |
505 | 509 | } |
506 | 510 | } |
507 | 511 |
|
| 512 | + /** |
| 513 | + * Some VEVO channels will redirect to a new page with a new channel id. |
| 514 | + * <p> |
| 515 | + * Though, it isn't a simple redirect, but a redirect instruction embed in the response itself, this |
| 516 | + * test assure that we account for that. |
| 517 | + */ |
| 518 | + public static class RedirectedChannel implements BaseChannelExtractorTest { |
| 519 | + private static YoutubeChannelExtractor extractor; |
| 520 | + |
| 521 | + @BeforeClass |
| 522 | + public static void setUp() throws Exception { |
| 523 | + NewPipe.init(DownloaderTestImpl.getInstance()); |
| 524 | + extractor = (YoutubeChannelExtractor) YouTube |
| 525 | + .getChannelExtractor("https://www.youtube.com/channel/UCITk7Ky4iE5_xISw9IaHqpQ"); |
| 526 | + extractor.fetchPage(); |
| 527 | + } |
| 528 | + |
| 529 | + /*////////////////////////////////////////////////////////////////////////// |
| 530 | + // Extractor |
| 531 | + //////////////////////////////////////////////////////////////////////////*/ |
| 532 | + |
| 533 | + @Test |
| 534 | + public void testServiceId() { |
| 535 | + assertEquals(YouTube.getServiceId(), extractor.getServiceId()); |
| 536 | + } |
| 537 | + |
| 538 | + @Test |
| 539 | + public void testName() throws Exception { |
| 540 | + assertEquals("LordiVEVO", extractor.getName()); |
| 541 | + } |
| 542 | + |
| 543 | + @Test |
| 544 | + public void testId() throws Exception { |
| 545 | + assertEquals("UCrxkwepj7-4Wz1wHyfzw-sQ", extractor.getId()); |
| 546 | + } |
| 547 | + |
| 548 | + @Test |
| 549 | + public void testUrl() throws ParsingException { |
| 550 | + assertEquals("https://www.youtube.com/channel/UCrxkwepj7-4Wz1wHyfzw-sQ", extractor.getUrl()); |
| 551 | + } |
| 552 | + |
| 553 | + @Test |
| 554 | + public void testOriginalUrl() throws ParsingException { |
| 555 | + assertEquals("https://www.youtube.com/channel/UCITk7Ky4iE5_xISw9IaHqpQ", extractor.getOriginalUrl()); |
| 556 | + } |
| 557 | + |
| 558 | + /*////////////////////////////////////////////////////////////////////////// |
| 559 | + // ListExtractor |
| 560 | + //////////////////////////////////////////////////////////////////////////*/ |
| 561 | + |
| 562 | + @Test |
| 563 | + public void testRelatedItems() throws Exception { |
| 564 | + defaultTestRelatedItems(extractor); |
| 565 | + } |
| 566 | + |
| 567 | + @Test |
| 568 | + public void testMoreRelatedItems() throws Exception { |
| 569 | + assertNoMoreItems(extractor); |
| 570 | + } |
| 571 | + |
| 572 | + /*////////////////////////////////////////////////////////////////////////// |
| 573 | + // ChannelExtractor |
| 574 | + //////////////////////////////////////////////////////////////////////////*/ |
| 575 | + |
| 576 | + @Test |
| 577 | + public void testDescription() throws Exception { |
| 578 | + assertEmpty(extractor.getDescription()); |
| 579 | + } |
| 580 | + |
| 581 | + @Test |
| 582 | + public void testAvatarUrl() throws Exception { |
| 583 | + String avatarUrl = extractor.getAvatarUrl(); |
| 584 | + assertIsSecureUrl(avatarUrl); |
| 585 | + assertTrue(avatarUrl, avatarUrl.contains("yt3")); |
| 586 | + } |
| 587 | + |
| 588 | + @Test |
| 589 | + public void testBannerUrl() throws Exception { |
| 590 | + assertEmpty(extractor.getBannerUrl()); |
| 591 | + } |
| 592 | + |
| 593 | + @Test |
| 594 | + public void testFeedUrl() throws Exception { |
| 595 | + assertEquals("https://www.youtube.com/feeds/videos.xml?channel_id=UCrxkwepj7-4Wz1wHyfzw-sQ", extractor.getFeedUrl()); |
| 596 | + } |
| 597 | + |
| 598 | + @Test |
| 599 | + public void testSubscriberCount() throws Exception { |
| 600 | + assertEquals(-1, extractor.getSubscriberCount()); |
| 601 | + } |
| 602 | + } |
508 | 603 |
|
509 | 604 | public static class RandomChannel implements BaseChannelExtractorTest { |
510 | 605 | private static YoutubeChannelExtractor extractor; |
|
0 commit comments