diff --git a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java index 5c9900236..616a3b865 100644 --- a/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java +++ b/extractor/src/main/java/org/schabi/newpipe/extractor/services/media_ccc/extractors/MediaCCCStreamExtractor.java @@ -121,6 +121,8 @@ public class MediaCCCStreamExtractor extends StreamExtractor { mediaFormat = MediaFormat.OPUS; } else if(mimeType.endsWith("mpeg")) { mediaFormat = MediaFormat.MP3; + } else if(mimeType.endsWith("ogg")){ + mediaFormat = MediaFormat.OGG; } else { throw new ExtractionException("Unknown media format: " + mimeType); } @@ -146,8 +148,6 @@ public class MediaCCCStreamExtractor extends StreamExtractor { mediaFormat = MediaFormat.WEBM; } else if(mimeType.endsWith("mp4")) { mediaFormat = MediaFormat.MPEG_4; - } else if(mimeType.endsWith("ogg")){ - mediaFormat = MediaFormat.OGG; } else { throw new ExtractionException("Unknown media format: " + mimeType); } diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java new file mode 100644 index 000000000..8f075ed90 --- /dev/null +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCOggTest.java @@ -0,0 +1,42 @@ +package org.schabi.newpipe.extractor.services.media_ccc; + +import org.junit.BeforeClass; +import org.junit.Test; +import org.schabi.newpipe.Downloader; +import org.schabi.newpipe.extractor.NewPipe; +import org.schabi.newpipe.extractor.services.media_ccc.extractors.MediaCCCStreamExtractor; +import org.schabi.newpipe.extractor.stream.AudioStream; +import org.schabi.newpipe.extractor.stream.StreamExtractor; +import org.schabi.newpipe.extractor.utils.Localization; + + +import static junit.framework.TestCase.assertEquals; +import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; + +/** + * Test {@link MediaCCCStreamExtractor} + */ +public class MediaCCCOggTest { + // test against https://api.media.ccc.de/public/events/1317 + private static StreamExtractor extractor; + + @BeforeClass + public static void setUpClass() throws Exception { + NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); + + extractor = MediaCCC.getStreamExtractor("https://api.media.ccc.de/public/events/1317"); + extractor.fetchPage(); + } + + @Test + public void getAudioStreamsCount() throws Exception { + assertEquals(1, extractor.getAudioStreams().size()); + } + + @Test + public void getAudioStreamsContainOgg() throws Exception { + for(AudioStream stream : extractor.getAudioStreams()) { + System.out.println(stream.getFormat()); + } + } +} diff --git a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java index dc0c64035..9ce475b4a 100644 --- a/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java +++ b/extractor/src/test/java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCSearchExtractorAllTest.java @@ -30,7 +30,7 @@ public class MediaCCCSearchExtractorAllTest { public static void setUpClass() throws Exception { NewPipe.init(Downloader.getInstance(), new Localization("GB", "en")); extractor = MediaCCC.getSearchExtractor( new MediaCCCSearchQueryHandlerFactory() - .fromQuery("c", Arrays.asList(new String[] {"all"}), "") + .fromQuery("c3", Arrays.asList(new String[] {"all"}), "") ,new Localization("GB", "en")); extractor.fetchPage(); itemsPage = extractor.getInitialPage(); @@ -40,6 +40,7 @@ public class MediaCCCSearchExtractorAllTest { public void testIfChannelInfoItemsAvailable() { boolean isAvialable = false; for(InfoItem item : itemsPage.getItems()) { + System.out.println(item); if(item instanceof ChannelInfoItem) { isAvialable = true; } @@ -51,6 +52,7 @@ public class MediaCCCSearchExtractorAllTest { public void testIfStreamInfoitemsAvailable() { boolean isAvialable = false; for(InfoItem item : itemsPage.getItems()) { + System.out.println(item); if(item instanceof StreamInfoItem) { isAvialable = true; }