乐于分享
好东西不私藏

云南省台代理源码

云南省台代理源码

需切片、耗流量,需国内主机,速度取决于你的主机能力
测试列表
云南卫视,http://cn.sohu.blog/yntv.php?id=yunnanweishi云南都市,http://cn.sohu.blog/yntv.php?id=yunnandushi云南娱乐,http://cn.sohu.blog/yntv.php?id=yunnanyule康旅频道,http://cn.sohu.blog/yntv.php?id=yunnangonggong澜湄国际,http://cn.sohu.blog/yntv.php?id=yunnanguoji云南少儿,http://cn.sohu.blog/yntv.php?id=yunnanshaoer
代理不代理的,其实不重要,因为有固定的地址可以看。

源码如下:
<?php/*云南卫视,yntv.php?id=yunnanweishi云南都市,yntv.php?id=yunnandushi云南娱乐,yntv.php?id=yunnanyule康旅频道,yntv.php?id=yunnangonggong澜湄国际,yntv.php?id=yunnanguoji云南少儿,yntv.php?id=yunnanshaoer*/if(need_m3u8($id$ts_url)) {    $u get_m3u8_url($id);    $c send_request($u$ct$u);    $c replace_ts_urls($u$c);else {    $c send_request($ts_url$ct);}echo_content($ct$c);functionneed_m3u8(&$id, &$ts_url){    $q $_SERVER['QUERY_STRING'];    $r stripos($q'id=') === 0;    if($r)        $id $_GET['id'];    else        $ts_url $q;    return $r;}functionget_m3u8_url($id){    $r load_from_cache($id);    if($r)        return $r;    $p get_m3u8_url_from_web($id);    $r get_actual_m3u8_url($p);    save_to_cache($id$r);    return $r;}functionget_m3u8_url_from_web($id{    $u "https://yntv-api.yntv.cn/index/jmd/getRq?name=$id";    $c send_request($u);    $j json_decode($c);    $r "https://tvlive.yntv.cn{$j->url}?wsSecret={$j->string}&wsTime={$j->time}";    return $r;}functionget_actual_m3u8_url($index_m3u8_url{    $c send_request($index_m3u8_url$ct$r);    if(stripos($c'#EXT-X-STREAM-INF:') !== false) {        $a explode("\n"$c);        foreach($a as $i) {            $i trim($i);            if(strpos($i'#') !== 0) {                if(is_absolute_url($i))                    $r $i;                else                    $r dirname($r)."/".$i;                break;            }        }    }    return $r;}functionsave_to_cache($id$url){    $a[$id]['expire_time'] = time() + 60 * 60;    $a[$id]['url'] = $url;    array_to_file($a'yntv_cache.txt');}functionload_from_cache($id){    file_to_array('yntv_cache.txt'$a);    if(isset($a) && isset($a[$id]) && $a[$id]['expire_time'] > time())        return $a[$id]['url'];    else        return '';}functionfile_to_array($filename, &$array{    $array = [];    if(file_exists($filename)) {        $handle fopen($filename'r');        if(flock($handle, LOCK_SH)) { // 共享锁,允许其他进程读但禁止写            $data file_get_contents($filename);            $array unserialize($data);            flock($handle, LOCK_UN);        }        fclose($handle);    }    return true;}functionarray_to_file($array$filename{    $data serialize($array);    file_put_contents($filename$data, LOCK_EX);    return true;}functionsend_request($url, &$content_type null, &$final_url null){    $ch curl_init($url);    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);    curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true);    curl_setopt($ch, CURLOPT_REFERER, 'https://www.yntv.cn/');    $ua 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/138.0.0.0 Safari/537.36';    curl_setopt($ch, CURLOPT_USERAGENT, $ua);    $res curl_exec($ch);    if(func_num_args() > 1)        $content_type curl_getinfo($ch, CURLINFO_CONTENT_TYPE);    if(func_num_args() > 2)        $final_url curl_getinfo($ch, CURLINFO_EFFECTIVE_URL);    curl_close($ch);    return $res;}functionreplace_ts_urls($m3u8_url$m3u8_content){    $dest_ts_path dirname($m3u8_url)."/";    $protocol = !empty($_SERVER['HTTPS']) ? 'https' : 'http';    $self_part "$protocol://".$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];    return preg_replace_callback("/^((?!#).+)$/im",        function ($matchesuse ($self_part, $dest_ts_path) {            if (!is_absolute_url($matches[1]))                $ts = $dest_ts_path.$matches[1];            else                $ts $matches[1];            return "$self_part?$ts";        },        $m3u8_content    );}functionis_absolute_url($url{    return stripos($url'http:') === 0 || stripos($url'https:') === 0;}functionecho_content($content_type$content){    header("Access-Control-Allow-Origin: *");    header("Content-Type: $content_type");    echo $content;}
本站文章均为手工撰写未经允许谢绝转载:夜雨聆风 » 云南省台代理源码

评论 抢沙发

2 + 3 =
  • 昵称 (必填)
  • 邮箱 (必填)
  • 网址
×
订阅图标按钮