|
发表于 2024-7-23 17:06:37
|
显示全部楼层
根据楼主python代码转成的php代码
- <?php
- error_reporting(0);
- $ts = $_GET['ts'];
- if(!$ts){
- $id = isset($_GET['id'])?$_GET['id']:'sxws';
- $n=[
- 'sxws'=> 'X6feiLQ',//陕西卫视
- 'sxxw'=>'SeT8Mem',//陕西新闻咨询
- 'sxds'=>'zAJprk2',//陕西都市青春
- 'sxsh'=>'a73O8Sd',//陕西生活
- 'sxys'=>'hi6TLBq',//陕西影视
- 'sxgg'=>'8aCj3gK',//陕西公共
- 'sxgw'=>'6z7fbD6',//陕西乐家购物
- 'sxxy'=>'LLhVrGZ',//陕西休闲体育
- 'sxyd'=> 'Au7pR2j',//陕西移动
- 'nlws'=>'etLf04K', //陕西农林卫视
- 'xatv1'=>'BmS21Wa',//陕西西安1套综合
- 'xytv1'=>'9xmmLy4',//陕西咸阳1套综合
- 'yatv1'=>'14c199y',//陕西延安1套综合
- 'wntv1'=>'BmSLiAx',//陕西渭南1套综合
- 'hztv1'=>'mul2l4m',//陕西汉中1套综合
- 'aktv1'=>'ebUpMpG',//陕西安康1套综合
- 'sltv1'=>'21HiFQt',//陕西商洛1套综合
- 'tctv1'=>'78d3NMg',//陕西铜川1套综合
- 'yltv1'=>'Uys5UFs',//陕西杨凌1套综合
- 'yltv2'=>'EQiV8hZ',//陕西榆林1套综合
- ];
- $baseurl=file_get_contents('https://ssp-api.sxtvs.com.cn//apiv4.3/api/m3u8_notoken?channelid='.$n[$id].'&site=76');
- $json=json_decode($baseurl,true);
- $m3u8=$json['data']['address'];
- $burl = dirname($m3u8)."/";
- $php = "http://".$_SERVER ['HTTP_HOST'].$_SERVER['PHP_SELF'];
- header('Content-Type: application/vnd.apple.mpegurl');
- print_r(preg_replace("/(.*?.ts)/i", $php."?ts=$burl$1",m3u8(trim($m3u8))));
- } else {
- $data = m3u8($ts);
- header('Content-Type: video/MP2T');
- echo $data;
- }
-
- function m3u8($url){
- $h = [
- 'Origin: https://ssp.sxtvs.com.cn',
- 'Referer: https://ssp.sxtvs.com.cn/',
- 'User-Agent: TideNews/4.3.1 (iPhone; iOS 15.6; Scale/2.00)',
- ];
- $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, $h);
- curl_setopt($ch, CURLOPT_REFERER, 'https://ssp.sxtvs.com.cn/');
- $result = curl_exec($ch);
- curl_close($ch);
- return $result;
- }
复制代码 |
评分
-
查看全部评分
|