linuxfans 发表于 2023-11-10 09:34

已有 5 人购买  本主题需向作者支付 2 币恩山币 才能浏览 购买主题

linuxfans 发表于 2023-11-10 09:37




接上面的代码:

如果打不开时,就要调整下面源码更换参数了。




<div>    // 以下缓存类来自互联网,请确保cache目录存在以及读写权限 //


<div>      $bstrURL = "https://gdtv-api.gdtv.cn/api/tv/v2/tvChannel/$id?tvChannelPk=$id&node=".base64_encode($wsnode);
      $sign = base64_encode(hash_hmac("SHA256","GET\n$bstrURL\n$ts\n","dfkcY1c3sfuw0Cii9DWjOUO3iQy2hqlDxyvDXd1oVMxwYAJSgeB6phO8eW1dfuwX",true));

      $opt_headers = [
            "access-control-request-headers: content-type,x-itouchtv-ca-key,x-itouchtv-ca-signature,x-itouchtv-ca-timestamp,x-itouchtv-client,x-itouchtv-device-id",
            "access-control-request-method: GET",
            "origin: https://www.gdtv.cn",
            "referer: https://www.gdtv.cn",
            "user-agent: Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/100.0.4896.75 Safari/537.36",
            
      ];


      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $bstrURL);<span style="white-space:pre">        </span> <span style="white-space:pre">        </span>
      curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "OPTIONS");<span style="white-space:pre">        </span>
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
      curl_setopt($ch, CURLOPT_HTTPHEADER,$opt_headers);
      $data = curl_exec($ch);
      curl_close($ch);

      array_pop($headers);
      $headers[] = "x-itouchtv-ca-signature: $sign";
      
      $ch = curl_init();
      curl_setopt($ch, CURLOPT_URL, $bstrURL);<span style="white-space:pre">        </span> <span style="white-space:pre">        </span>
      curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
      curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
      curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
      curl_setopt($ch, CURLOPT_HTTPHEADER,$headers);
      $data = curl_exec($ch);
      
      curl_close($ch);
      $json = json_decode($data);
      $playURL = json_decode($json->playUrl)->hd;
      $cache->put("gdtv_".$id."_cache",$playURL);
      fclose($sock); // 取串完成再关闭wss
    }
    // m3u8清单有referer校验。
    $ch = curl_init();
    curl_setopt($ch, CURLOPT_URL, $playURL);<span style="white-space:pre">        </span> <span style="white-space:pre">        </span>
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, FALSE);
    curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, FALSE);
    curl_setopt($ch, CURLOPT_HTTPHEADER,["Referer: https://www.gdtv.cn","origin: https://www.gdtv.cn"]);
    $data = curl_exec($ch);
    curl_close($ch);

    header("Content-Type: application/vnd.apple.mpegURL");
    header("Content-Disposition: filename=$id.m3u8");
    echo $data;

   
    function genSecKey()
    {
      return base64_encode(substr(md5(mt_rand(1,999)),0,16));
    }

    function encode($data)
    {

      $len = strlen($data);
      $head = 129;
      $mask = [];
      for ($j = 0; $j < 4; $j ++)
      {
            $mask[] = mt_rand(1, 128);
      }
      $split = str_split(sprintf('%016b', $len), 8);
      $head = 254;
      $head = bindec($split);
      $head = bindec($split);
      $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;

    }
    function createNewGUID()
    {
      if (function_exists('com_create_guid') === true)
      {
            return trim(com_create_guid(), '{}');
      }
      return sprintf('%04X%04X-%04X-%04X-%04X-%04X%04X%04X', mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(16384, 20479), mt_rand(32768, 49151), mt_rand(0, 65535), mt_rand(0, 65535), mt_rand(0, 65535));
    }


    // 以下缓存类来自互联网,请确保cache目录存在以及读写权限 //
    class Cache {

      private $cache_path;
      private $cache_expire;
      public function __construct($exp_time=3600,$path="cache/"){
            $this->cache_expire=$exp_time;
            $this->cache_path=$path;
      }

      private function fileName($key){return $this->cache_path.md5($key); }
      public function put($key, $data){

            $values = serialize($data);
            $filename = $this->fileName($key);   
            $file = fopen($filename, 'w');
            if ($file){

                fwrite($file, $values);
                fclose($file);
            }
            else return false;
      }

      public function get($key){

            $filename = $this->fileName($key);

            if (!file_exists($filename) || !is_readable($filename)){ return false; }

            if ( time() < (filemtime($filename) + $this->cache_expire) ) {

                $file = fopen($filename, "r");

                if ($file){

                  $data = fread($file, filesize($filename));
                  fclose($file);
                  return unserialize($data);
                }
                else return false;

            }
            else return false;
      }
    }

?></div>

</div>

jing.we 发表于 2023-11-10 09:41

看看是什么。

_Samlibra 发表于 2023-11-10 09:44

不错不错!!!

nhyhb 发表于 2023-11-10 09:48

枝网】源分析

wellan 发表于 2023-11-10 09:56

感谢分享

ALIPAY 发表于 2023-11-10 09:56

要调整下面源码更换参数了

paradislover 发表于 2023-11-10 10:14

如果打不开时,就要调整下面源码更换参数了。

yxxy 发表于 2023-11-10 10:15

谢谢楼主分享

winrjfx 发表于 2023-11-10 10:16

不懂啊

nhyhb 发表于 2023-11-10 10:19

好象不行喔

cxjys 发表于 2023-11-10 10:19

感谢你的分享

txatxa 发表于 2023-11-10 10:28

看看是啥

EScZkc_1d8 发表于 2023-11-10 11:06

看看是啥。

wuyanzhijian 发表于 2023-11-10 11:19

看看是个啥
页: [1] 2 3 4 5 6 7 8 9 10
查看完整版本: 【广东台】【荔枝网】源分析解码。。。。。。。。