乐于分享
好东西不私藏

广东电视台省级频道代理源码

广东电视台省级频道代理源码

广东电视台省级频道代理源码,部分频道间歇性因为版权原因无法观看某段内容,建议此类节目收看酒店源或者组播源

代理测试:仅供测试使用,随时删除

广东卫视,http://cn.sohu.blog/gdtv.php?id=43广东珠江频道,http://cn.sohu.blog/gdtv.php?id=44广东新闻频道,http://cn.sohu.blog/gdtv.php?id=45广东民生频道,http://cn.sohu.blog/gdtv.php?id=48大湾区卫视,http://cn.sohu.blog/gdtv.php?id=51大湾区卫视海外版,http://cn.sohu.blog/gdtv.php?id=46广东影视频道,http://cn.sohu.blog/gdtv.php?id=53广东少儿频道,http://cn.sohu.blog/gdtv.php?id=54嘉佳卡通,http://cn.sohu.blog/gdtv.php?id=66南方购物,http://cn.sohu.blog/gdtv.php?id=42岭南戏曲,http://cn.sohu.blog/gdtv.php?id=15广东移动,http://cn.sohu.blog/gdtv.php?id=74广东现代教育,http://cn.sohu.blog/gdtv.php?id=111广东台经典剧,http://cn.sohu.blog/gdtv.php?id=100GRTN健康频道,http://cn.sohu.blog/gdtv.php?id=99GRTN文化频道,http://cn.sohu.blog/gdtv.php?id=75GRTN生活频道,http://cn.sohu.blog/gdtv.php?id=102广东体育频道,http://cn.sohu.blog/gdtv.php?id=47

代理源码:

