| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788 |
- <?php
- /**
- * 重庆赤晓店信息科技有限公司
- * https://www.chixiaodian.com
- * Copyright (c) 2023 赤店商城 All rights reserved.
- */
- namespace app\utils;
- class GetInfo
- {
- //通过vid参数换取源地址
- public static function getVideoInfo($url){
- preg_match("/\/([0-9a-zA-Z]+).html/", $url, $vids);
- if(empty($vids) || !is_array($vids)){
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'url' => $url
- ];
- }
- $getUrl = 'https://h5vv.video.qq.com/getinfo?';
- $realUrl = 'http://ugcws.video.gtimg.com/%s?vkey=%s&br=56&platform=2&fmt=auto&level=0&sdtfrom=v5010&guid=a3527bbc8888951591bc3a67c2bc9c50';
- $newVideo = array();
- foreach($vids as $key => $value){
- if(!empty($value) && $key == 1){
- $vid = $value;
- //获取真正的视频源地址
- $data = array(
- 'platform' => 11001,
- 'charge' => 0,
- 'otype' => 'json',
- 'ehost' => 'https://v.qq.com',
- 'sphls' => 1,
- 'sb' => 1,
- 'nocache' => 0,
- '_rnd' => time(),
- 'guid' => 'a3527bbc8888951591bc3a67c2bc9c50',
- 'appVer' => 'V2.0Build9496',
- 'vids' => $vid,
- 'defaultfmt' => 'auto',
- '_qv_rmt' => 'jJPtBTyoA12993HPU=',
- '_qv_rmt2' => 'pS3QdOqZ150285Jdg=',
- 'sdtfrom' => 'v5010'
- );
- $result = self::http_get($getUrl.http_build_query($data));
- if(!empty($result)){
- $result = explode('=', $result);
- if(!empty($result) && !empty($result[1])){
- $json = substr($result[1], 0, strlen($result[1])-1);
- $json = json_decode($json, true);
- if(json_last_error() == 'JSON_ERROR_NONE'){
- if(!empty($json['vl']['vi'][0]['fn']) && !empty($json['vl']['vi'][0]['fvkey'])){
- $fn = $json['vl']['vi'][0]['fn'];
- $fvkey = $json['vl']['vi'][0]['fvkey'];
- $returnUrl = sprintf($realUrl, $fn, $fvkey);
- $newVideo['url'] = $returnUrl;
- }
- }
- }
- }
- }
- }
- return [
- 'code' => 0,
- 'msg' => 'success',
- 'url' => $newVideo['url']
- ];
- }
- public static function http_get($url) {
- $oCurl = curl_init ();
- if (stripos ( $url, "https://" ) !== FALSE) {
- curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYPEER, FALSE );
- curl_setopt ( $oCurl, CURLOPT_SSL_VERIFYHOST, FALSE );
- }
- curl_setopt ( $oCurl, CURLOPT_URL, $url );
- curl_setopt ( $oCurl, CURLOPT_RETURNTRANSFER, 1 );
- $sContent = curl_exec ( $oCurl );
- $aStatus = curl_getinfo ( $oCurl );
- curl_close ( $oCurl );
- if (intval ( $aStatus ["http_code"] ) == 200) {
- return $sContent;
- } else {
- return false;
- }
- }
- }
|