美文网首页
获取腾讯视频

获取腾讯视频

作者: taitou | 来源:发表于2018-04-19 16:12 被阅读0次

    <pre><code>
    <?php
    if(is_array($_GET)&&count($_GET)>0){
    if(isset($_REQUEST["url"])){
    $url=$_REQUEST["url"];//存在
    //公用参数
    $vid = $url;
    $guid = "2073222a85166fd9380876bfb5cac383"; // 发觉有问题用不了就要换,抓包看

      // 查找getinfo filename https://h5vv.video.qq.com/getinfo
    $params = array(
      'charge'=>0,
      'vid'=>$vid, // url或html获取
      'defaultfmt'=>'auto',
      'otype'=>'json',
      'guid'=>$guid, // 发觉有问题用不了就要换,抓包看
      'platform'=>plt,
      'defnpayver'=>1,
      'appVer'=>'3.0.83',
      'sdtfrom'=>std,
      'host'=>'v.qq.com',
      // 'ehost'=>'https%3A%2F%2Fv.qq.com%2Fx%2Fcover%2Fnuijxf6k13t6z9b%2Fl0023olk3g4.html',
      'defn'=>'mp4',
      'fhdswitch'=>0,
      'show1080p'=>1,
      'isHLS'=>0,
      'newplatform'=>'v1010',
      'defsrc'=>1,
      '_0'=>'undefined',
      '_1'=>'undefined',
      '_2'=>'undefined',
      // rand(min,max)
      // '_'=>int(round(time() * 1000)),
      '_'=>round(time() * 1000),
      // 'callback'=>jsonpCallback, // 返回json的前缀
    );  
    
    $params = http_build_query($params);  // 把参数转换成URL数据  
    // $sUrl = 'https://h5vv.video.qq.com/getinfo'; //此处必须为完整路径  
    $sUrl = "https://h5vv.video.qq.com/getinfo?" . $params; 
    $opts = array(
      'http'=>array(
        'method'=>"GET",
        'timeout'=>100,
      )
    );
    $context = stream_context_create($opts);
    $d = @file_get_contents($sUrl,false,$context);  
    // echo $d; 
    
    $json_data = preg_replace("/\t|QZOutputJson=/","",$d);
    $json_data = preg_replace("/\t|;/","",$json_data);
    echo "<br>-------------json_data:--------<br>" . $json_data;
    
    $json_data_arry = json_decode($json_data, true);
    // echo $json_data_arry; 
    // var_dump($json_data_arry);
    // echo $json_data_arry["vl"]; 
    // var_dump($json_data_arry["vl"]["vi"][0]["fn"]);
    
    // 视频文件名
    $filename = $json_data_arry["vl"]["vi"][0]["fn"];
    // $filename = $vid . ".p712.1.mp4";
    echo "<br>-------------filename:--------<br>" . $filename;
    $keyid = $json_data_arry["vl"]["vi"][0]["cl"]["keyid"];
    echo "<br>-------------keyid:--------<br>" . $keyid;
    $fvkey = $json_data_arry["vl"]["vi"][0]["fvkey"];
    // 视频url前缀
    $url_prefix_0 = $json_data_arry["vl"]["vi"][0]["ul"]["ui"][0]["url"];
    $url_prefix_1 = $json_data_arry["vl"]["vi"][0]["ul"]["ui"][1]["url"];
    $url_prefix_2 = $json_data_arry["vl"]["vi"][0]["ul"]["ui"][2]["url"];
    $url_prefix_3 = $json_data_arry["vl"]["vi"][0]["ul"]["ui"][3]["url"];
    echo $url_prefix_0 . "<br>---------------<br>";
    echo $url_prefix_1 . "<br>---------------<br>";
    echo $url_prefix_2 . "<br>-------------- <br>";
    echo $url_prefix_3 . "<br>---------------<br>";
    
    // 查找vkey https://h5vv.video.qq.com/getkey
    $params2 = array(
      'charge'=> 0,
      'vid'=>$vid, // url或html获取
      'format'=>2,
      'otype'=> 'json',
      'guid'=>$guid, // 发觉有问题用不了就要换,抓包看
      'platform'=> 10901,
      'defnpayver'=> 0,
      'appVer'=> '3.0.83',
      'vt'=>0,
      'sdtfrom'=>'v1010',
      // '_rnd'=>rmt['t'], // 时间戳重要,没有直接20k速度
          // '_qv_rmt'=> rmt['u1'], // 限速算法,重要,没有直接20k速度
          // '_qv_rmt2'=> rmt['u2'], // 同上
      'ui_host'=> 2,
      'filename'=> $filename,
      // 'callback'=>jsonpCallback,
      '_'=>round(time() * 1000), // 13位时间戳,我测没有会卡顿
    );
    $params2 = http_build_query($params2);  // 把参数转换成URL数据  
    // $sUrl = 'https://h5vv.video.qq.com/getinfo'; //此处必须为完整路径  
    $sUrl2 = "https://h5vv.video.qq.com/getkey?" . $params2; 
    $opts2 = array(
      'http'=>array(
        'method'=>"GET",
        'timeout'=>100,
      )
    );
    $context2 = stream_context_create($opts2);
    $d2 = @file_get_contents($sUrl2,false,$context2);  
    // echo $d; 
    
    $json_data2 = preg_replace("/\t|QZOutputJson=/","",$d2);
    $json_data2 = preg_replace("/\t|;/","",$json_data2);
    echo "<br><br>json_data2:-----<br><br>" . $json_data2 . "<br><br>";
    $json_data_arry2 = json_decode($json_data2, true);
    //var_dump($json_data2);
    // echo $json_data_arry; 
    // var_dump($json_data_arry);
    // echo $json_data_arry["vl"]; 
    // var_dump($json_data_arry["vl"]["vi"][0]["fn"]);
    
    // 视频文件key
    $key = $json_data_arry2["key"];
    echo "<br><br>key:-----<br><br>" . $key . "<br><br>";
    echo "<br><br>------URL:" . $url_prefix . $filename . $key;
    

    // "br":60,
    // "ch":0,
    // "cl":{
    // "fc":0,
    // "keyid":"e0502ni34x7.2"
    // e0502ni34x7.mp4",
    // .p712.1.mp4

    // // http://ugcyd.qq.com/e0502ni34x7.p712.1.mp4?sdtfrom=v1010&guid=c6ffbfd785a0a2f9208eab836d0d841b&vkey=F896F9B1DEABC9C8F2DA50651727266C6F0A898B419CAF5758FBD92F3075C1EBAE5146C936D8ED060929B100CE56B94A29604104E57521270ACE881CF573187C48895090527027C1889BD319E8999F71400FC8EDCF83DD510F28040942859FC4F8DBFD1D4BA96EBEA0A3CAD7D7B915E4F3EBABB5AE3A3B3B

    echo "<br><br>-------------0::--------<br><a href =" . $url_prefix_0 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key .">" . $url_prefix_0 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key . "</a><br>";
    echo "<br><br>-------------1::--------<br><a href =" . $url_prefix_1 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key .">" . $url_prefix_1 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key . "</a><br>";
    echo "<br><br>-------------2::--------<br><a href =" . $url_prefix_2 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key .">" . $url_prefix_2 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key . "</a><br>";
    echo "<br><br>-------------3::--------<br><a href =" . $url_prefix_3 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key .">" . $url_prefix_3 . $filename . "?sdtfrom=v1010&guid=" . $guid . "&vkey=" . $key . "</a><br>";
    // 视频url前缀
    // $url_prefix = $json_data_arry["vl"]["vi"][0]["ul"]["ui"][0]["url"];
    // echo $url_prefix;
    
    // https://h5vv.video.qq.com/getkey
    

    }else{
    die("Error!");
    }
    }else{
    die("Error!");
    }
    ?>

    </code></pre>

    相关文章

      网友评论

          本文标题:获取腾讯视频

          本文链接:https://www.haomeiwen.com/subject/deiwkftx.html