gpt4 book ai didi

youtube - 获取youtube下载链接[4k,1080px]使用API​​ v3

转载 作者:行者123 更新时间:2023-12-03 05:27:12 30 4
gpt4 key购买 nike

我尝试从获取youtube视频链接

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

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

api v3不允许获取网址

最佳答案

这个功能可以完成工作

<?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 - 获取youtube下载链接[4k,1080px]使用API​​ v3,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45927434/

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com