本文介绍了获取 youtube 下载链接 [4k , 1080px] 使用 API v3的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我尝试从

http://www.youtube.com/get_video_info?video_id=XXXXXXXX

但是 1080 px 和 4k 不在列表中所以我如何获得此分辨率的链接

But 1080 px and 4k is not in the list So how i can get links for this resolution

api v3 不允许获取 url

api v3 not allow to get url

推荐答案

这个功能可以解决问题

<?php
function get_youtube($id)
{
    $data = file_get_contents('http://youtube.com/get_video_info?video_id=' . $id . '&el=vevo&fmt=18&asv=2&hd=1');

    parse_str($data , $details);
    $my_formats_array = explode(',' , $details['adaptive_fmts']);
    $avail_formats[] = '';
    $i = 0;
    $ipbits = $ip = $itag = $sig = $quality_label = '';
    $expire = time();

    foreach ($my_formats_array as $format) {
         parse_str($format);
         $avail_formats[$i]['itag'] = $itag;
         $avail_formats[$i]['quality'] = $quality_label;
         $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++;
     }
     return $avail_formats;
}
$qualitys = get_youtube($_GET['id']);

foreach($qualitys as $video)
{
    //echo "<a href='" . $video['url'] . "'>" . $video['quality'] . "-" . $video['type'] .  "</a></br>"; //print all resolution
    // for getting 1080p only
    if($video['quality']=='1080p' && $video['type']=='video/mp4'){
        echo "<a href='" . $video['url'] . "'>" . $video['quality'] . "-" . $video['type'] .  "</a></br>";
    }
}

这篇关于获取 youtube 下载链接 [4k , 1080px] 使用 API v3的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-28 15:30