wbt5 / real-url

获取斗鱼&虎牙&哔哩哔哩&抖音&快手等 58 个直播平台的真实流媒体地址(直播源)和弹幕,直播源可在 PotPlayer、flv.js 等播放器中播放。
GNU General Public License v2.0
7.43k stars 1.54k forks source link

虎牙直播问题 #203

Open dingzhengjie opened 3 years ago

dingzhengjie commented 3 years ago

这是php代码 $id=$_GET[id]; $url = "https://www.huya.com/".$id; $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $url); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); $re = curl_exec($ch); $re = htmlspecialchars($re); curl_close($ch); preg_match('|stream": "(.?)" };|i',$re,$play); $play = base64_decode($play[1]); preg_match('|sStreamName":"(.?)","|i',$play,$name); preg_match('|m3u8","sHlsAntiCode":"(.*?)","|i',$play,$pam); $pam = str_replace("&","&",$pam[1]); //$playurl = "http://121.12.115.15/txdirect.flv.huya.com/src/".$name[1].".m3u8"; $playurl = "http://121.12.115.15/tx.hls.huya.com/src/".$name[1].".m3u8";

header('Location:'.$playurl);

使用这个就能用,希望对你有帮助

DysaniazzZ commented 3 years ago

这是走的回源地址?

dingzhengjie commented 3 years ago

这是走的回源地址?

不清楚,这是别人发的,目前是能用的

rain-dl commented 3 years ago

已基于这个方法更新了虎牙地址的获取,并更新到了Pull Requests中。

wjxgzz commented 3 years ago

CDN不带尾巴的请参考 ****.v.smtcdns.net

下面是正常使用的PHP代码[容错代码请自行处理]

`<?php

$rid = $_GET['id'];
$bstrURL = "https://mp.huya.com/cache.php?m=Live&do=profileRoom&roomid=$rid";
$ch = curl_init();
curl_setopt($ch,CURLOPT_URL,$bstrURL);
curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
$data = curl_exec($ch);
curl_close($ch);

$json = json_decode($data);
$bStreamLst = $json->data->stream->baseSteamInfoList[0];

$sStreamName = $bStreamLst->sStreamName;
$sHlsUrl = $bStreamLst->sHlsUrl;
$sAntiCode = $bStreamLst->sHlsAntiCode;

parse_str($sAntiCode,$params);
$fm = base64_decode($params['fm']);
$wsTime = $params['wsTime'];
$ctype = $params['ctype'];
$seqid = time().'000'; // uid(0) + date.now() == 13位时间戳
$i = md5($seqid.'|'.$ctype.'|100'); // t = 100 若为动态请从AntiCode获取

$wsSecret = md5(str_replace(['$0','$1','$2','$3'],['0',$sStreamName,$i,$wsTime],$fm));  // uid_streamname_hash_wstime

$szURL = $sHlsUrl.'/'.$sStreamName.'.m3u8?wsSecret='.$wsSecret.'&wsTime='.$wsTime.'&uid=0&fm='.urlencode(base64_encode($fm)).'&ctype='.$ctype.'&seqid='.$seqid.'&ver=1&t=100';

header('location:'.$szURL);

?>`

dingzhengjie commented 3 years ago

CDN不带尾巴的请参考 ****.v.smtcdns.net

下面是正常使用的PHP代码[容错代码请自行处理]

`<?php

$rid = $_GET['id'];

$bstrURL = "https://mp.huya.com/cache.php?m=Live&do=profileRoom&roomid=$rid";

$ch = curl_init();

curl_setopt($ch,CURLOPT_URL,$bstrURL);

curl_setopt($ch,CURLOPT_RETURNTRANSFER,true);

curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE); 

curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);

$data = curl_exec($ch);

curl_close($ch);

$json = json_decode($data);

$bStreamLst = $json->data->stream->baseSteamInfoList[0];

$sStreamName = $bStreamLst->sStreamName;

$sHlsUrl = $bStreamLst->sHlsUrl;

$sAntiCode = $bStreamLst->sHlsAntiCode;

parse_str($sAntiCode,$params);

$fm = base64_decode($params['fm']);

$wsTime = $params['wsTime'];

$ctype = $params['ctype'];

$seqid = time().'000'; // uid(0) + date.now() == 13位时间戳

$i = md5($seqid.'|'.$ctype.'|100'); // t = 100 若为动态请从AntiCode获取

$wsSecret = md5(str_replace(['$0','$1','$2','$3'],['0',$sStreamName,$i,$wsTime],$fm));  // uid_streamname_hash_wstime

$szURL = $sHlsUrl.'/'.$sStreamName.'.m3u8?wsSecret='.$wsSecret.'&wsTime='.$wsTime.'&uid=0&fm='.urlencode(base64_encode($fm)).'&ctype='.$ctype.'&seqid='.$seqid.'&ver=1&t=100';

header('location:'.$szURL);

?>`

可以用么

dingzhengjie commented 3 years ago

我这个不是永久的,也是代理的,http://121.12.115.15/这个地址容易失效 @wbt5

wjxgzz commented 3 years ago

我这个不是永久的,也是代理的,http://121.12.115.15/这个地址容易失效 @wbt5

http://0d6e0ab7f6b628dc024bfbffd1dc637a.v.smtcdns.net/tx.hls.huya.com/src/1394575534-1394575534-5989656310331736064-2789274524-10057-A-0-1-imgplus.m3u8

dingzhengjie commented 3 years ago

我这个不是永久的,也是代理的,http://121.12.115.15/这个地址容易失效 @wbt5

http://0d6e0ab7f6b628dc024bfbffd1dc637a.v.smtcdns.net/tx.hls.huya.com/src/1394575534-1394575534-5989656310331736064-2789274524-10057-A-0-1-imgplus.m3u8

感谢,刚测试,可用

WincerChan commented 3 years ago

121.12.115.15 已失效,121.12.115.26 可用

Ch1cC commented 3 years ago

121.12.115.26 还是用不了

sparkssssssss commented 3 years ago

请教,虎牙现在是怎么解决的啊,以上的ip都不行啊,江苏移动

sparkssssssss commented 3 years ago

我这个不是永久的,也是代理的,http://121.12.115.15/这个地址容易失效 @wbt5

http://0d6e0ab7f6b628dc024bfbffd1dc637a.v.smtcdns.net/tx.hls.huya.com/src/1394575534-1394575534-5989656310331736064-2789274524-10057-A-0-1-imgplus.m3u8

谢谢,可用