|

本帖最后由 guoma 于 2023-6-25 21:30 编辑
安徽电视台网页版和APP版ts部分都取消了referfer验证,故两版本php代理都简单了,且运行流畅。
网页版php:
- <?php
- //https://www.ahtv.cn/folder9000/folder20193?channelIndex=0
- $id = isset($_GET['id'])?$_GET['id']:'ahws';
- $n = [
- 'ahws' => 47,
- 'ahjjsh' => 71,
- 'ahzyty' => 73,
- 'ahys' => 72,
- 'ahgg' => 50,
- 'ahnykj' => 51,
- 'ahgj' => 70,
- 'ahyd' => 68,
- ];
- $url = 'http://mapi.ahtv.cn/api/open/ahtv/channel.php?appid=m2otdjzyuuu8bcccnq&appkey=5eab6b4e1969a8f9aef459699f0d9000&is_audio=0&category_id=1';
- $d = json_decode(m3u8($url));
- for($i=0;$i<count($d);$i++){
- if($n[$id] == $d[$i] -> id){
- $m3u8 = $d[$i] -> m3u8;
- }
- }
- $host = 'https://'.parse_url($m3u8)['host'];
- $burl = dirname($m3u8)."/";
- $live = $burl.strstr(m3u8($m3u8),'hd');
- header('Content-Type: application/vnd.apple.mpegurl');
- print_r(preg_replace("/(.*?.ts)/i", $host."$1",m3u8(trim($live))));
- function m3u8($url){
- $ch = curl_init($url);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_HTTPHEADER, ["User-Agent: Mozilla/5.0",]);
- curl_setopt($ch, CURLOPT_REFERER, 'https://www.ahtv.cn/');
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
- ?>
复制代码
APP版php:
- <?php
- error_reporting(0);
- //https://tvzb-hw.ahtv.cn/application/tvradio/h5/detail.html?type=tv
- $id = isset($_GET['id'])?$_GET['id']:'ahws';
- $n = [
- 'ahws' => 11,
- 'ahjjsh' => 12,
- 'ahys' => 13,
- 'ahnykj' => 14,
- 'ahgg' => 16,
- 'ahzyty' => 17,
- 'ahgj' => 18,
- ];
- $url = 'https://tvzb-hw.ahtv.cn/tvradio/Tvfront/getTvInfo?loop=1&tv_id='.$n[$id];
- $m3u8 = json_decode(file_get_contents($url))->data->m3u8;
- $ch = curl_init($m3u8);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_REFERER,'https://tvzb-hw.ahtv.cn/');
- $p = curl_exec($ch);
- curl_close($ch);
- $live = trim(strstr($p,"https"));
- $burl = 'https://'.parse_url($live)['host'];
- $ch = curl_init($live);
- curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
- curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
- curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
- curl_setopt($ch, CURLOPT_REFERER,'https://tvzb-hw.ahtv.cn/');
- $play = curl_exec($ch);
- curl_close($ch);
- header('Content-Type: application/vnd.apple.mpegurl');
- print_r(preg_replace("/(.*?.ts)/i",$burl."$1",$play));
- ?>
复制代码
|
|