<?php/*广东卫视 43广东珠江 44广东新闻 45大湾区卫视(海外版) 46广东体育 47广东民生 48大湾区卫视 51广东影视 53  *4K超高清 16广东少儿 54嘉佳卡通 66南方购物 42岭南戏曲 15广东移动 74现代教育 111广东台经典剧 100 *纪录片 *GRTN健康频道 99GRTN文化频道 75GRTN生活频道 102http://gd.sohu.blog*/main($_GET['id']);functionmain($id){    $r = load_from_cache($id);    if($r && locate_or_echoContent($r)) {        return;    }    $r = get_m3u8_url_from_web($id);    save_to_cache($id, $r);    locate_or_echoContent($r);}functionlocate_or_echoContent($url){    if(can_locate($url['url'])) {        locate($url['url']);        return true;    } else {        $c = request($url['url'], false);        if(!empty($c)) {            echo_content($c);            return true;        }    }    return false;}functioncan_locate($url){    $h = parse_url($url, PHP_URL_HOST);    return strpos($h, '.itouchtv.cn') === false;}functionlocate($url) {    header('Access-Control-Allow-Origin: *');    header('Location: '.$url);}functionecho_content($content){    header("Access-Control-Allow-Origin: *");    header("Content-Type: application/vnd.apple.mpegurl");    echo $content;}functionget_m3u8_url_from_web($id) {    $url = "https://tcdn-api.itouchtv.cn/getParam";    $data = request($url);    $json = json_decode($data);    $node = $json->node;    send_heartbeat($node, false, $wsnode);//    request($url);    $url = "https://gdtv-api.gdtv.cn/api/tv/v2/tvChannel/$id?node=".base64_encode($wsnode);    request($url, false, "OPTIONS");    $data = request($url);    $json = json_decode($data);    $playURL = json_decode($json->playUrl)->hd;    return [        'url' => $playURL,        'node' => $node,    ];}functionsave_to_cache($id, $url){    array_to_file($url, "gdtv_cache/$id.txt");}functionload_from_cache($id){    $cacheFile = "gdtv_cache/$id.txt";    $expireSeconds = 60 * 30;    if(file_exists($cacheFile) && (time() - filemtime($cacheFile) < $expireSeconds)) {        file_to_array($cacheFile, $a);        return $a;    } else {        return null;    }}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) {    $dir = dirname($filename);    if(!is_dir($dir) && is_writable(dirname($dir))) {        if(!@mkdir($dir, 0755, true))            return false;    }    $data = serialize($array);    file_put_contents($filename, $data, LOCK_EX);    return true;}functionrequest($url, $sign_in_header = true, $method = null) {    $ch = curl_init();    $o = [        CURLOPT_URL => $url,        CURLOPT_RETURNTRANSFER => true,        CURLOPT_SSL_VERIFYPEER => false,    ];    if($sign_in_header) {        $t = round(microtime(true) * 1000);        $k = 'dfkcY1c3sfuw1Cii9DWj8UO3iQy2hqlDxyvDXd1oVMxwYVDSgeB6phO9eW1dfuwX';        $sign = base64_encode(hash_hmac("SHA256","GET\n$url\n$t\n",$k,true));        $header = [            "Referer: https://www.gdtv.cn/",            "Origin: https://www.gdtv.cn",//            "User-Agent: Mozilla/5.0 (Linux; U; Android 9; zh-cn; Redmi Note 5 Build/PKQ1.180904.001) AppleWebKit/537.36 (KHTML, like Gecko) Version/4.0 Chrome/71.0.3578.141 Mobile Safari/537.36 XiaoMi/MiuiBrowser/11.10.8",            "User-Agent: Mozilla/5.0 (Linux; U; Android 9)",            "X-Itouchtv-Ca-Key: 89541943007407288657755311868534",            "X-Itouchtv-Ca-Signature: $sign",            "X-Itouchtv-Ca-Timestamp: $t",            "X-Itouchtv-Client: WEB_M",            "X-Itouchtv-Device-Id: WEBM_0",        ];    } else {        $header = [            "Referer: https://www.gdtv.cn/",        ];    }    $o[CURLOPT_HTTPHEADER] = $header;    if($method !== null)        $o[CURLOPT_CUSTOMREQUEST] = $method;    curl_setopt_array($ch, $o);    $data = curl_exec($ch);    if($data === false) {        echo 'Err ' . curl_errno($ch) .': '. curl_error($ch);        curl_close($ch);        die;    }    curl_close($ch);    return $data;}functionsend_heartbeat($node, $twice = false, &$wsnode = null) {    $encode = function($data) {        $len = strlen($data);        $head[0] = 129;        $mask = [];        for($j = 0; $j < 4; $j ++) {            $mask[] = mt_rand(1, 128);        }        $split = str_split(sprintf('%016b', $len), 8);        $head[1] = 254;        $head[2] = bindec($split[0]);        $head[3] = bindec($split[1]);        $head = array_merge($head, $mask);        foreach($head as $k => $v) {            $head[$k] = chr($v);        }        $mask_data = '';        for($j = 0; $j < $len; $j ++) {            $mask_data .= chr(ord($data[$j]) ^ $mask[$j % 4]);        }        return implode('', $head).$mask_data;    };    $result = false;//    static $sock = null;    $contextOptions = ['ssl' => ["verify_peer"=>false,"verify_peer_name"=>false]];    $context = stream_context_create($contextOptions);//    if ($sock === null)        $sock = stream_socket_client("ssl://tcdn-ws.itouchtv.cn:3800",$errno,$errstr,5,STREAM_CLIENT_CONNECT,$context);    stream_set_timeout($sock,5);    $key = '';    for($i = 0; $i < 16; $i++) {        $key .= chr(rand(33, 126));    }    $key = base64_encode($key);    $header = '';    $header .= "GET /connect HTTP/1.1\r\n";    $header .= "Host: tcdn-ws.itouchtv.cn:3800\r\n";    $header .= "Upgrade: websocket\r\n";    $header .= "Sec-WebSocket-Key: $key\r\n";    fwrite($sock,$header."\r\n");    $handshake = fread($sock, 4096);    if(strstr($handshake,'Sec-Websocket-Accept')) {        $wssData = json_encode(['route' => 'getwsparam','message' => $node]);        $encoded_data = $encode($wssData);        fwrite($sock, $encoded_data);        if(func_num_args() > 2) {            $param = fread($sock, 4096);            $param = substr($param,4);            $json = json_decode($param);            $wsnode = $json->wsnode;        }//        if ($twice) {//            fread($sock, 4096);//            fwrite($sock, $encoded_data);//        }        $result = true;    }    fclose($sock);    return $result;}
本站文章均为手工撰写未经允许谢绝转载:夜雨聆风 » 广东电视台省级频道代理源码

评论 抢沙发

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