@Nonnull
    static String extractJavaScriptPlayerCode(@Nonnull final String videoId)
            throws ParsingException {
        String url;
        try {
            url = YoutubeJavaScriptExtractor.extractJavaScriptUrlWithIframeResource();
            final String playerJsUrl = YoutubeJavaScriptExtractor.cleanJavaScriptUrl(url);

            // Assert that the URL we extracted and built is valid
            new URL(playerJsUrl);

            return YoutubeJavaScriptExtractor.downloadJavaScriptCode(playerJsUrl);
        } catch (final Exception e) {
            url = YoutubeJavaScriptExtractor.extractJavaScriptUrlWithEmbedWatchPage(videoId);
            final String playerJsUrl = YoutubeJavaScriptExtractor.cleanJavaScriptUrl(url);

            try {
                // Assert that the URL we extracted and built is valid
                new URL(playerJsUrl);
            } catch (final MalformedURLException exception) {
                throw new ParsingException(
                        "The extracted and built JavaScript URL is invalid", exception);
            }

            return YoutubeJavaScriptExtractor.downloadJavaScriptCode(playerJsUrl);
        }
    }
@Test
    public void testExtractJavaScript__success() throws ParsingException {
        String playerJsCode = YoutubeJavaScriptExtractor.extractJavaScriptPlayerCode("d4IGg5dqeO8");
        assertPlayerJsCode(playerJsCode);
    }