龙珠解析源码
1. <?php
3. echo json\_encode(LongZhu::parse($url));
5. /\*\*
6. \*
7. \*/
8. class LongZhu
9. {
11. public static function parse($url)
12. {
13. $vid = explode(“?", basename($url))\[0\];
14. $data = self::get\_video\_url($vid);
15. if(!emptyempty($data)){
16. return $data;
17. }else{
18. $content = self::curl($url);
19. preg\_match('#“RoomId":(.\*?),#’,$content,$\_rid);
20. if(!emptyempty($\_rid\[1\])){
21. $rid = $\_rid\[1\];
22. }else{
23. preg\_match(“#ROOMID\\s\*=\\s\*'(.\*?)’;#",$content,$\_\_rid);
24. $rid = $\_\_rid\[1\];
25. }
26. return self::get\_live\_url($rid);
27. }
28. }
29. public static function get\_video\_url($mid)
30. {
31. $api = “http://api.v.plu.cn/CloudMedia/GetInfoForPlayer?mediaId={$mid}";
32. $content = self::curl($api);
33. $data = json\_decode($content,true);
34. if(!emptyempty($data\[“urls"\])){
35. $urls = $data\[“urls"\];
36. foreach ($urls as $key => $value) {
37. $level = $value\[“RateLevel"\];
38. $ext = $value\[“Ext"\];
39. $vurl = $value\[“SecurityUrl"\];
40. switch ($level) {
41. case 1:$def\=“标清";break;
42. case 2:$def\=“高清";break;
43. case 3:$def\=“超清";break;
44. case 4:$def\=“原画";break;
45. default:$def\=“自动";break;
46. }
47. switch ($ext) {
48. case 'flv’:$type = “flv";break;
49. case 'mp4’:$type = “mp4";break;
50. case 'm3u8’:$type = “m3u8";break;
51. }
52. if (GlobalBase::is\_ipad()) {
53. if($ext\==’m3u8′){
54. $videoinfo\['code’\] = 200;
55. $videoinfo\[“data"\]\[“video"\]\[“file"\] = $vurl;
56. $videoinfo\[“data"\]\[“video"\]\[“type"\] = “video/m3u8";
57. break;
58. }
59. }else{
60. $video\[0\] = $vurl;
61. $video\[1\] = $type;
62. $video\[2\] = $type.$def;
63. $video\[3\] = $level != 2 ? 0 : 10;
64. $videoinfo\[“code"\] = 200;
65. $videoinfo\[“data"\]\[“video"\]\[$key\] = $video;
66. $videoinfo\[“data"\]\[“flashplayer"\] = true;
67. }
68. }
69. return $videoinfo;
70. }else{
71. return “";
72. }
73. }
74. public static function get\_live\_url($rid)
75. {
76. $api = “http://liveapi.plu.cn/liveapp/roomstatus?roomId={$rid}";
77. $content = self::curl($api);
78. $data = json\_decode($content,true);
79. $img = $data\[“cover"\];
80. $vurl = $data\[“streamUri"\];
81. $videoinfo\[“poster"\] = $img;
82. if (!GlobalBase::is\_ipad()) {
83. $videoinfo\[“data"\]\[“live"\] = true;
84. $videoinfo\[“data"\]\[“flashplayer"\] = true;
85. }
86. $videoinfo\['code’\] = 200;
87. $videoinfo\[“data"\]\[“video"\]\[“file"\] = $vurl;
88. $videoinfo\[“data"\]\[“video"\]\[“type"\] = “video/m3u8";
89. return $videoinfo;
90. }
91. public static function curl($url)
92. {
93. $params\[“ua"\] = “Mozilla/5.0 (Windows NT 10.0; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.84 Safari/537.36";
94. return GlobalBase::curl($url,$params);
95. }
96. }
97. ?>