Skip to content

Commit

Permalink
alternative way of fetching player_response for such videos where tha…
Browse files Browse the repository at this point in the history
…t block does not appear on video page itself
  • Loading branch information
Athlon1600 committed Oct 17, 2020
1 parent e1e0ba2 commit a595645
Showing 1 changed file with 5 additions and 0 deletions.
5 changes: 5 additions & 0 deletions src/YouTubeDownloader.php
Expand Up @@ -226,6 +226,11 @@ public function getDownloadLinks($video_id, $selector = false)
// get JSON encoded parameters that appear on video pages
$json = $this->getPlayerResponse($page_html);

if (empty($json)) {
$json = $this->getVideoInfo($this->extractVideoId($video_id));
$json = Utils::arrayGet($json, 'player_response');
}

// get player.js location that holds signature function
$url = $this->getPlayerScriptUrl($page_html);
$js = $this->getPlayerCode($url);
Expand Down

0 comments on commit a595645

Please sign in to comment.