Skip to content

Instantly share code, notes, and snippets.

@rstrobl
Created April 23, 2011 21:48
Show Gist options
  • Save rstrobl/939013 to your computer and use it in GitHub Desktop.
Save rstrobl/939013 to your computer and use it in GitHub Desktop.
Getting YouTube download URLs for a given video ID
// fill in the video ID here
$video_id = '';
$info_url = 'http://www.youtube.com/get_video_info?video_id=' . $video_id;
$info_page = file_get_contents($info_url);
// put query strings into local scope
parse_str($info_page);
// parse fmt_stream_map
$stream_map = explode("|", $fmt_stream_map);
// select first stream URL
$yt_url = urldecode($stream_map[1]);
// now you can do anything with $yt_url
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment