Faster iframe api based player extraction. (#694)
* Faster iframe api based player extraction. Uses the IFrame API to reduce the required download to less than 1/50 of the size. * Remove debug code. * Extract to two methods. * Add tests for player URL extraction. * Add assertThat for tests.
This commit is contained in:
@@ -8,8 +8,7 @@ import org.schabi.newpipe.extractor.exceptions.ParsingException;
|
||||
|
||||
import java.io.IOException;
|
||||
|
||||
import static org.hamcrest.CoreMatchers.allOf;
|
||||
import static org.hamcrest.CoreMatchers.containsString;
|
||||
import static org.hamcrest.CoreMatchers.*;
|
||||
import static org.hamcrest.MatcherAssert.assertThat;
|
||||
|
||||
public class YoutubeJavaScriptExtractorTest {
|
||||
@@ -19,6 +18,16 @@ public class YoutubeJavaScriptExtractorTest {
|
||||
NewPipe.init(DownloaderTestImpl.getInstance());
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractJavaScriptUrlIframe() throws ParsingException {
|
||||
assertThat(YoutubeJavaScriptExtractor.extractJavaScriptUrl(), endsWith("base.js"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractJavaScriptUrlEmbed() throws ParsingException {
|
||||
assertThat(YoutubeJavaScriptExtractor.extractJavaScriptUrl("d4IGg5dqeO8"), endsWith("base.js"));
|
||||
}
|
||||
|
||||
@Test
|
||||
public void testExtractJavaScript__success() throws ParsingException {
|
||||
String playerJsCode = YoutubeJavaScriptExtractor.extractJavaScriptCode("d4IGg5dqeO8");
|
||||
|
||||
Reference in New Issue
Block a user