歪歪神曲解析源码

1.  <?php  
2.  //$url = “http://www.yy.com/x/15012\_1222559164\_38974734\_1527084874496";  
3.  //$url = “http://www.yy.com/sv/9221285915528344768";  
4.  //$url = “http://www.yy.com/shenqu/play/id\_1134094401301923854.html";  
5.  // $api = http://api-tinyvideo-web.yy.com/tinyVideo/getDetailsForVideo?appId=svwebpc&sign=&data=%7B%22resid%22%3A%229180350519213102625%22%2C%22uid%22%3A1%7D&\_=1527172814634  
6.  echo json\_encode(YY::parse($url));  
7.  /\*\* 
8.  \*  
9.  \*/  
10.  class YY  
11.  {  
12.      public static function parse($url)  
13.      {  
14.          $content = self::curl($url);  

16.          if(strstr($url,“/shenqu/play/")==true){  
17.              preg\_match('#snapshot“:"(.\*)“,"conv#’,$content,$img);  
18.              preg\_match('#worksUrl“:"(.\*)“,"likeCou#’,$content,$vurl);  
19.              preg\_match('#worksName“:"(.\*).“,"singerPho#’,$content,$name);  
20.             // print\_r('1:’.$name);exit;  
21.              $pic = “http:".$img\[1\];  
22.              $type = 'h5mp4’;  
23.          }else if(strstr($url,“/sv/")==true){  
24.              preg\_match('#window.resid = \\'(.\*)\\’;#’,$content,$id);  
25.              preg\_match('#window.owneruid = \\'(.\*)\\’;#’,$content,$uid);  

27.              $url = “http://api-tinyvideo-web.yy.com/tinyVideo/getDetailsForVideo?appId=svwebpc&sign=&data=%7B%22resid%22%3A%22".$id\['1’\].“%22%2C%22uid%22%3A1%7D&\_=".GlobalBase::getMillisecond();  
28.              $data = self::curl($url,’http://www.yy.com/sv/’.$id\['1’\]);  
29.              $data = json\_decode($data,true);  
30.              $data = $data\['data’\]\['data’\];  
31.              $vurl\['1’\] = $data\['resurl’\];  
32.              $pic = $data\['snapshoturl’\];  
33.              $type = 'h5mp4’;  
34.              //print\_r($data);exit;  

36.          }else if(strstr($url,“/x/")==true){  
37.              preg\_match('#video:\\s{0,}“(.\*)",#’,$content,$vurl);  
38.              preg\_match('#title:\\s{0,}“(.\*)",#’,$content,$name);  
39.              preg\_match('#pic:\\s{0,}“(.\*)",#’,$content,$img);  
40.              //print\_r('3:’.$name);exit;  
41.              $pic = $img\[1\];  
42.              $type = 'hls’;  
43.          }  

45.          $mp4 =  str\_replace('\\u002F’,’/’,$vurl\[1\]);  
46.          $videoinfo\['code’\] = 200;  
47.          $videoinfo\[“poster"\]= $pic;  
48.          $videoinfo\['play’\] = $type;  
49.          $videoinfo\[“data"\]\[“url"\] = $mp4;  
50.          return $videoinfo;  
51.      }  
52.      public static function curl($url,$ref\=")  
53.      {  
54.          $params\[“ua"\] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";  
55.          if ($ref) {  
56.              $params\['ref’\] = $ref;  
57.          }  
58.          return GlobalBase::curl($url,$params);  
59.      }  
60.  }  

62.  ?>