PageRenderTime 40ms CodeModel.GetById 17ms RepoModel.GetById 0ms app.codeStats 0ms

/htdocs/umsp/plugins/qiyi/qiyi.php

http://umspx.googlecode.com/
PHP | 273 lines | 222 code | 14 blank | 37 comment | 40 complexity | c3b9f8dc94ae0a152e6a20fb15d32a64 MD5 | raw file
Possible License(s): GPL-3.0
  1. <?php
  2. // qiyi UMSP plugin by Daniel
  3. // ????
  4. include('info.php');
  5. include_once($_SERVER[DOCUMENT_ROOT] . '/umsp/funcs-config.php');
  6. include_once($_SERVER[DOCUMENT_ROOT] . '/umsp/funcs-log.php');
  7. //??????????
  8. //????????
  9. define("ITEMPERPAGE",30);
  10. function _pluginMain($prmQuery) {
  11. //l('[DEBUG]',$prmQuery);
  12. $queryData = array();
  13. parse_str($prmQuery, $queryData);
  14. if ($queryData['mode'] == 'root'){
  15. //???
  16. $items = _pluginCreateRootList($queryData['sort']);
  17. return $items;
  18. }else if($queryData['mode'] == 'channel'){
  19. //??????
  20. $items = _pluginCreateChannelPage($queryData['channel'],$queryData['sort']);
  21. return $items;
  22. }else if($queryData['mode'] == 'channelpage'){
  23. //????????
  24. $items = _pluginCreateMovieList($queryData['channel'],$queryData['page'],$queryData['sort']);
  25. return $items;
  26. }else if($queryData['mode'] == 'play'){
  27. //??????
  28. $items = _pluginCreatePlayList($queryData['movlink'],$queryData['name']);
  29. return $items;
  30. }else if($queryData['mode'] == 'playtv'){
  31. //????TV??
  32. $items = _pluginCreateTVPlayList($queryData['movlink'],$queryData['name']);
  33. return $items;
  34. }else{
  35. //???,??????
  36. $items = _pluginCreateSortList();
  37. return $items;
  38. }
  39. }
  40. //??????
  41. function _pluginCreateSortList(){
  42. $sortarray = array(
  43. '?????' => 2,
  44. '?????' => 5,
  45. '?????' => 3,
  46. '?????' => 4
  47. );
  48. foreach ($sortarray as $name => $id) {
  49. $isort = $id;
  50. $data = array(
  51. 'mode' => 'root',
  52. 'sort' => $isort
  53. );
  54. $dataString = http_build_query($data, '','&amp;');
  55. $retMediaItems[] = array (
  56. 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
  57. 'dc:title' => $name,
  58. 'upnp:class' => 'object.container',
  59. );
  60. }
  61. return $retMediaItems;
  62. }
  63. //???????
  64. function _pluginCreateRootList($isort){
  65. $categories = array(
  66. '??' => '_E7_94_B5_E5_BD_B1',
  67. '????' => '_E7_94_B5_E5_BD_B1_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E5_BD_B1',
  68. '???' => '_E7_94_B5_E8_A7_86_E5_89_A7',
  69. '?????' => '_E7_94_B5_E8_A7_86_E5_89_A7_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E8_A7_86_E5_89_A7',
  70. '??' => '_E5_8A_A8_E6_BC_AB',
  71. '???' => '_E7_BA_AA_E5_BD_95_E7_89_87',
  72. '??' => '_E7_BB_BC_E8_89_BA',
  73. '??' => '_E9_9F_B3_E4_B9_90'
  74. );
  75. foreach ($categories as $name => $id) {
  76. $channel = $id;
  77. $data = array(
  78. 'mode' => 'channel',
  79. 'sort' => $isort,
  80. 'channel' => $channel
  81. );
  82. $dataString = http_build_query($data, '','&amp;');
  83. $retMediaItems[] = array (
  84. 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
  85. 'dc:title' => $name,
  86. 'upnp:class' => 'object.container',
  87. );
  88. }
  89. return $retMediaItems;
  90. }
  91. //??????
  92. function _pluginCreateChannelPage($channel,$isort)
  93. {
  94. if( $channel == '_E7_94_B5_E5_BD_B1' ||
  95. $channel == '_E7_94_B5_E8_A7_86_E5_89_A7' ||
  96. $channel == '_E7_94_B5_E8_A7_86_E5_89_A7_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E8_A7_86_E5_89_A7' ||
  97. $channel == '_E7_94_B5_E5_BD_B1_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E5_BD_B1' ){
  98. $html = file_get_contents('http://search.video.qiyi.com/category/' . $channel . '/1/'.$isort.'/1/' .ITEMPERPAGE.'//www/');
  99. } else {
  100. $html = file_get_contents('http://search.video.qiyi.com/searchCategory/' . $channel . '/1/'.$isort.'/1/' .ITEMPERPAGE.'/www/');
  101. }
  102. preg_match_all('/"sumPages":(.*?),"weight"/',$html,$sumPages);
  103. //????
  104. $PagesNum = (int)$sumPages[1][0];
  105. for($z=0; $z<$PagesNum;$z++){
  106. $page = $z+1;
  107. $data = array(
  108. 'mode' => 'channelpage',
  109. 'sort' => $isort,
  110. 'channel' => $channel,
  111. 'page' => $page,
  112. );
  113. $dataString = http_build_query($data, '','&amp;');
  114. $retMediaItems[] = array (
  115. 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
  116. 'dc:title' => '?'.$page.'?',
  117. 'upnp:class' => 'object.container',
  118. );
  119. }
  120. return $retMediaItems;
  121. }
  122. //??????????
  123. function _pluginCreateMovieList($channel,$page,$isort)
  124. {
  125. if( $channel == '_E7_94_B5_E5_BD_B1' ||
  126. $channel == '_E7_94_B5_E8_A7_86_E5_89_A7' ||
  127. $channel == '_E7_94_B5_E8_A7_86_E5_89_A7_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E8_A7_86_E5_89_A7' ||
  128. $channel == '_E7_94_B5_E5_BD_B1_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E5_BD_B1'){
  129. $html = file_get_contents('http://search.video.qiyi.com/category/' . $channel . '/1/'.$isort.'/' . $page . '/' .ITEMPERPAGE.'//www/');
  130. } else {
  131. $html = file_get_contents('http://search.video.qiyi.com/searchCategory/' . $channel . '/1/'.$isort.'/' . $page . '/' .ITEMPERPAGE.'/www/');
  132. }
  133. //"VrsVideoTv.tvName":"???????","VrsVideotv.tvTag":"
  134. preg_match_all('/"VrsVideoTv.tvName":"(.*?)","/',$html,$title);
  135. preg_match_all('/"vrsVideoTv.TvBigPic":"(.*?)","VrsVideoTv.tvDesc":/',$html,$bigpic);
  136. preg_match_all('/"TvApplication.purl":"(.*?)","category"/',$html,$movieurl);
  137. preg_match_all('/"tvsets":"(.*?)","firstUrl":/',$html,$tvsets);
  138. preg_match_all('/"firstUrl":"(.*?)","/',$html,$firstUrl);
  139. //l($html);
  140. //l($firstUrl[1]);
  141. for ($z = 0; $z < sizeof($title[1]); $z++) {
  142. if ($firstUrl[1][$z]!='')
  143. {
  144. $istv = 1;
  145. $movlink = urlencode($firstUrl[1][$z]);
  146. }else
  147. {
  148. $istv =0;
  149. $movlink = urlencode($movieurl[1][$z]);
  150. }
  151. if ((int)$tvsets[1][$z]>0)
  152. {
  153. $name = $title[1][$z] . ' (?' . $tvsets[1][$z] . '?)';
  154. }else
  155. {
  156. $name = $title[1][$z];
  157. }
  158. $playmode = 'play';
  159. if($istv == 0){
  160. $playmode = 'play';
  161. }else if($istv == 1){
  162. $playmode = 'playtv';
  163. }else{
  164. $playmode = 'playtv';
  165. }
  166. $data = array(
  167. 'mode' => $playmode,
  168. 'movlink' => $movlink,
  169. 'name' => $name
  170. );
  171. $dataString = http_build_query($data,'', '&amp;');
  172. $retMediaItems[] = array (
  173. 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
  174. 'dc:title' => $name,
  175. 'upnp:album_art'=> $bigpic[1][$z],
  176. 'upnp:class' => 'object.container'
  177. );
  178. }
  179. return $retMediaItems;
  180. }
  181. //??TV??
  182. function _pluginCreateTVPlayList($movlink,$name)
  183. {
  184. //l($movlink);
  185. $html = file_get_contents(urldecode($movlink));
  186. $html = str_replace("\r","",$html);
  187. $html = str_replace("\n","",$html);
  188. //l($html);
  189. //preg_match_all('/<a videoId="(.*?)"(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/',$html,$tvurls);
  190. /*
  191. <li vid='ce7d6a8f76b1484faa17c8ccaaae225d'>
  192. <a title="??????1?" href="http://www.qiyi.com/dianshiju/20110418/48af82e3012faac7.html"><img data-lazyload="http://www.qiyipic.com/thumb/20110418/v88373_116_65.jpg" width="116" height="65" alt="??????1?" /><span style="display:none">???..</span>
  193. <p></p>
  194. </a><a href="http://www.qiyi.com/dianshiju/20110418/48af82e3012faac7.html" title="??????1?">?1?</a>
  195. </li>
  196. */
  197. preg_match_all('/<li vid=\'(.*?)\'>(.*?)<a href="(.*?)"(.*?)>(.*?)<\/a>/',$html,$tvurls);
  198. //l($tvurls);
  199. //$tvurls[3] url,tvurls[5] name
  200. for ($z = 0;$z<sizeof($tvurls[3]);$z++){
  201. $tvname = '';
  202. if(strlen($tvurls[5][$z])>4)
  203. {
  204. $tvname = $tvurls[5][$z];
  205. }else{
  206. $tvname = $name . ' - ' .$tvurls[5][$z];
  207. }
  208. $data = array(
  209. 'mode' => 'play',
  210. 'movlink' => $tvurls[3][$z],
  211. 'name' => $tvname
  212. );
  213. $dataString = http_build_query($data,'', '&amp;');
  214. $retMediaItems[] = array (
  215. 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
  216. 'dc:title' => $tvname,
  217. 'upnp:class' => 'object.container'
  218. );
  219. }
  220. return $retMediaItems;
  221. }
  222. //??????
  223. function _pluginCreatePlayList($movlink,$name)
  224. {
  225. //l($movlink);
  226. $vurl = _getVideoUrl(urldecode($movlink));
  227. if ($vurl == '')
  228. {
  229. $retMediaItems[] = array (
  230. 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
  231. 'res' => $vurl,
  232. 'dc:title' => '???????????',
  233. 'upnp:class' => 'object.item.videoitem',
  234. 'protocolInfo' => 'http-get:*:video/mp4:*',
  235. );
  236. }else{
  237. $retMediaItems[] = array (
  238. 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
  239. 'res' => $vurl,
  240. 'dc:title' => '?? '.$name,
  241. 'upnp:class' => 'object.item.videoitem',
  242. 'protocolInfo' => 'http-get:*:video/mp4:*',
  243. );
  244. }
  245. return $retMediaItems;
  246. }
  247. //??????
  248. function _getVideoUrl($url)
  249. {
  250. $html = file_get_contents($url);
  251. //l($url);
  252. //tvId : "88373",//??id
  253. preg_match_all('/tvId : "(.*?)",\/\/??id/',$html,$tvid);
  254. $html = file_get_contents('http://cache.video.qiyi.com/h5/v/' .$tvid[1][0] . '/');
  255. preg_match_all('/"url":"(.*?)"/',$html,$vurl);
  256. $videourl = $vurl[1][0];
  257. return $videourl;
  258. }
  259. ?>