|
50 | 50 | import org.schabi.newpipe.extractor.stream.StreamExtractor; |
51 | 51 | import org.schabi.newpipe.extractor.stream.StreamSegment; |
52 | 52 | import org.schabi.newpipe.extractor.stream.StreamType; |
| 53 | +import org.schabi.newpipe.extractor.stream.SubtitlesStream; |
53 | 54 |
|
54 | 55 | import java.io.IOException; |
55 | 56 | import java.net.MalformedURLException; |
@@ -603,4 +604,67 @@ void testCheckDescriptiveAudio() throws Exception { |
603 | 604 | .anyMatch(s -> s.getAudioTrackType() == AudioTrackType.DESCRIPTIVE)); |
604 | 605 | } |
605 | 606 | } |
| 607 | + |
| 608 | + public static class GeneratedSubtitles { |
| 609 | + private static YoutubeStreamExtractor extractor; |
| 610 | + private static List<SubtitlesStream> subtitles; |
| 611 | + |
| 612 | + @BeforeAll |
| 613 | + public static void setUp() throws Exception { |
| 614 | + YoutubeTestsUtils.ensureStateless(); |
| 615 | + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "generatedSubtitles")); |
| 616 | + extractor = (YoutubeStreamExtractor) YouTube |
| 617 | + .getStreamExtractor("https://www.youtube.com/watch?v=bvwohQavFV8"); |
| 618 | + extractor.fetchPage(); |
| 619 | + subtitles = extractor.getSubtitlesDefault(); |
| 620 | + } |
| 621 | + |
| 622 | + @Test |
| 623 | + void testUploaderProvidedSubtitles() { |
| 624 | + assertEquals(1, subtitles.stream().filter(s -> !s.isAutoGenerated()).count()); |
| 625 | + } |
| 626 | + |
| 627 | + @Test |
| 628 | + void testAutoGeneratedSubtitles() { |
| 629 | + assertEquals(1, subtitles.stream().filter( |
| 630 | + s -> s.isAutoGenerated() && !s.isAutoTranslated()).count()); |
| 631 | + } |
| 632 | + |
| 633 | + @Test |
| 634 | + void testAutoTranslatedSubtitles() { |
| 635 | + assertTrue(subtitles.stream().anyMatch(SubtitlesStream::isAutoTranslated)); |
| 636 | + } |
| 637 | + } |
| 638 | + |
| 639 | + public static class GeneratedAndTranslatedSubtitles { |
| 640 | + private static YoutubeStreamExtractor extractor; |
| 641 | + private static List<SubtitlesStream> subtitles; |
| 642 | + |
| 643 | + @BeforeAll |
| 644 | + public static void setUp() throws Exception { |
| 645 | + YoutubeTestsUtils.ensureStateless(); |
| 646 | + NewPipe.init(DownloaderFactory.getDownloader(RESOURCE_PATH + "generatedAndTranslatedSubtitles")); |
| 647 | + extractor = (YoutubeStreamExtractor) YouTube |
| 648 | + .getStreamExtractor("https://www.youtube.com/watch?v=_cMxraX_5RE"); |
| 649 | + extractor.fetchPage(); |
| 650 | + subtitles = extractor.getSubtitlesDefault(); |
| 651 | + } |
| 652 | + |
| 653 | + @Test |
| 654 | + void testUploaderProvidedSubtitles() { |
| 655 | + System.out.println("Getestet"); |
| 656 | + assertEquals(9, subtitles.stream().filter(s -> !s.isAutoGenerated()).count()); |
| 657 | + } |
| 658 | + |
| 659 | + @Test |
| 660 | + void testAutoGeneratedSubtitles() { |
| 661 | + assertFalse(subtitles.stream().anyMatch(s -> s.isAutoGenerated() && !s.isAutoTranslated())); |
| 662 | + } |
| 663 | + |
| 664 | + @Test |
| 665 | + void testAutoTranslatedSubtitles() { |
| 666 | + assertTrue(subtitles.stream().anyMatch(SubtitlesStream::isAutoTranslated)); |
| 667 | + } |
| 668 | + |
| 669 | + } |
606 | 670 | } |
0 commit comments