movie520.php 25 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693
  1. <?php
  2. header("Content-Type: text/html; charset=UTF-8");
  3. libxml_use_internal_errors(true);
  4. //建议php版本7 开启curl扩展
  5. $typeid =$_GET["t"];
  6. $page = $_GET["pg"];
  7. $ids = $_GET["ids"];
  8. $burl = $_GET["url"];
  9. $wd = $_GET["wd"];
  10. //通用模板要修改的东西只有:$web=网站链接 $movietype=影视分类 $url1=影视详情链接文本左 $url2=影视详情链接文本右
  11. //通用模板要修改的东西只有:$liebiao=影视列表链接 $num=影视列表单页多少个 $detail=影视详情链接
  12. //如果修改以上数据后还是无法显示列表,请自行修改xpath规则
  13. //===============================================基础配置开始===========================================
  14. $web='https://www.movie520.cn';
  15. //1=开启搜索 0=关闭搜索 默认关闭搜索(极品有验证码 开启无效,搜索框架仅供参考)
  16. $searchable=1;
  17. //====================以下内容可忽略不修改===================
  18. //1=curl访问 2=file_get_contents 真不卡用curl被屏蔽了,所以改为2. //$gettype仅在此模板有效(其他模板未添加这个设置) //如遇其他网站出现类似的【电脑可以访问,但是php打不开】也可以尝试用此模板
  19. $gettype=1;
  20. //$gettype=1时设置cookie有效,如不懂可以不填写(针对奈菲这样子的,就需要写入cookie才能访问)
  21. $cookie='';
  22. //当影视详情没有影视图片或取图片失败时,返回该指定的图片链接(不设置的话,缺图时历史记录的主图会空白)
  23. $historyimg='https://www.hjunkel.com/images/nopic2.gif';
  24. //模拟ua 如非不要默认即可
  25. $UserAgent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36';
  26. //1=开启直链分析 0=关闭直链分析 (直链也是通过本php页面解析) 测试极品关闭直链 大部分能通过webview解析
  27. //该模板的直链代码是针对极品影视的,每个站的直链代码都不同。其他网站请设置为0关闭
  28. $zhilian=0;
  29. //QQ iqiyi youku的VIP解析 没用直链的话,$vip设置无效
  30. $vip='https://jxapp.jpysvip.net/m3u8.php?url=';
  31. //====================以上内容可忽略不修改===================
  32. //===============================================基础配置结束===========================================
  33. //===============================================广告图片配置开始 可以不用修改 默认不开启=======================================
  34. //$adable=1开启广告 $adable=0关闭广告图片 可插入指定图片到每次读取第一页影视列表的开头,默认关闭
  35. $adable=0;
  36. $adpicurl='https://alifei05.cfp.cn/creative/vcg/800/version23/VCG41184086603.jpg';
  37. $adtitle1='我是片名';
  38. $adtitle2='我是更新内容';
  39. //===============================================广告图片配置结束 可以不用修改 默认不开启============================================
  40. //===============================================影视分类相关配置开始===========================
  41. //例如 国产剧链接:https://www.jpysvip.net/vodshow/13-----------.html 那国产剧ID就等于13
  42. //例如 电影链接:https://www.jpysvip.net/vodtype/1.html 那电影ID就等于1
  43. //电影 连续剧 关键词中间要用1个空格隔开,否则无法显示
  44. $movietype = '{"class":[{"type_id":"1","type_name":"电 影"},{"type_id":"2","type_name":"连续 剧"},{"type_id":"4","type_name":"动漫"},{"type_id":"31","type_name":"国创"},{"type_id":"32","type_name":"b电影"},{"type_id":"33","type_name":"b国产剧"},{"type_id":"34","type_name":"b日产剧"},{"type_id":"35","type_name":"b欧美剧"},{"type_id":"36","type_name":"b港台剧"},{"type_id":"37","type_name":"番剧"},{"type_id":"29","type_name":"哔哩哔哩"},{"type_id":"39","type_name":"蓝光电影"},{"type_id":"47","type_name":"蓝光动漫"},{"type_id":"48","type_name":"蓝光电视剧"}]}';
  45. //支持类目ID非数字,type_id按照正常顺序排列 把catname写进去.注意$liebiao也要填写正确 {pageid}也写在catname里即可
  46. //$movietype ='{"class":[{"type_id":1,"type_name":"全部动漫","catname":"all-all-all-all-all-time-{pageid}"},{"type_id":2,"type_name":"日漫","catname":"all-all-all-all-all-time-{pageid}-日本-all-all"},{"type_id":3,"type_name":"国漫","catname":"all-all-all-all-all-time-{pageid}-中国-all-all"},{"type_id":4,"type_name":"欧美动漫","catname":"all-all-all-all-all-time-{pageid}-欧美-all-all"}]}';
  47. //===============================================影视分类相关配置结束===========================
  48. //===============================================影视列表相关配置开始===========================
  49. //=====================苹果CMS通用模板修改以下内容即可=============================
  50. //取出影片ID的文本左边
  51. $url1='/voddetail/';
  52. //取出影片ID的文本右边
  53. $url2='.html';
  54. //影视列表链接 {pageid}=页码 {typeid}=类目ID 如果$movietype的catname不为空的话,{typeid}会被自动替换为相应的catname内容
  55. $liebiao='https://www.movie520.cn/vodtype/{typeid}-{pageid}.html';
  56. //每页多少个影片
  57. $num=48;
  58. //=====================苹果CMS通用模板修改以上内容即可=============================
  59. //xpath列表
  60. $query="//li/div[contains(@class,'-vodlist__box')]/a";
  61. //取出影片的图片
  62. $picAttr="//li/div[contains(@class,'-vodlist__box')]/a/@data-original";
  63. //取出影片的图片 优先取$picAttr $picAttr无结果的话,从$picAttr2取
  64. //如果会xpath的话,只需设置$picAttr的即可
  65. $picAttr2="//li/div[contains(@class,'-vodlist__box')]/a/img/@data-original";
  66. //取出影片的标题
  67. $titleAttr="//li/div[contains(@class,'-vodlist__box')]/a/@title";
  68. //取出影片的链接
  69. $linkAttr="//li/div[contains(@class,'-vodlist__box')]/a/@href";
  70. //影视更新情况 例如:更新至*集
  71. $query2 = "//li/div[contains(@class,'-vodlist__box')]/a/span[contains(@class,'pic-text')]";
  72. //===============================================影视列表相关配置结束===========================
  73. //===============================================影视详情相关配置开始===========================
  74. //=====================苹果CMS通用模板修改以下内容即可=============================
  75. //影片链接 {vodid}=影片ID
  76. $detail='https://www.movie520.cn/voddetail/{vodid}.html';
  77. //=====================苹果CMS通用模板修改以上内容即可=============================
  78. //影片名称
  79. $vodtitle="//h1[contains(@class,'title')]";
  80. //影片类型
  81. $vodtype="//div[contains(@class,'-content__detail')]//span[contains(@class,'text') and contains(text(), '分类')]/following-sibling::*/text()";
  82. //取出影片图片 猫的详情图片显示在历史记录里(历史记录图片没有的话,就是这个没取对)
  83. $vodimg="//a[contains(@class,'-vodlist__thumb') and contains(@class,'picture')]/img/@data-original";
  84. //取出影片简介
  85. $vodtext="//div[contains(@class,'-content__detail')]/p[contains(@class,'data') and contains(@class,'hidden')]/text()";
  86. //取出影片年份
  87. $vodyear="//div[contains(@class,'-content__detail')]//span[contains(@class,'text') and contains(text(), '年份')]/following-sibling::*/text()";
  88. //取出影片主演
  89. $vodactor="//div[contains(@class,'-content__detail')]//span[contains(@class,'text') and contains(text(), '主演')]/following-sibling::*/text()";
  90. //取出影片导演
  91. $voddirector="//div[contains(@class,'-content__detail')]//span[contains(@class,'text') and contains(text(), '导演')]/following-sibling::*/text()";
  92. //取出影片地区
  93. $vodarea="//div[contains(@class,'-content__detail')]//span[contains(@class,'text') and contains(text(), '地区')]/following-sibling::*/text()";
  94. //播放地址名称 //div[contains(@class,'-panel__head') and contains(@class, 'clearfix')]/ul/li/a
  95. //为了通用性,没有取出播放源名称(php自动添加名称) 会xpath的可以自己填写进去 例子如上
  96. $playname="";
  97. //播放地址 自动往下级尝试查找5次并取链接 如第二次就找到链接,就会从第二个下级中获取
  98. $playurl="//ul[contains(@class,'-content__') and contains(@class, 'list') and contains(@class, 'clearfix')]";
  99. //===============================================影视详情相关配置结束===========================
  100. //===============================================影视搜索相关配置开始===========================
  101. //=========下面把xpath规则的搜索屏蔽了,极品采用json的搜索结果========
  102. //影片搜索返回结果 1=htm代码套用xpath规则 2=json结果
  103. //$searchtype=1;
  104. $searchtype=2;
  105. //影片搜索 {wd}=搜索文字
  106. //$searchtype=1的网址
  107. //$search='https://www.jpysvip.net/vodsearch/-------------.html?wd={wd}&submit=';
  108. //$searchtype=2的网址
  109. //$search='https://www.jpysvip.net/index.php/ajax/suggest?mid=1&wd={wd}&limit=10';
  110. //通用模板 $web=前面设置的网址
  111. $search=$web.'/index.php/ajax/suggest?mid=1&wd={wd}&limit=10';
  112. //htm代码分析用xpath取影片,取出影片ID的文本左边
  113. //$searchurl1='/voddetail/';
  114. //searchtype=2时,如果$searchurl1不为空 那返回的影片ID前缀就会加上$searchurl1(前面$detail如果不能直接传入数字vodid的话,这里就需要自己补充了)
  115. $searchurl1='';
  116. //htm代码分析用xpath取影片,取出影片ID的文本右边
  117. //$searchurl2='.html';
  118. //searchtype=2时,如果$searchurl2不为空 那返回的影片ID后缀就会加上$searchurl2(前面$detail如果不能直接传入数字vodid的话,这里就需要自己补充了)
  119. $searchurl2='';
  120. //xpath列表
  121. //$searchquery="//ul[@class='myui-vodlist__media clearfix']/li/div/a";
  122. //json路径
  123. $searchquery='list';
  124. //xpath规则取出影片的标题
  125. //$searchtitleAttr="//ul[@class='myui-vodlist__media clearfix']/li/div/a/@title";
  126. //json取影片标题
  127. $searchtitleAttr='name';
  128. //xpath规则取出影片的链接
  129. //$searchlinkAttr="//ul[@class='myui-vodlist__media clearfix']/li/div/a/@href";
  130. //json取出影片的ID
  131. $searchlinkAttr='id';
  132. //xpath规则取影视更新情况 例如:更新至*集
  133. //$searchquery2 ="//ul[@class='myui-vodlist__media clearfix']/li/div/a/span[@class='pic-text text-right']";
  134. //json取影视更新情况 极品没有更新情况,所以留空
  135. $searchquery2 ='';
  136. //===============================================影视搜索相关配置结束===========================
  137. //==============================================仅需修改以上代码↑=======================================
  138. //==============================================以下内容的代码无需修改↓=======================================
  139. $weburl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  140. if ($typeid<> null && $page<>null){
  141. //==============================================读取影视列表开始=======================================
  142. $catname ='';
  143. $arr=json_decode($movietype,true);
  144. $arr_q1a=$arr['class'];
  145. $m=count($arr_q1a);
  146. for($i=0;$i<$m;$i++){
  147. $type_id = $arr_q1a[$i]["type_id"];
  148. if($typeid==$type_id){
  149. $catname = $arr_q1a[$i]["catname"];
  150. break;
  151. }
  152. }
  153. if($catname==null){
  154. $liebiao=str_replace("{typeid}",$typeid,$liebiao);
  155. }else{
  156. $liebiao=str_replace("{typeid}",$catname,$liebiao);
  157. }
  158. $liebiao=str_replace("{pageid}",$page,$liebiao);
  159. $html = curl_get($liebiao,$gettype,$cookie,$UserAgent);
  160. if(strpos($html, 'href=')==0 && strpos($liebiao, 'index-1.html')>0){
  161. $liebiao=str_replace("index-1.html","",$liebiao);
  162. $html = curl_get($liebiao,$gettype,$cookie,$UserAgent);
  163. }
  164. $dom = new DOMDocument();
  165. $html= mb_convert_encoding($html ,'HTML-ENTITIES',"UTF-8");
  166. $dom->loadHTML($html);
  167. $dom->normalize();
  168. $xpath = new DOMXPath($dom);
  169. $texts = $xpath->query($query2);
  170. //if($texts->length==0 && $query3<>null){
  171. //$texts = $xpath->query($query3);
  172. //}
  173. $events = $xpath->query($query);
  174. $picevents = $xpath->query($picAttr);
  175. if ($picevents->length==0 && $picAttr2<>null){
  176. $picevents = $xpath->query($picAttr2);
  177. }
  178. $titleevents= $xpath->query($titleAttr);
  179. $linkevents= $xpath->query($linkAttr);
  180. $length=$events->length;
  181. $guolv='';
  182. if ($adable==1 && $page==1){
  183. $length=$length+1;
  184. }
  185. if ($length<$num)
  186. {
  187. $page2=$page;
  188. }else{
  189. $length=$length+1;
  190. $page2=$page + 1;
  191. }
  192. $result='{"code":1,"page":'.$page.',"pagecount":'. $page2 .',"total":'. $length.',"list":[';
  193. if ($adable==1 && $page==1){
  194. $result=$result.'{"vod_id":"888888888","vod_name":"'.$adtitle1.'","vod_pic":"'.$adpicurl.'","vod_remarks":"'.$adtitle2.'"},';
  195. }
  196. for ($i = 0; $i < $events->length; $i++) {
  197. $event = $events->item($i);
  198. $text = $texts->item($i)->nodeValue;
  199. $text = replacestr($text);
  200. $link = $linkevents->item($i)->nodeValue;
  201. $title = $titleevents->item($i)->nodeValue;
  202. $title = replacestr($title);
  203. $pic = $picevents->item($i)->nodeValue;
  204. if($url1<>null){
  205. $link2 =getSubstr($link,$url1,$url2);
  206. }else{
  207. $link2 =$link;
  208. }
  209. if (substr($pic,0,2)=='//'){
  210. $pic = 'http:'.$pic;
  211. }else if (substr($pic,0,4)<>'http' && $pic<>null){
  212. $pic = $web.$pic;
  213. }
  214. if($guolv==null){
  215. $result=$result.'{"vod_id":"'.$link2.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  216. $guolv=$guolv."{".$link2."}";
  217. }else if(strpos($guolv, "{".$link2."}")==0){
  218. $result=$result.'{"vod_id":"'.$link2.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  219. $guolv=$guolv."{".$link2."}";
  220. }
  221. }
  222. $result=substr($result, 0, strlen($result)-1).']}';
  223. echo $result;
  224. //==============================================读取影视列表结束=======================================
  225. }else if ($ids<> null){
  226. if($ids=='888888888'){
  227. $result='{"list":[{"vod_id":"888888888",';
  228. $result=$result.'"vod_name":"'.$adtitle1.'",';
  229. $result=$result.'"vod_pic":"'.$adpicurl.'",';
  230. $actor='内详';
  231. $result=$result.'"vod_actor":"'.$actor.'",';
  232. $director='内详';
  233. $result=$result.'"vod_director":"'.$director.'",';
  234. $result=$result.'"vod_content":"'.$adtitle2.'",';
  235. $result= $result.'"vod_play_from":"'."无播放源".'",';
  236. $result= $result.'"vod_play_url":"'."1".'"}]}';
  237. echo $result;
  238. }else{
  239. //==============================================读取影视信息开始=======================================
  240. $detail=str_replace("{vodid}",$ids,$detail);
  241. $html = curl_get($detail,$gettype,$cookie,$UserAgent);
  242. $dom = new DOMDocument();
  243. $html= mb_convert_encoding($html ,'HTML-ENTITIES',"UTF-8");
  244. $dom->loadHTML($html);
  245. $dom->normalize();
  246. $xpath = new DOMXPath($dom);
  247. if($vodtitle<>null){
  248. $texts = $xpath->query($vodtitle);
  249. $text = $texts->item(0)->nodeValue;
  250. $text = replacestr($text);
  251. }
  252. if($vodtype<>null){
  253. $texts = $xpath->query($vodtype);
  254. $type = $texts->item(0)->nodeValue;
  255. $type = replacestr($type);
  256. }
  257. if($vodtext<>null){
  258. $texts = $xpath->query($vodtext);
  259. $vodtext2 = $texts->item(0)->nodeValue;
  260. $vodtext2 = replacestr($vodtext2);
  261. }
  262. if($vodyear<>null){
  263. $texts = $xpath->query($vodyear);
  264. $year = $texts->item(0)->nodeValue;
  265. $year = replacestr($year);
  266. }
  267. if($vodimg<>null){
  268. $texts = $xpath->query($vodimg);
  269. $img = $texts->item(0)->nodeValue;
  270. if (substr($img,0,2)=='//'){
  271. $img = 'http:'.$img;
  272. }else if (substr($img,0,4)<>'http' && $img<>null){
  273. $img = $web.$img;
  274. }
  275. }
  276. if($img==null){
  277. $img =$historyimg;
  278. }
  279. if($vodarea<>null){
  280. $texts = $xpath->query($vodarea);
  281. $area = $texts->item(0)->nodeValue;
  282. $area = replacestr($area);
  283. }
  284. if($vodactor<>null){
  285. $texts = $xpath->query($vodactor);
  286. $actor ='';
  287. for ($i = 0; $i < $texts->length; $i++) {
  288. $event1 = $texts->item($i);
  289. $actor = $actor.$event1->nodeValue.' ';
  290. }
  291. }
  292. if($voddirector<>null){
  293. $texts = $xpath->query($voddirector);
  294. $director ='';
  295. for ($i = 0; $i < $texts->length; $i++) {
  296. $event1 = $texts->item($i);
  297. $director = $director.$event1->nodeValue.' ';
  298. }
  299. }
  300. $result='{"list":[{"vod_id":"'.$ids.'",';
  301. if($text==null){
  302. $text='片名获取失败';
  303. }
  304. $result=$result.'"vod_name":"'.$text.'",';
  305. if($img<>null){
  306. $result=$result.'"vod_pic":"'.$img.'",';
  307. }
  308. if($type<>null){
  309. $result=$result.'"type_name":"'.$type.'",';
  310. }
  311. if($year<>null){
  312. $result=$result.'"vod_year":"'.$year.'",';
  313. }
  314. if($actor==null){
  315. $actor='内详';
  316. }
  317. $result=$result.'"vod_actor":"'.$actor.'",';
  318. if($director==null){
  319. $director='内详';
  320. }
  321. $result=$result.'"vod_director":"'.$director.'",';
  322. if($area<>null){
  323. $result=$result.'"vod_area":"'.$area.'",';
  324. }
  325. if($vodtext2<>null){
  326. $vodtext2=str_replace('"','\"',$vodtext2);
  327. $result=$result.'"vod_content":"'.$vodtext2.'",';
  328. }
  329. $yuan = '';
  330. $dizhi = '';
  331. $text1 = $xpath->query($playname);
  332. $text2 = $xpath->query($playurl);
  333. if($text2->length==0){
  334. $result= $result.'"vod_play_from":"'."原页面".'",';
  335. $result= $result.'"vod_play_url":"'.$detail.'"}]}';
  336. }else{
  337. $i3=1;
  338. if($playname<>null){
  339. for ($i = 0; $i < $text2->length; $i++) {
  340. $event1 = $text1->item($i);
  341. $bfyuan = $event1->nodeValue;
  342. $bfyuan = replacestr($bfyuan);
  343. if($bfyuan==null){
  344. $bfyuan="播放源".$i3;
  345. $i3=$i3+1;
  346. }
  347. $yuan = $yuan.$bfyuan.'$$$';
  348. }
  349. }
  350. if($yuan==''){
  351. for ($i = 0; $i < $text2->length; $i++) {
  352. $bfyuan =$i+1;
  353. $yuan = $yuan."播放源".$bfyuan.'$$$';
  354. }
  355. }
  356. foreach ($text2 as $oObject) {
  357. $dizhi2 = '';
  358. foreach($oObject->childNodes as $col){
  359. if ($col->hasChildNodes()){
  360. $link4 = $col->getAttribute('href');
  361. if($link4<>null){
  362. $text4 = $col->nodeValue;
  363. $text4 = replacestr($text4);
  364. if (substr($link4,0,4)<>'http' && $link4<>null){
  365. $link4 = $web.$link4;
  366. }
  367. if($zhilian==1){
  368. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  369. }else{
  370. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  371. }
  372. }else{
  373. foreach($col->childNodes as $col2){
  374. if ($col2->hasChildNodes()){
  375. $link4 = $col2->getAttribute('href');
  376. if($link4<>null){
  377. $text4 = $col2->nodeValue;
  378. $text4 = replacestr($text4);
  379. if (substr($link4,0,4)<>'http' && $link4<>null){
  380. $link4 = $web.$link4;
  381. }
  382. if($zhilian==1){
  383. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  384. }else{
  385. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  386. }
  387. }else{
  388. foreach($col2->childNodes as $col3){
  389. if ($col3->hasChildNodes()){
  390. $link4 = $col3->getAttribute('href');
  391. if($link4<>null){
  392. $text4 = $col3->nodeValue;
  393. $text4 = replacestr($text4);
  394. if (substr($link4,0,4)<>'http' && $link4<>null){
  395. $link4 = $web.$link4;
  396. }
  397. if($zhilian==1){
  398. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  399. }else{
  400. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  401. }
  402. }else{
  403. foreach($col3->childNodes as $col4){
  404. if ($col4->hasChildNodes()){
  405. $link4 = $col4->getAttribute('href');
  406. if($link4<>null){
  407. $text4 = $col4->nodeValue;
  408. $text4 = replacestr($text4);
  409. if (substr($link4,0,4)<>'http' && $link4<>null){
  410. $link4 = $web.$link4;
  411. }
  412. if($zhilian==1){
  413. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  414. }else{
  415. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  416. }
  417. }else{
  418. foreach($col4->childNodes as $col5){
  419. if ($col5->hasChildNodes()){
  420. $link4 = $col5->getAttribute('href');
  421. if($link4<>null){
  422. $text4 = $col5->nodeValue;
  423. $text4 = replacestr($text4);
  424. if (substr($link4,0,4)<>'http' && $link4<>null){
  425. $link4 = $web.$link4;
  426. }
  427. if($zhilian==1){
  428. $dizhi2 = $dizhi2.$text4.'$'.$weburl.'?url='.$link4.'#';
  429. }else{
  430. $dizhi2 = $dizhi2.$text4.'$'.$link4.'#';
  431. }}}}}}}}}}}}}}}}
  432. if($dizhi2==null){
  433. $dizhi=$dizhi.'无播放地址 请检查xpath规则$http'.'$$$';
  434. }else{
  435. $dizhi=$dizhi.substr($dizhi2, 0, strlen($dizhi2)-1).'$$$';
  436. }
  437. }
  438. $result= $result.'"vod_play_from":"'.substr($yuan, 0, strlen($yuan)-3).'",';
  439. $result= $result.'"vod_play_url":"'.substr($dizhi, 0, strlen($dizhi)-3).'"}]}';
  440. }
  441. echo $result;
  442. //==============================================读取影视信息结束=======================================
  443. }
  444. }else if ($burl<> null){
  445. //=============================以下是直链分析代码=======================================================
  446. $html = curl_get($burl,$gettype,$cookie,$UserAgent);
  447. $content=getSubstr($html,'var player','</script>');
  448. $content=getSubstr($content,'"url":"','",');
  449. $content=str_replace("\/","/",$content);
  450. if(strpos($content,"qq.com")>0 or strpos($content,"youku.com")>0 or strpos($content,"iqiyi.com")>0 or strpos($content,"mgtv.com")>0){
  451. $content=$vip.$content;
  452. }
  453. echo '<iframe src="'.$content.'" class="iframeStyle" id="myiframe" ></iframe>';
  454. //==============================以上是直链分析代码=======================================================
  455. }else if ($wd<> null){
  456. //=============================以下是搜索代码=======================================================
  457. if($searchable==0){
  458. echo 'php未开启搜索';
  459. exit;
  460. }
  461. if($page==null){
  462. $page=1;
  463. }
  464. $geturl =str_replace("{wd}",urlencode($wd),$search);
  465. $geturl =str_replace("{page}",$page,$geturl);
  466. $html = curl_get($geturl,$gettype,$cookie,$UserAgent);
  467. if($searchtype==1){
  468. $dom = new DOMDocument();
  469. $html= mb_convert_encoding($html ,'HTML-ENTITIES',"UTF-8");
  470. $dom->loadHTML($html);
  471. $dom->normalize();
  472. $xpath = new DOMXPath($dom);
  473. $texts = $xpath->query($searchquery2);
  474. $events = $xpath->query($searchquery);
  475. $titleevents= $xpath->query($searchtitleAttr);
  476. $linkevents= $xpath->query($searchlinkAttr);
  477. $length=$events->length;
  478. $result='{"code":1,"page":'.$page.',"pagecount":'. $page.',"total":'. $length.',"list":[';
  479. for ($i = 0; $i < $events->length; $i++) {
  480. $event = $events->item($i);
  481. $text = $texts->item($i)->nodeValue;
  482. $link = $linkevents->item($i)->nodeValue;
  483. $title = $titleevents->item($i)->nodeValue;
  484. if($searchurl1<>null){
  485. $link2 =getSubstr($link,$searchurl1,$searchurl2);
  486. }else{
  487. $link2 =$link;
  488. }
  489. $result=$result.'{"vod_id":"'.$link2.'","vod_name":"'.$title.'","vod_remarks":"'.$text.'"},';
  490. }
  491. $result=substr($result, 0, strlen($result)-1).']}';
  492. echo $result;
  493. }else{
  494. $arr=json_decode($html,true);
  495. $arr_q1a=$arr[$searchquery];
  496. $m=count($arr_q1a);
  497. $result='{"code":1,"page":'.$page.',"pagecount":'. $page.',"total":'. $m.',"list":[';
  498. for($i=0;$i<$m;$i++){
  499. $title = $arr_q1a[$i][$searchtitleAttr];
  500. $link = $arr_q1a[$i][$searchlinkAttr];
  501. if($url1==null && is_numeric($link)==true && $searchurl1<>null){
  502. $link =$searchurl1.$link.$searchurl2;
  503. }
  504. if($searchquery2<>null){
  505. $text = $arr_q1a[$i][$searchquery2];
  506. $result=$result.'{"vod_id":"'.$link.'","vod_name":"'.$title.'","vod_remarks":"'.$text.'"},';
  507. }else{
  508. $result=$result.'{"vod_id":"'.$link.'","vod_name":"'.$title.'"},';
  509. }
  510. }
  511. $result=substr($result, 0, strlen($result)-1).']}';
  512. echo $result;
  513. }
  514. //==============================以上是搜索代码=======================================================
  515. }else{
  516. echo $movietype;
  517. }
  518. function curl_get($url,$gettype2,$cookie2,$UserAgent2){
  519. $header = array(
  520. 'Accept: */*',
  521. 'Accept-Language: zh-cn',
  522. 'Referer: '.$url,
  523. 'User-Agent: '.$UserAgent2,
  524. 'Content-Type: application/x-www-form-urlencoded'
  525. );
  526. if($gettype2==2){
  527. $data = file_get_contents($url);
  528. return $data;
  529. }else{
  530. $curl = curl_init();
  531. curl_setopt($curl, CURLOPT_URL, $url);
  532. curl_setopt($curl, CURLOPT_HEADER, 0);
  533. curl_setopt($curl, CURLOPT_TIMEOUT, 20);
  534. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  535. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  536. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  537. curl_setopt ($curl, CURLOPT_HTTPHEADER , $header);
  538. curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent2);
  539. if($cookie2<>null){
  540. curl_setopt($curl, CURLOPT_COOKIE, $cookie2);
  541. }
  542. $data = curl_exec($curl);
  543. if (curl_error($curl)) {
  544. return "Error: ".curl_error($curl);
  545. } else {
  546. curl_close($curl);
  547. return $data;
  548. }
  549. }
  550. }
  551. function getSubstr($str, $leftStr, $rightStr)
  552. {
  553. if($leftStr<>null && $rightStr<>null){
  554. $left = strpos($str, $leftStr);
  555. $right = strpos($str, $rightStr,$left+strlen($left));
  556. if($left < 0 or $right < $left){
  557. return '';
  558. }
  559. return substr($str, $left + strlen($leftStr),$right-$left-strlen($leftStr));
  560. }else{
  561. $str2=$str;
  562. if($leftStr<>null){
  563. $str2=str_replace($leftStr,'',$str2);
  564. }
  565. if($rightStr<>null){
  566. $str2=str_replace($rightStr,'',$str2);
  567. }
  568. return $str2;
  569. }
  570. }
  571. function replacestr($str2){
  572. $test2=$str2;
  573. $test2=str_replace(" ","",$test2);
  574. $test2=str_replace(" ","",$test2);
  575. $test2 = preg_replace('/\s*/', '', $test2);
  576. return $test2;
  577. }
  578. ?>