最新华数TV解析源码

Z站站长今天给大家分享一个来自柴郡猫的资源,也是来自别的网站,希望大家喜欢,下载地址就在文中。

华数TV解析源码

  1. <?php
  2. echo str_replace(“//”,“/”,json_encode(Wasu::parse($url)));
  3. /**
  4. *
  5. */
  6. class Wasu
  7. {
  8. public static function parse($url)
  9. {
  10. /*if(GlobalBase::is_ipad()){
  11. if(strstr($url,”www.wasu.cn/Play/”)==true){
  12. $url = str_replace(“Play”,”wap/Play”,$url);
  13. }
  14. $content = self::curl($url);
  15. preg_match(“#’vid’/s*:/s*'(/d+)’,#”,$content,$playId);
  16. preg_match(“#’key’/s*:/s*'(.*)’,#”,$content,$playKey);
  17. preg_match(“#’url’/s*:/s*'(.*)’,#”,$content,$playUrl);
  18. $ids[‘vid’] = $playId[1];
  19. $ids[‘key’] = $playKey[1];
  20. $ids[‘vurl’] = $playUrl[1];
  21. $ids[‘url’] = $url;
  22. $data = self::get_wap_videos($ids);
  23. }else{ */
  24. if(strstr($url,“www.wasu.cn/wap/”)==true){
  25. $url = str_replace(“/wap”,“”,$url);
  26. }
  27. $content = self::curl($url);
  28. preg_match(“#var/s*_playId/s*=/s*'(/d+)’,#”,$content,$playId);
  29. preg_match(“#_playKey/s*=/s*'(.*)’,#”,$content,$playKey);
  30. preg_match(“#_playUrl/s*=/s*'(.*)’,#”,$content,$playUrl);
  31. preg_match(“#_playUrlHls/s*=/s*'(.*)’,#”,$content,$playUrlHls);
  32. preg_match(“#_playpic/s*=/s*'(.*)’,#”,$content,$posters);
  33. preg_match(“#_sid_=(.*),_cid#”,$content,$playId2);
  34. $ids[‘vid’] = isset($playId[1]) ? $playId[1] : $playId2[1];
  35. $ids[‘poster’] = isset($posters[1]) ? $posters[1] : ;
  36. $ids[‘key’] = $playKey[1];
  37. $ids[‘url’] = $url;
  38. $ids[‘vurl’] = $playUrl[1];
  39. $ids[‘hurl’] = $playUrlHls[1];
  40. //print_r($ids);exit;
  41. $data = self::get_videos($ids);
  42. /*} */
  43. return $data;
  44. }
  45. public static function get_videos($ids)
  46. {
  47. $api = “https://www.wasu.cn/Api/getPlayInfoById/id/{$ids[‘vid’]}/datatype/xml”;
  48. $ids[‘ref’] = ‘https://www.wasu.cn/Play/show/id/’.$ids[‘vid’];
  49. $ids[‘ua’] = ‘Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/67.0.3396.99 Safari/537.36’;
  50. $data = self::curl($api,$ids);
  51. $txt = $data;
  52. $pa = ‘%<title><!/[CDATA/[(.*)/]/]></title>%si’;//正则表达式
  53. preg_match_all($pa,$txt,$matches);
  54. $xml = simplexml_load_string($data);
  55. $json = json_decode(json_encode($xml),true);
  56. $mp4 = $json[“mp4”];
  57. foreach ($mp4 as $_key => $value) {
  58. switch ($_key) {
  59. case ‘hd0’:$def = “标清”;break;
  60. case ‘hd1’:$def = “高清”;break;
  61. case ‘hd2’:$def = “超清”;break;
  62. case ‘hd3’:$def = “720P”;break;
  63. case ‘hd4’:$def = “1080P”;break;
  64. }
  65. $value = base64_encode(base64_decode($value));
  66. //$value = base64_encode(str_replace(‘.mp4′,’/playlist.m3u8’,base64_decode($value)));
  67. $vurl = self::streamCode(self::get_code($ids[‘vid’],$ids[‘key’],$value));
  68. if (GlobalBase::is_ipad()) {
  69. if ($_key == ‘hd2’ && $vurl != ) {
  70. $fdata[2][‘url’] = $vurl;
  71. $fdata[2][‘def’] = ‘高清’;
  72. }
  73. if ($_key == ‘hd1’ && $vurl != ) {
  74. $fdata[3][‘url’] = $vurl;
  75. $fdata[3][‘def’] = ‘流畅’;
  76. }
  77. if ($_key == ‘hd0’ && $vurl != ) {
  78. $fdata[4][‘url’] = $vurl;
  79. $fdata[4][‘def’] = ‘流畅’;
  80. }
  81. } else {
  82. if ($_key == ‘hd4’ && $vurl != ) {
  83. $fdata[0][‘url’] = $vurl;
  84. $fdata[0][‘def’] = ‘蓝光’;
  85. }
  86. if ($_key == ‘hd3’ && $vurl != ) {
  87. $fdata[1][‘url’] = $vurl;
  88. $fdata[1][‘def’] = ‘720P’;
  89. }
  90. if ($_key == ‘hd2’ && $vurl != ) {
  91. $fdata[2][‘url’] = $vurl;
  92. $fdata[2][‘def’] = ‘高清’;
  93. }
  94. if ($_key == ‘hd1’ && $vurl != ) {
  95. $fdata[3][‘url’] = $vurl;
  96. $fdata[3][‘def’] = ‘流畅’;
  97. }
  98. if ($_key == ‘hd0’ && $vurl != ) {
  99. $fdata[4][‘url’] = $vurl;
  100. $fdata[4][‘def’] = ‘流畅’;
  101. }
  102. }
  103. }
  104. for ($i=0; $i <= 5 ; $i++) {
  105. if ($fdata[$i] == ) {continue;}
  106. $key_arrays[]=$fdata[$i];
  107. }
  108. $videoinfo[‘code’] = 200;
  109. $videoinfo[‘poster’] = $json[‘snapshot’];
  110. $videoinfo[‘name’] = isset($matches[1][0]) ? $matches[1][0] : ;
  111. $videoinfo[‘play’] = ‘h5mp4’;
  112. $videoinfo[‘data’][‘url’] = $key_arrays[0][‘url’];
  113. return $videoinfo;
  114. }
  115. public static function get_wap_videos($ids)
  116. {
  117. $api = “http://clientapi.wasu.cn/Phone/vodinfo/id/{$ids[‘vid’]}”;
  118. $data = self::curl($api,$ids);
  119. $json = json_decode($data,true);
  120. $vods = $json[“vods”];
  121. $host = parse_url(base64_decode($ids[‘vurl’]))[“host”];
  122. foreach ($vods as $key => $value) {
  123. $def = $value[“hd”];
  124. $vurl = $value[“url”];
  125. $vurl = str_replace(parse_url($vurl)[“host”],$host,$vurl);
  126. $vurl = str_replace(‘.mp4′,’/playlist.m3u8’,$vurl);
  127. $vurl = self::streamCode(self::get_code($ids[‘vid’],$ids[‘key’],base64_encode($vurl)));
  128. $video[0] = $vurl;
  129. $video[1] = “video/m3u8”;
  130. $video[2] = $def;
  131. $video[3] = $def ==“1080P”? 10 : $def ==“高清”?10:0;
  132. $videoinfo[“video”][$key] = $video;
  133. }
  134. return $videoinfo;
  135. }
  136. public static function get_code($vid,$key,$url)
  137. {
  138. $api = “https://apiontime.wasu.cn/Auth/getVideoUrl?id={$vid}&mode=1&key={$key}&url={$url}”;
  139. $data = self::curl($api);
  140. preg_match(“#/[CDATA/[(.*)/]/]#”,$data,$video);
  141. return $video[1];
  142. }
  143. public static function curl($url,$ids=)
  144. {
  145. $params[“ua”] = isset($ids[‘ua’]) ? $ids[‘ua’] : “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36”;
  146. return GlobalBase::curl($url,$params);
  147. }
  148. //=======================================================================================================================================
  149. public static function streamCode($string, $operation = ‘DECODE’, $key = ‘wasu!@#48217#$@#1’, $expiry = 0){
  150. $ckey_length = 4;
  151. $key = md5($key ? $key : ‘12345678’);
  152. $keya = md5(substr($key, 0, 16));
  153. $keyb = md5(substr($key, 16, 32));
  154. $keyc = $ckey_length ? $operation == ‘DECODE’ ? substr($string, 0, $ckey_length) : substr(md5(microtime()), –$ckey_length) : ;
  155. $cryptkey = $keya . md5($keya . $keyc);
  156. $key_length = strlen($cryptkey);
  157. $string = $operation == ‘DECODE’ ? base64_decode(substr($string, $ckey_length)) : sprintf(‘%010d’, $expiry ? $expiry + time() : 0) . substr(md5($string . $keyb), 0, 16) . $string;
  158. $string_length = strlen($string);
  159. $result = ;
  160. $box = range(0, 255);
  161. $rndkey = array();
  162. for($i = 0; $i <= 255; $i++){
  163. $rndkey[$i] = ord($cryptkey[$i % $key_length]);
  164. }
  165. for($j = $i = 0; $i < 128; $i++){
  166. $j = ($j + $box[$i] + $rndkey[$i]) % 128;
  167. $tmp = $box[$i];
  168. $box[$i] = $box[$j];
  169. $box[$j] = $tmp;
  170. }
  171. for($a = $j = $i = 0; $i < $string_length; $i++){
  172. $a = ($a + 1) % 128;
  173. $j = ($j + $box[$a]) % 128;
  174. $tmp = $box[$a];
  175. $box[$a] = $box[$j];
  176. $box[$j] = $tmp;
  177. $result .= chr(ord($string[$i]) ^ $box[($box[$a] + $box[$j]) % 128]);
  178. }
  179. if($operation == ‘DECODE’){
  180. if((substr($result, 0, 10) == 0 || substr($result, 0, 10) – time() > 0) && substr($result, 10, 16) == substr(md5(substr($result, 26) . $keyb), 0, 16)){
  181. return substr($result, 26);
  182. }else{
  183. return ;
  184. }
  185. }else{
  186. return $keyc . base64_encode($result);
  187. }
  188. }
  189. public static function _streamCode($enstr, $token = “wasu!@#48217#$@#1”) {
  190. $klen = 4;
  191. if (strstr($enstr,“.mp4”)) {
  192. return $enstr;
  193. }
  194. $token = md5($token);
  195. $tm = $_SERVER[‘REQUEST_TIME’];
  196. $key1 = md5(substr($token, 0, 16));
  197. $key2 = md5(substr($token, 16, 32));
  198. $key3 = substr($enstr, 0, $klen);
  199. $key4 = $key1.md5($key1.$key3);
  200. $keylen = strlen($key4);
  201. $enstr = base64_decode(substr($enstr, $klen));
  202. $l16 = 0;
  203. $l14 = array();
  204. $l15 = array();
  205. $local13 = strlen($enstr);
  206. while ($l16 < 128){
  207. $l14[$l16] = $l16;
  208. $l15[$l16] = ord(substr($key4, $l16 % $keylen, 1)) & 0xff;
  209. $l16++;
  210. }
  211. $l16 = 0;
  212. $l17 = $l16;
  213. while ($l16 < 128) {
  214. $l17 = (($l17 + $l14[$l16]) + $l15[$l16]) % 128;
  215. $l19 = $l14[$l16];
  216. $l14[$l16] = $l14[$l17];
  217. $l14[$l17] = $l19;
  218. $l16++;
  219. }
  220. $l16 = 0;
  221. $l20 = array();
  222. $l17 = $l16;
  223. $l18 = $l17;
  224. while ($l16 < $local13) {
  225. $l18 = (($l18 + 1) % 128);
  226. $l17 = (($l17 + $l14[$l18]) % 128);
  227. $l19 = $l14[$l18];
  228. $l14[$l18] = $l14[$l17];
  229. $l14[$l17] = $l19;
  230. $l20[] = ((ord(substr($enstr, $l16, 1)) & 0xFF) ^ $l14[(($l14[$l18] + $l14[$l17]) % 128)]);
  231. $l16++;
  232. }
  233. $toStr = “”;
  234. for($i = 0; $i < count($l20); $i++){
  235. $toStr .= chr($l20[$i]);
  236. }
  237. return strlen($toStr) > 26 ? substr($toStr, 26) : “”;
  238. }
  239. public static function get_WasuVODUrl($url) {
  240. $play = parse_url($url);
  241. $tm = $_SERVER[‘REQUEST_TIME’];
  242. $timestamp = date(“YmdHi”, $tm);
  243. $token = sprintf(“%s%s%s”, “ccVOD@)!#/$WASUPC”, $timestamp, $play[‘path’]);
  244. return sprintf(“http://clientvod.wasu.cn/%s/%s%s”, $timestamp, md5($token), $play[‘path’]);
  245. }
  246. }
  247. /*
  248. function streamCode($enstr, $token = “wasu!@#48217#$@#1”) {
  249. $klen = 4;
  250. if (strstr($enstr,”.mp4″)) {
  251. return $enstr;
  252. }
  253. $token = md5($token);
  254. $tm = $_SERVER[‘REQUEST_TIME’];
  255. $key1 = md5(substr($token, 0, 16));
  256. $key2 = md5(substr($token, 16, 32));
  257. $key3 = substr($enstr, 0, $klen);
  258. $key4 = $key1.md5($key1.$key3);
  259. $keylen = strlen($key4);
  260. $enstr = base64_decode(substr($enstr, $klen));
  261. $l16 = 0;
  262. $l14 = array();
  263. $l15 = array();
  264. $local13 = strlen($enstr);
  265. while ($l16 < 128){
  266. $l14[$l16] = $l16;
  267. $l15[$l16] = ord(substr($key4, $l16 % $keylen, 1)) & 0xff;
  268. $l16++;
  269. }
  270. $l16 = 0;
  271. $l17 = $l16;
  272. while ($l16 < 128) {
  273. $l17 = (($l17 + $l14[$l16]) + $l15[$l16]) % 128;
  274. $l19 = $l14[$l16];
  275. $l14[$l16] = $l14[$l17];
  276. $l14[$l17] = $l19;
  277. $l16++;
  278. }
  279. $l16 = 0;
  280. $l20 = array();
  281. $l17 = $l16;
  282. $l18 = $l17;
  283. while ($l16 < $local13) {
  284. $l18 = (($l18 + 1) % 128);
  285. $l17 = (($l17 + $l14[$l18]) % 128);
  286. $l19 = $l14[$l18];
  287. $l14[$l18] = $l14[$l17];
  288. $l14[$l17] = $l19;
  289. $l20[] = ((ord(substr($enstr, $l16, 1)) & 0xFF) ^ $l14[(($l14[$l18] + $l14[$l17]) % 128)]);
  290. $l16++;
  291. }
  292. $toStr = “”;
  293. for($i = 0; $i < count($l20); $i++){
  294. $toStr .= chr($l20[$i]);
  295. }
  296. return strlen($toStr) > 26 ? substr($toStr, 26) : “”;
  297. }
  298. function get_WasuVODUrl($url) {
  299. $play = parse_url($url);
  300. $tm = $_SERVER[‘REQUEST_TIME’];
  301. $timestamp = date(“YmdHi”, $tm);
  302. $token = sprintf(“%s%s%s”, “ccVOD@)!#/$WASUPC”, $timestamp, $play[‘path’]);
  303. return sprintf(“http://clientvod.wasu.cn/%s/%s%s”, $timestamp, md5($token), $play[‘path’]);
  304. }
  305. $url = “”;
  306. $link = isset($_REQUEST[‘url’]) ? $_REQUEST[‘url’] : “”;
  307. $enstr = empty($_REQUEST[‘enstr’]) ? “” : $_REQUEST[‘enstr’];
  308. if (strlen($enstr) > 32) {
  309. $url = streamCode($enstr);
  310. } else if (strlen($link) > 15) {
  311. $url = @get_WasuVODUrl(base64_decode($link));
  312. }
  313. echo ‘{“url”:”‘.$url.'”}’;
  314. */

大家觉得Z站站长分享得这个资源怎么样?赶紧评论一下吧!

【小程序源码网资源版权风险说明】:
本站为避免不必要的纷争,分享的所有资源中一切可能有版权风险的资源将全部转载自第三方网站或平台,站长只为大家提供相关资源的介绍和跳转引导。 因可能有疏忽大意,所以如有遗漏资源侵犯了您的合法权利,请联系站长删除。
【小程序源码网资源下载使用说明】:
本站所分享的一切QQ小程序源码,thinkphp整站源码,微信小程序源码,图文教程等资源仅供用户学习参考使用,任何人不得作其他用途,违者自行承担所有责任。
【小程序源码网毫无人看的介绍】:
本站又称Z站,原名贼娘网,开站于2018年,换过三任站长,目前站长是第四任站长,本站是一个主要分享免费开源小程序源码/网站源码/免费素材/教程资源的网站,主要小程序资源有用于学习的小程序源码,也有正版原创可商用的小程序源码,是一个公益博客型网站。
【小程序源码网原创源码版权申明】:
未经小程序源码网许可,任何人不得擅自使用本站原创首发源码进行商业行为(除本站VIP用户在期限内,版权无使用限制),否则将依法承担相应赔偿责任。
【小程序源码网转载文章版权申明】:
本站所转载的QQ小程序或微信小程序源码与其他资源仅供学习,任何人不得作其他用途,违者自行承担所有责任。
【小程序源码网站长最后的屁话】:
如有您认为本站有任何侵犯您合法权益的文章,或者您有什么疑问需求,欢迎联系站长QQ,站长24小时在线,备注公司名称和源码版权问题或者需要小程序定制开发等站长业务类型可急速处理,如果您只是交流小程序的一些开发问题或源码问题可以加入QQ群讨论,就不用加站长啦,对于白嫖党,QQ群才是处理问题的天堂,当然站长也欢迎大家骚扰~
小程序源码网 » 最新华数TV解析源码

发表评论

嘿,投喂下嘛!