Skip to content

Commit

Permalink
Add tests for player URL extraction.
Browse files Browse the repository at this point in the history
  • Loading branch information
FireMasterK committed Aug 4, 2021
1 parent c2cce97 commit 6296183
Show file tree
Hide file tree
Showing 2 changed files with 12 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -73,7 +73,7 @@ public static void resetJavaScriptCode() {
cachedJavaScriptCode = null;
}

private static String extractJavaScriptUrl() throws ParsingException {
public static String extractJavaScriptUrl() throws ParsingException {
try {
final String iframeUrl = "https://www.youtube.com/iframe_api";
final String iframeContent = NewPipe.getDownloader()
Expand All @@ -88,7 +88,7 @@ private static String extractJavaScriptUrl() throws ParsingException {
throw new ParsingException("Iframe API did not provide YouTube player js url");
}

private static String extractJavaScriptUrl(final String videoId) throws ParsingException {
public static String extractJavaScriptUrl(final String videoId) throws ParsingException {
try {
final String embedUrl = "https://www.youtube.com/embed/" + videoId;
final String embedPageContent = NewPipe.getDownloader()
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,16 @@ public void setup() throws IOException {
NewPipe.init(DownloaderTestImpl.getInstance());
}

@Test
public void testExtractJavaScriptUrlIframe() throws ParsingException {
YoutubeJavaScriptExtractor.extractJavaScriptUrl();
}

@Test
public void testExtractJavaScriptUrlEmbed() throws ParsingException {
YoutubeJavaScriptExtractor.extractJavaScriptUrl("d4IGg5dqeO8");
}

@Test
public void testExtractJavaScript__success() throws ParsingException {
String playerJsCode = YoutubeJavaScriptExtractor.extractJavaScriptCode("d4IGg5dqeO8");
Expand Down

0 comments on commit 6296183

Please sign in to comment.