/htdocs/umsp/plugins/qiyi/qiyi.php
PHP | 273 lines | 222 code | 14 blank | 37 comment | 40 complexity | c3b9f8dc94ae0a152e6a20fb15d32a64 MD5 | raw file
Possible License(s): GPL-3.0
- <?php
- // qiyi UMSP plugin by Daniel
- // ????
- include('info.php');
- include_once($_SERVER[DOCUMENT_ROOT] . '/umsp/funcs-config.php');
- include_once($_SERVER[DOCUMENT_ROOT] . '/umsp/funcs-log.php');
- //??????????
- //????????
- define("ITEMPERPAGE",30);
- function _pluginMain($prmQuery) {
- //l('[DEBUG]',$prmQuery);
- $queryData = array();
- parse_str($prmQuery, $queryData);
- if ($queryData['mode'] == 'root'){
- //???
- $items = _pluginCreateRootList($queryData['sort']);
- return $items;
- }else if($queryData['mode'] == 'channel'){
- //??????
- $items = _pluginCreateChannelPage($queryData['channel'],$queryData['sort']);
- return $items;
- }else if($queryData['mode'] == 'channelpage'){
- //????????
- $items = _pluginCreateMovieList($queryData['channel'],$queryData['page'],$queryData['sort']);
- return $items;
- }else if($queryData['mode'] == 'play'){
- //??????
- $items = _pluginCreatePlayList($queryData['movlink'],$queryData['name']);
- return $items;
- }else if($queryData['mode'] == 'playtv'){
- //????TV??
- $items = _pluginCreateTVPlayList($queryData['movlink'],$queryData['name']);
- return $items;
- }else{
- //???,??????
- $items = _pluginCreateSortList();
- return $items;
- }
- }
- //??????
- function _pluginCreateSortList(){
- $sortarray = array(
- '?????' => 2,
- '?????' => 5,
- '?????' => 3,
- '?????' => 4
- );
- foreach ($sortarray as $name => $id) {
- $isort = $id;
- $data = array(
- 'mode' => 'root',
- 'sort' => $isort
- );
- $dataString = http_build_query($data, '','&');
- $retMediaItems[] = array (
- 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
- 'dc:title' => $name,
- 'upnp:class' => 'object.container',
- );
- }
- return $retMediaItems;
- }
- //???????
- function _pluginCreateRootList($isort){
- $categories = array(
- '??' => '_E7_94_B5_E5_BD_B1',
- '????' => '_E7_94_B5_E5_BD_B1_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E5_BD_B1',
- '???' => '_E7_94_B5_E8_A7_86_E5_89_A7',
- '?????' => '_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',
- '??' => '_E5_8A_A8_E6_BC_AB',
- '???' => '_E7_BA_AA_E5_BD_95_E7_89_87',
- '??' => '_E7_BB_BC_E8_89_BA',
- '??' => '_E9_9F_B3_E4_B9_90'
- );
- foreach ($categories as $name => $id) {
- $channel = $id;
- $data = array(
- 'mode' => 'channel',
- 'sort' => $isort,
- 'channel' => $channel
- );
- $dataString = http_build_query($data, '','&');
- $retMediaItems[] = array (
- 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
- 'dc:title' => $name,
- 'upnp:class' => 'object.container',
- );
- }
- return $retMediaItems;
- }
- //??????
- function _pluginCreateChannelPage($channel,$isort)
- {
- if( $channel == '_E7_94_B5_E5_BD_B1' ||
- $channel == '_E7_94_B5_E8_A7_86_E5_89_A7' ||
- $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' ||
- $channel == '_E7_94_B5_E5_BD_B1_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E5_BD_B1' ){
- $html = file_get_contents('http://search.video.qiyi.com/category/' . $channel . '/1/'.$isort.'/1/' .ITEMPERPAGE.'//www/');
- } else {
- $html = file_get_contents('http://search.video.qiyi.com/searchCategory/' . $channel . '/1/'.$isort.'/1/' .ITEMPERPAGE.'/www/');
- }
- preg_match_all('/"sumPages":(.*?),"weight"/',$html,$sumPages);
- //????
- $PagesNum = (int)$sumPages[1][0];
-
- for($z=0; $z<$PagesNum;$z++){
- $page = $z+1;
- $data = array(
- 'mode' => 'channelpage',
- 'sort' => $isort,
- 'channel' => $channel,
- 'page' => $page,
- );
- $dataString = http_build_query($data, '','&');
- $retMediaItems[] = array (
- 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
- 'dc:title' => '?'.$page.'?',
- 'upnp:class' => 'object.container',
- );
- }
- return $retMediaItems;
- }
- //??????????
- function _pluginCreateMovieList($channel,$page,$isort)
- {
- if( $channel == '_E7_94_B5_E5_BD_B1' ||
- $channel == '_E7_94_B5_E8_A7_86_E5_89_A7' ||
- $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' ||
- $channel == '_E7_94_B5_E5_BD_B1_20_E7_B2_A4_E8_AF_AD_E7_94_B5_E5_BD_B1'){
- $html = file_get_contents('http://search.video.qiyi.com/category/' . $channel . '/1/'.$isort.'/' . $page . '/' .ITEMPERPAGE.'//www/');
- } else {
- $html = file_get_contents('http://search.video.qiyi.com/searchCategory/' . $channel . '/1/'.$isort.'/' . $page . '/' .ITEMPERPAGE.'/www/');
- }
- //"VrsVideoTv.tvName":"???????","VrsVideotv.tvTag":"
- preg_match_all('/"VrsVideoTv.tvName":"(.*?)","/',$html,$title);
- preg_match_all('/"vrsVideoTv.TvBigPic":"(.*?)","VrsVideoTv.tvDesc":/',$html,$bigpic);
- preg_match_all('/"TvApplication.purl":"(.*?)","category"/',$html,$movieurl);
- preg_match_all('/"tvsets":"(.*?)","firstUrl":/',$html,$tvsets);
- preg_match_all('/"firstUrl":"(.*?)","/',$html,$firstUrl);
- //l($html);
- //l($firstUrl[1]);
- for ($z = 0; $z < sizeof($title[1]); $z++) {
- if ($firstUrl[1][$z]!='')
- {
- $istv = 1;
- $movlink = urlencode($firstUrl[1][$z]);
- }else
- {
- $istv =0;
- $movlink = urlencode($movieurl[1][$z]);
- }
- if ((int)$tvsets[1][$z]>0)
- {
- $name = $title[1][$z] . ' (?' . $tvsets[1][$z] . '?)';
- }else
- {
- $name = $title[1][$z];
- }
-
- $playmode = 'play';
-
- if($istv == 0){
- $playmode = 'play';
- }else if($istv == 1){
- $playmode = 'playtv';
- }else{
- $playmode = 'playtv';
- }
-
- $data = array(
- 'mode' => $playmode,
- 'movlink' => $movlink,
- 'name' => $name
- );
-
- $dataString = http_build_query($data,'', '&');
- $retMediaItems[] = array (
- 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
- 'dc:title' => $name,
- 'upnp:album_art'=> $bigpic[1][$z],
- 'upnp:class' => 'object.container'
- );
- }
- return $retMediaItems;
- }
- //??TV??
- function _pluginCreateTVPlayList($movlink,$name)
- {
- //l($movlink);
- $html = file_get_contents(urldecode($movlink));
- $html = str_replace("\r","",$html);
- $html = str_replace("\n","",$html);
- //l($html);
- //preg_match_all('/<a videoId="(.*?)"(.*?)href="(.*?)"(.*?)>(.*?)<\/a>/',$html,$tvurls);
- /*
- <li vid='ce7d6a8f76b1484faa17c8ccaaae225d'>
- <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>
- <p></p>
- </a><a href="http://www.qiyi.com/dianshiju/20110418/48af82e3012faac7.html" title="??????1?">?1?</a>
- </li>
- */
- preg_match_all('/<li vid=\'(.*?)\'>(.*?)<a href="(.*?)"(.*?)>(.*?)<\/a>/',$html,$tvurls);
- //l($tvurls);
- //$tvurls[3] url,tvurls[5] name
- for ($z = 0;$z<sizeof($tvurls[3]);$z++){
- $tvname = '';
- if(strlen($tvurls[5][$z])>4)
- {
- $tvname = $tvurls[5][$z];
- }else{
- $tvname = $name . ' - ' .$tvurls[5][$z];
- }
- $data = array(
- 'mode' => 'play',
- 'movlink' => $tvurls[3][$z],
- 'name' => $tvname
- );
- $dataString = http_build_query($data,'', '&');
-
- $retMediaItems[] = array (
- 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
- 'dc:title' => $tvname,
- 'upnp:class' => 'object.container'
- );
- }
- return $retMediaItems;
- }
- //??????
- function _pluginCreatePlayList($movlink,$name)
- {
- //l($movlink);
- $vurl = _getVideoUrl(urldecode($movlink));
- if ($vurl == '')
- {
- $retMediaItems[] = array (
- 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
- 'res' => $vurl,
- 'dc:title' => '???????????',
- 'upnp:class' => 'object.item.videoitem',
- 'protocolInfo' => 'http-get:*:video/mp4:*',
- );
- }else{
- $retMediaItems[] = array (
- 'id' => 'umsp://plugins/qiyi/qiyi?' . $dataString,
- 'res' => $vurl,
- 'dc:title' => '?? '.$name,
- 'upnp:class' => 'object.item.videoitem',
- 'protocolInfo' => 'http-get:*:video/mp4:*',
- );
- }
- return $retMediaItems;
- }
- //??????
- function _getVideoUrl($url)
- {
- $html = file_get_contents($url);
- //l($url);
- //tvId : "88373",//??id
- preg_match_all('/tvId : "(.*?)",\/\/??id/',$html,$tvid);
- $html = file_get_contents('http://cache.video.qiyi.com/h5/v/' .$tvid[1][0] . '/');
- preg_match_all('/"url":"(.*?)"/',$html,$vurl);
- $videourl = $vurl[1][0];
- return $videourl;
- }
- ?>