Click here to Skip to main content
15,902,198 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hieverybody i have problem to grabbing some video of youtube in my host
video : https://www.youtube.com/watch?v=VhjYaeotTYY[^]
my code
$my_video_info = 'http://www.youtube.com/get_video_info?&video_id='. $my_id;
$my_video_info = curlGet($my_video_info);
parse_str($my_video_info);
$my_formats_array = explode(',',$url_encoded_fmt_stream_map);
if (count($my_formats_array) == 0)
{
    $error = "Error: Could not download video!";
}
else
{
    $avail_formats[] = '';
    $i = 0;
    foreach($my_formats_array as $format) {
        parse_str($format);
        $avail_formats[$i]['itag'] = $itag;
        $avail_formats[$i]['quality'] = $quality;
        $type = explode(';',$type);
        $avail_formats[$i]['type'] = $type[0];
        $avail_formats[$i]['url'] = urldecode($url) . '&signature=' . $sig;
        parse_str(urldecode($url));
        $avail_formats[$i]['expires'] = date("G:i:s T", $expire);
        $avail_formats[$i]['ipbits'] = $ipbits;
        $avail_formats[$i]['ip'] = $ip;
        $i++;
    }
    // $target_formats = array('35','34','5'); BEST QUALITY BUT LARGE FILE
    // $target_formats = array('34','5'); MEDIUM QUALITY
    $target_formats = array('35','34','5');
    $best_format = '';
    for ($i=0; $i < count($target_formats); $i++) {
        for ($j=0; $j < count ($avail_formats); $j++) {
            if($target_formats[$i] == $avail_formats[$j]['itag']) {
                $best_format = $j;
                break 2;
            }
        }
    }
    $flvurl = $avail_formats[$best_format]['url'];
}
Posted
Comments
[no name] 24-Dec-14 10:59am    
Thank you for your code. We are keen now on your question :P

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900