- file_get_contents: documentation ( source)
- json_decode: documentation ( source)
- parse_str: documentation ( source)
- preg_match: documentation ( source)
- error_reporting: documentation ( source)
- explode: documentation ( source)
<?php
error_reporting(E_ERROR);
$data = file_get_contents('youtube.com/watch?v=u7R4kdCi1zY');
preg_match('/ytplayer.config = {(.*?)};/',$data,$match);
$o = json_decode('{'.$match[1].'}') ;
$links = explode(',',$o -> args -> url_encoded_fmt_stream_map);
foreach($links as $link) {
parse_str($link,$r);
echo '<a href="'.$r['url'].'">quality: '.$r['itag'].'</a><br />';
}
?>