Created
April 23, 2011 21:48
-
-
Save rstrobl/939013 to your computer and use it in GitHub Desktop.
Getting YouTube download URLs for a given video ID
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// 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