Skip to content

Instantly share code, notes, and snippets.

@krisives
Created September 1, 2015 22:50
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save krisives/55345b94f5fd1ca8f2f3 to your computer and use it in GitHub Desktop.
Save krisives/55345b94f5fd1ca8f2f3 to your computer and use it in GitHub Desktop.
<?php
$videoID = @trim($argv[1]);
if (strlen($videoID) <= 0) {
die("USAGE: storyboard <videoid>\n");
}
$html = file_get_contents("https://www.youtube.com/watch?v=$videoID");
$pattern = '#"storyboard_spec":"([^"]+)"#';
if (!preg_match_all($pattern, $html, $matches)) {
die("ERROR: Cannot find storyboard_spec\n");
}
$parts = explode('#', $matches[1][0]);
$url = $parts[0];
$token = $parts[count($parts) - 1];
$url = explode('|', $url);
$url = $url[0];
$url = str_replace(
array('$L', '$N'),
array(2, 'M2'),
$url
);
$url = json_decode("\"$url\"");
echo "$url?sigh=$token\n";
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment