获取腾讯视频真实地址实例

原理是这样的,已知真实的JSON地址(SHD代表高清)

http://vv.video.qq.com/getinfo?vid=视频ID&platform=101001&charge=0&otype=json&defn=shd

例如:https://v.qq.com/x/cover/380idj4s3fxn1mz.html这是一个原地址。

那么这个380idj4s3fxn1mz就是原地址的ID了,但其实并不是。

其实这个地址的真实ID是y003057wcgc

结果如下:

http://vv.video.qq.com/getinfo?vid=y003057wcgc&platform=101001&charge=0&otype=json&defn=shd

返回的JSON是下面这样的

QZOutputJson={"dltype":1,"exem":2,"fl":{"cnt":2,"fi":[{"id":100001,"name":"msd","lmt":0,"sb":1,"cname":"标清;(270P)","br":34,"profile":2,"drm":0,"video":1,"audio":1,"fs":194806719,"super":0,"hdr10enh":0,"sname":"标清","resolution":"270P","sl":1},{"id":2,"name":"mp4","lmt":0,"sb":1,"cname":"高清;(480P)","br":39,"profile":1,"drm":0,"video":1,"audio":1,"fs":411201914,"super":1,"hdr10enh":0,"sname":"高清","resolution":"480P","sl":0}]},"hs":0,"ip":"120.231.25.145","ls":0,"preview":180,"s":"o","sfl":{"cnt":0},"tstid":3,"tm":1582223900,"vl":{"cnt":1,"vi":[{"br":34,"ch":0,"cl":{"fc":0,"keyid":"y003057wcgc.100001"},"ct":21600,"drm":0,"dsb":0,"fmd5":"d05e42aad1ec605fe3d85a4fa6b2dfcc","fn":"y003057wcgc.m1.mp4","fs":194806719,"fst":5,"fvkey":"088271183D74CADFD8F22B0C7024656F56DB24EB8784CBA4A054582C6B6C7FD5045D958E181BE9DDC74CED46AE4AAAF62ACB772B4F93460A8D1D6F92F8143C1F0CEB2D5EDA1293D27803E6CAACD5257F3865F4257AA92659DAC3D4C7E7BCAC16BF9F0D84A322C114FC38C001938DC288","head":0,"hevc":0,"iflag":0,"level":0,"lnk":"y003057wcgc","logo":1,"mst":8,"pl":[{"cnt":3,"pd":[{"cd":10,"h":45,"w":80,"r":10,"c":10,"fmt":40001,"fn":"q1","url":"http://puui.qpic.cn/video_caps/0/"},{"cd":10,"h":90,"w":160,"r":5,"c":5,"fmt":40002,"fn":"q2","url":"http://puui.qpic.cn/video_caps/0/"},{"cd":10,"h":135,"w":240,"r":5,"c":5,"fmt":40003,"fn":"q3","url":"http://puui.qpic.cn/video_caps/0/"}]}],"share":1,"sp":0,"st":2,"tail":0,"td":"5443.11","ti":"钢铁飞龙之奥特曼崛起","tie":0,"type":1036,"ul":{"ui":[{"url":"http://183.240.83.88/vlive.qqvideo.tc.qq.com/AZflgiON4H1h7vX3TM2utQX3ARKAiVjV6N6WdenDJjWc/uwMROfz2r5zAoaQXGdGnC2dfiMVaprY8QrbK21CByPIM2CdQ/","vt":203,"dtc":0,"dt":2},{"url":"http://183.240.82.89/vlive.qqvideo.tc.qq.com/AZflgiON4H1h7vX3TM2utQX3ARKAiVjV6N6WdenDJjWc/uwMROfz2r5zAoaQXGdGnCmdfiMXG-iG9HMEDN08uBg6WC5Rt/","vt":203,"dtc":0,"dt":2},{"url":"http://183.240.83.89/vlive.qqvideo.tc.qq.com/AZflgiON4H1h7vX3TM2utQX3ARKAiVjV6N6WdenDJjWc/uwMROfz2r5zAoaQXGdGnCWdfiMWgH5k-_llZA2_eVQs5f0Er/","vt":203,"dtc":0,"dt":2},{"url":"http://video.dispatch.tc.qq.com/uwMROfz2r5zAoaQXGdGnDGdfiMULMVC62fG3Xw7OoAXI4j7h/","vt":0,"dtc":0,"dt":2}]},"vh":204,"vid":"y003057wcgc","videotype":1,"vr":0,"vst":2,"vw":480,"wh":2.3529413,"wl":{"wi":[]},"uptime":1552656534,"fvideo":0,"cached":1,"fvpint":0,"swhdcp":0,"sshot":3,"mshot":0}]}};
最后我们就要合并了得出最后的播放地址
http://140.249.94.154/vlive.qqvideo.tc.qq.com/AGK5A-CcmAA4B71WmnD7tyneupB6surqhAyBklqQ-AoU/uwMROfz2r5zAoaQXGdGnC2dfiMVaprY8QrbK21CByPIM2CdQ/y003057wcgc.m1.mp4?vkey=10C9BF6598465353B38734984CA1E8FEE7C68C4327E26E29B813E935D202900AC5F30FB82EAFA9B88908BA58E508C324AEC89930F90DA6807F470D8000C68F9E5D40631052FD911387015A70D0755DF20073AE27196A1B856CD8758B7353BB59AE6B26AD119BE406AE18EED0CCB1CBE7

完整PHP实例

<?php
//腾讯视频真实地址
header("Access-Control-Allow-Origin:*");
header('Content-type: application/json');
!empty($_GET['url']) ? $geturl = $_GET['url'] : exit(json_encode([
    'code'=>202,
    "msg"=>"请输入网址"
],JSON_UNESCAPED_UNICODE));
$view = myCurl($geturl);
$b = '&vid=';
$c = '&ptag';
$id = GetBetween($view,$b,$c);
$api = myCurl('http://vv.video.qq.com/getinfo?vid='.$id.'&platform=101001&charge=0&otype=json&defn=shd');
preg_match('/^QZOutputJson=(.*?);$/',$api,$json);
$data = json_decode($json[1],true);
$row = $data['vl']['vi'][0];
if ($row){
	$value = array(
	    'code'=>200,
		'data'=>$row['ul']['ui'][0]['url'].$row['fn']."?vkey=".$row['fvkey']
	);
}else{
	$value = array(
	    'code'=>202,
		'msg'=>'接口失效'
	);
}
echo json_encode($value,JSON_PRETTY_PRINT|JSON_UNESCAPED_UNICODE);
function myCurl($url){ //Curl GET
    $ch = curl_init();     // Curl 初始化  
    $timeout = 30;     // 超时时间:30s  
    $ua='Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/50.0.2661.102 Safari/537.36';    // 伪造抓取 UA  
    $ip = mt_rand(11, 191) . "." . mt_rand(0, 240) . "." . mt_rand(1, 240) . "." . mt_rand(1, 240);
    curl_setopt($ch, CURLOPT_URL, $url);              // 设置 Curl 目标  
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);      // Curl 请求有返回的值  
    curl_setopt($ch, CURLOPT_CONNECTTIMEOUT, $timeout);     // 设置抓取超时时间  
    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);        // 跟踪重定向  
    curl_setopt($ch, CURLOPT_REFERER, $url);   // 伪造来源网址  
    curl_setopt($ch, CURLOPT_HTTPHEADER, array('X-FORWARDED-FOR:'.$ip, 'CLIENT-IP:'.$ip));  //伪造IP  
    curl_setopt($ch, CURLOPT_USERAGENT, $ua);   // 伪造ua   
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); // https请求 不验证证书和hosts  
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);  //不检查 证书中 SSL 加密算法是否存在
    curl_setopt($ch, CURLOPT_AUTOREFERER, true); ////当Location:重定向时,自动设置header中的Referer:信息
    curl_setopt($ch, CURLOPT_ENCODING, '');//解决网页乱码问题
    curl_setopt($ch, CURLOPT_HTTP_VERSION, CURL_HTTP_VERSION_1_0); //强制协议为1.0
    curl_setopt($ch, CURLOPT_IPRESOLVE, CURL_IPRESOLVE_V4 ); //强制使用IPV4协议解析域名
    $content = curl_exec($ch);   
    curl_close($ch);    // 结束 Curl  
    return $content;    // 函数返回内容  
}

// 截取ID
function GetBetween($content,$start,$end) {
	$r = explode($start, $content);
	if (isset($r[1])) {
		$r = explode($end, $r[1]);
		return $r[0];
	}
	return '';
}
1 条回复A管理员Y会员M游客
  1. tourist LV.1
    WiIrono M 沙发
    [url=https://megaremont.pro/msk-restavratsiya-vann]在科洛姆纳丙烯酸浴的改造[/url]