-
Notifications
You must be signed in to change notification settings - Fork 420
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[media.ccc.de] Fix live streams extraction
The API was slightly changed and only HLS streams are provided anymore. Add a basic test for to check whether the required streamInfo fields are available. Closes #766
- Loading branch information
Showing
3 changed files
with
69 additions
and
14 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
52 changes: 52 additions & 0 deletions
52
...java/org/schabi/newpipe/extractor/services/media_ccc/MediaCCCLiveStreamExtractorTest.java
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,52 @@ | ||
package org.schabi.newpipe.extractor.services.media_ccc; | ||
|
||
import org.junit.Assert; | ||
import org.junit.Assume; | ||
import org.junit.BeforeClass; | ||
import org.junit.Test; | ||
import org.schabi.newpipe.downloader.DownloaderTestImpl; | ||
import org.schabi.newpipe.extractor.InfoItem; | ||
import org.schabi.newpipe.extractor.NewPipe; | ||
import org.schabi.newpipe.extractor.exceptions.ExtractionException; | ||
import org.schabi.newpipe.extractor.kiosk.KioskExtractor; | ||
import org.schabi.newpipe.extractor.stream.StreamExtractor; | ||
import org.schabi.newpipe.extractor.stream.StreamInfo; | ||
|
||
import java.io.IOException; | ||
import java.util.List; | ||
|
||
import static org.schabi.newpipe.extractor.ServiceList.MediaCCC; | ||
|
||
public class MediaCCCLiveStreamExtractorTest { | ||
|
||
private static KioskExtractor liveKiosk; | ||
private static StreamExtractor extractor; | ||
|
||
private static List<InfoItem> liveItems; | ||
|
||
@BeforeClass | ||
public static void setUp() throws Exception { | ||
NewPipe.init(DownloaderTestImpl.getInstance()); | ||
liveKiosk = MediaCCC.getKioskList().getExtractorById("live", null); | ||
liveKiosk.fetchPage(); | ||
liveItems = liveKiosk.getInitialPage().getItems(); | ||
Assume.assumeFalse( | ||
"Received an empty list of live streams. Skipping MediaCCCLiveStreamExtractorTest", | ||
liveItems.isEmpty()); | ||
} | ||
|
||
@Test | ||
public void testRequiredStreamInfo() { | ||
// Try to get the StreamInfo for each live stream. | ||
// If some required info is not present an exception will be thrown. | ||
try { | ||
for (final InfoItem item : liveItems) { | ||
StreamInfo.getInfo(item.getUrl()); | ||
} | ||
} catch (ExtractionException | IOException e) { | ||
e.printStackTrace(); | ||
Assert.fail("An exception was thrown while getting a StreamInfo for a livestream."); | ||
} | ||
} | ||
|
||
} |