mgtv.php 21 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516
  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. //===============================================基础配置开始===========================================
  11. $web='https://www.mgtv.com';
  12. //1=开启搜索 0=关闭搜索 默认关闭搜索
  13. $searchable=1;
  14. //1=开启首页推荐 0=关闭首页推荐
  15. $indexable=1;
  16. //====================以下内容可忽略不修改===================
  17. //如不懂可以不填写
  18. $cookie='';
  19. //当影视详情没有影视图片或取图片失败时,返回该指定的图片链接(不设置的话,缺图时历史记录的主图会空白)
  20. $historyimg='https://www.hjunkel.com/images/nopic2.gif';
  21. //模拟ua 如非不要默认即可
  22. $UserAgent='Mozilla/5.0 (Windows NT 6.1; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/63.0.3239.132 Safari/537.36';
  23. //1=开启直链分析 0=关闭直链分析 (直链也是通过本php页面解析) 测试极品关闭直链 大部分能通过webview解析
  24. //该模板的直链代码是针对极品影视的,每个站的直链代码都不同。其他网站请设置为0关闭
  25. $zhilian=0;
  26. //====================以上内容可忽略不修改===================
  27. //===============================================基础配置结束===========================================
  28. //===============================================广告图片配置开始 可以不用修改 默认不开启=======================================
  29. //$adable=1开启广告 $adable=0关闭广告图片 可插入指定图片到每次读取第一页影视列表的开头,默认关闭
  30. $adable=0;
  31. $adpicurl='https://alifei05.cfp.cn/creative/vcg/800/version23/VCG41184086603.jpg';
  32. $adtitle1='我是片名';
  33. $adtitle2='我是更新内容';
  34. //===============================================广告图片配置结束 可以不用修改 默认不开启============================================
  35. //===============================================影视分类相关配置开始===========================
  36. $movietype = '{"class":[{"type_id":"1","type_name":"电 影","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=a1&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"2","type_name":"连续 剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=a1&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"3","type_name":"综艺","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=1&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=a1&area=a1&sort=c1"},{"type_id":"4","type_name":"动漫","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=50&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=a1&area=a1&edition=a1&sort=c1"},{"type_id":"5","type_name":"甜蜜互宠","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=14&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"6","type_name":"古装剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=148&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"7","type_name":"悬疑剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=3002&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"8","type_name":"喜剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=3005&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"9","type_name":"都市职场","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=19&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"10","type_name":"偶像剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=147&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"11","type_name":"谍战剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=3004&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"12","type_name":"家庭剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=3007&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"13","type_name":"青春剧","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=3003&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1"},{"type_id":"14","type_name":"喜剧片","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=176&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"15","type_name":"动作片","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=177&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"16","type_name":"爱情片","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=175&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"17","type_name":"恐怖悬疑","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=43&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"18","type_name":"警匪片","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=45&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"20","type_name":"战争片","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=44&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"21","type_name":"科幻片","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=178&edition=a1&year=all&chargeInfo=a1&sort=c1"},{"type_id":"22","type_name":"动画片","catname":"https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=3&pn={pageid}&pc=80&hudong=1&_support=10000000&kind=48&edition=a1&year=all&chargeInfo=a1&sort=c1"}]}';
  37. //===============================================影视分类相关配置结束===========================
  38. //===============================================首页推荐相关配置开始===========================
  39. $indexnum=50;
  40. //===============================================首页推荐相关配置结束===========================
  41. //===============================================影视搜索相关配置开始===========================
  42. //=========下面把xpath规则的搜索屏蔽了,极品采用json的搜索结果========
  43. $searchtype=1;
  44. //-----------------------------如非必要,下面4项可以不用修改-------------------------------
  45. //影片标题是否精确匹配 1=精确匹配(必须包含搜索文字) 0为关闭精确匹配,显示所有搜索结果
  46. $titlematch=1;
  47. //搜索访问类型 1=get 2=post 一般默认为1
  48. $datatype=1;
  49. //搜索访问提交数据 当$datatype为2时,需要在此处填写提交数据 关键词用{wd}代替
  50. $searchdata='';
  51. //{wd}提交的编码格式 1=utf-8编码 2=gb2312编码(大部分网站默认为utf-8即可)
  52. $convert=1;
  53. //-----------------------------如非必要,上面4项可以不用修改-------------------------------
  54. //===============================================影视搜索相关配置结束===========================
  55. //==============================================仅需修改以上代码↑=======================================
  56. //==============================================以下内容的代码无需修改↓=======================================
  57. $weburl='http://'.$_SERVER['HTTP_HOST'].$_SERVER['PHP_SELF'];
  58. if ($typeid<> null && $page<>null){
  59. //==============================================读取影视列表开始=======================================
  60. $catname ='';
  61. $arr=json_decode($movietype,true);
  62. $arr_q1a=$arr['class'];
  63. $m=count($arr_q1a);
  64. for($i=0;$i<$m;$i++){
  65. $type_id = $arr_q1a[$i]["type_id"];
  66. if($typeid==$type_id){
  67. $catname = $arr_q1a[$i]["catname"];
  68. break;
  69. }
  70. }
  71. $catname=str_replace('{pageid}',$page,$catname);
  72. $html ='';
  73. for ($i = 0; $i < 3; $i++) {
  74. $html = curl_get($catname,$cookie,$UserAgent);
  75. if($html<>null){
  76. break;
  77. }
  78. }
  79. $arr=json_decode($html,true);
  80. $arr_q1a=$arr['data']['hitDocs'];
  81. $m=count($arr_q1a);
  82. $length=$m;
  83. $guolv='';
  84. if ($adable==1 && $page==1){
  85. $length=$length+1;
  86. }
  87. if ($length<$num)
  88. {
  89. $page2=$page;
  90. }else{
  91. $length=$length+1;
  92. $page2=$page + 1;
  93. }
  94. $result='{"code":1,"page":'.$page.',"pagecount":'. $page2 .',"total":'. $length.',"list":[';
  95. if ($adable==1 && $page==1){
  96. $result=$result.'{"vod_id":"888888888","vod_name":"'.$adtitle1.'","vod_pic":"'.$adpicurl.'","vod_remarks":"'.$adtitle2.'"},';
  97. }
  98. for ($i = 0; $i < $m; $i++) {
  99. $text=$arr['data']['hitDocs'][$i]['updateInfo'];
  100. if($text==null){
  101. $text=$arr['data']['hitDocs'][$i]['rightCorner']['text'];
  102. }
  103. if($text==null){
  104. $text=$arr['data']['hitDocs'][$i]['year'].'年';
  105. }
  106. $clipId=$arr['data']['hitDocs'][$i]['clipId'];
  107. $playPartId=$arr['data']['hitDocs'][$i]['playPartId'];
  108. $link =$playPartId;
  109. $title =$arr['data']['hitDocs'][$i]['title'];
  110. $pic = $arr['data']['hitDocs'][$i]['img'];
  111. if (substr($pic,0,2)=='//'){
  112. $pic = 'https:'.$pic;
  113. }
  114. if($text<>'预告' && $text<>'付费点播' && $text<>'VIP用券'){
  115. if($guolv==null){
  116. $result=$result.'{"vod_id":"'.$link.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  117. $guolv=$guolv."{".$link."}";
  118. }else if(strpos($guolv, "{".$link2."}")===false){
  119. $result=$result.'{"vod_id":"'.$link.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  120. $guolv=$guolv."{".$link."}";
  121. }
  122. }
  123. }
  124. $result=substr($result, 0, strlen($result)-1).']}';
  125. echo $result;
  126. //==============================================读取影视列表结束=======================================
  127. }else if ($ids<> null && strpos($ids, ",")===false && strpos($ids, "%2C")===false){
  128. if($ids=='888888888'){
  129. $result='{"list":[{"vod_id":"888888888",';
  130. $result=$result.'"vod_name":"'.$adtitle1.'",';
  131. $result=$result.'"vod_pic":"'.$adpicurl.'",';
  132. $actor='内详';
  133. $result=$result.'"vod_actor":"'.$actor.'",';
  134. $director='内详';
  135. $result=$result.'"vod_director":"'.$director.'",';
  136. $result=$result.'"vod_content":"'.$adtitle2.'",';
  137. $result= $result.'"vod_play_from":"'."无播放源".'",';
  138. $result= $result.'"vod_play_url":"'."1".'"}]}';
  139. echo $result;
  140. }else{
  141. //==============================================读取影视信息开始=======================================
  142. $vid='https://pcweb.api.mgtv.com/video/info?vid='.$ids.'&_support=10000000';
  143. $html = curl_get($vid,$cookie,$UserAgent);
  144. $arr=json_decode($html,true);
  145. $text=$arr['data']['info']['clipName'];
  146. $img=$arr['data']['info']['clipImage'];
  147. if (substr($img,0,2)=='//'){
  148. $img = 'https:'.$img;
  149. }
  150. if($img==null){
  151. $img= $historyimg;
  152. }
  153. $type =$arr['data']['info']['fstlvlType'];
  154. $actor=$arr['data']['info']['detail']['leader'];
  155. $director=$arr['data']['info']['detail']['director'];
  156. $area=$arr['data']['info']['detail']['area'];
  157. $vodtext2=$arr['data']['info']['detail']['story'];
  158. $year=$arr['data']['info']['detail']['releaseTime'];
  159. $html ='';
  160. $webids='https://pcweb.api.mgtv.com/episode/list?_support=10000000&version=5.5.35&video_id='.$ids.'&page=1&size=50';
  161. for ($i = 0; $i < 3; $i++) {
  162. $html = curl_get($webids,$cookie,$UserAgent);
  163. if($html<>null){
  164. break;
  165. }
  166. }
  167. $arr=json_decode($html,true);
  168. $arr_q1a=$arr['data']['list'];
  169. $result='{"list":[{"vod_id":"'.$ids.'",';
  170. if($text==null){
  171. $text='片名获取失败';
  172. }
  173. $result=$result.'"vod_name":"'.$text.'",';
  174. if($img<>null){
  175. $result=$result.'"vod_pic":"'.$img.'",';
  176. }
  177. if($type<>null){
  178. $result=$result.'"type_name":"'.$type.'",';
  179. }
  180. if($year<>null){
  181. $result=$result.'"vod_year":"'.$year.'",';
  182. }
  183. if($actor==null){
  184. $actor='内详';
  185. }
  186. $result=$result.'"vod_actor":"'.$actor.'",';
  187. if($director==null){
  188. $director='内详';
  189. }
  190. $result=$result.'"vod_director":"'.$director.'",';
  191. if($area<>null){
  192. $result=$result.'"vod_area":"'.$area.'",';
  193. }
  194. if($vodtext2<>null){
  195. $vodtext2=str_replace('"','\"',$vodtext2);
  196. $result=$result.'"vod_content":"'.$vodtext2.'",';
  197. }
  198. $m=count($arr_q1a);
  199. $total=$arr['data']['total'];
  200. $yuan = 'mgtv';
  201. if($m=='0'){
  202. $result= $result.'"vod_play_from":"'."mgtv".'",';
  203. $result= $result.'"vod_play_url":"'.'高清$'.$ids.'"}]}';
  204. }else{
  205. for($i=0;$i<$m;$i++)
  206. {
  207. $name=$arr['data']['list'][$i]['t4'];
  208. $font=$arr['data']['list'][$i]['corner'][0]['font'];
  209. if($font=='预'){
  210. $name=$name.'(预告)';
  211. }else if($font=='VIP'){
  212. $name=$name.'(VIP)';
  213. }
  214. $t1=$arr['data']['list'][$i]['t1'];
  215. $dizhi2='https://www.mgtv.com'.$arr['data']['list'][$i]['url'];
  216. if(strpos($t1,'彩蛋')===false){
  217. $dizhi=$dizhi.$name.'$'.$dizhi2.'#';
  218. }
  219. }
  220. if($total>50){
  221. $pg=floor($total/50);
  222. for($i2=0;$i2<$pg;$i2++) {
  223. $i3=$i2+2;
  224. $ids2=str_replace('page=1','page='.$i3,$webids);
  225. $html2 = curl_get($ids2,$cookie,$UserAgent);
  226. $arr2=json_decode($html2,true);
  227. $arr_q1a2=$arr2['data']['list'];
  228. $m2=count($arr_q1a2);
  229. for($i4=0;$i4<$m2;$i4++)
  230. {
  231. $name=$arr2['data']['list'][$i4]['t4'];
  232. $t1=$arr2['data']['list'][$i4]['t1'];
  233. $font=$arr2['data']['list'][$i4]['corner'][0]['font'];
  234. if($font=='预'){
  235. $name=$name.'(预告)';
  236. }else if($font=='VIP'){
  237. $name=$name.'(VIP)';
  238. }
  239. $dizhi2='https://www.mgtv.com'.$arr2['data']['list'][$i4]['url'];
  240. if(strpos($t1,'彩蛋')===false){
  241. $dizhi=$dizhi.$name.'$'.$dizhi2.'#';
  242. }
  243. }
  244. }
  245. }
  246. }
  247. $dizhi=substr($dizhi, 0, strlen($dizhi)-1);
  248. $dizhi2='';
  249. $hello=explode("#",$dizhi);
  250. if(count($hello)==2){
  251. if(floor($hello[0])<floor($hello[1])){
  252. $dizhi2=$hello[1].'#'.$hello[0];
  253. $dizhi=$dizhi2;
  254. }
  255. }
  256. $result= $result.'"vod_play_from":"'.$yuan.'",';
  257. $result= $result.'"vod_play_url":"'.$dizhi.'"}]}';
  258. }
  259. echo $result;
  260. //==============================================读取影视信息结束=======================================
  261. }else if ($burl<> null){
  262. //=============================以下是直链分析代码=======================================================
  263. $html = curl_get($burl,$cookie,$UserAgent);
  264. $content=getSubstr($html,'var player','</script>');
  265. $content=getSubstr($content,'"url":"','",');
  266. $content=urldecode(str_replace("\/","/",$content));
  267. if(strpos($content,'.m3u8')>0 or strpos($content,'.mp4')>0){
  268. echo '<iframe src="'.$content.'" class="iframeStyle" id="myiframe" ></iframe>';
  269. }else{
  270. $from=getSubstr($html,'"from":"','",');
  271. $from=urldecode(str_replace("\/","/",$from));
  272. $playerconfig=$web.'/static/js/playerconfig.js';
  273. $playerhtml = curl_get($playerconfig,$cookie,$UserAgent);
  274. if(strpos($playerhtml,'player_list=')>0){
  275. $content2=getSubstr($playerhtml,'player_list=',',Mac');
  276. $arr=json_decode($content2,true);
  277. $show=$arr[$from]['show'];
  278. $parse=$arr[$from]['parse'];
  279. if (substr($parse,0,4)<>'http'){
  280. $parse=$web.$parse;
  281. }
  282. $parse=str_replace("\/","/",$parse);
  283. echo '<iframe src="'.$parse.$content.'" class="iframeStyle" id="myiframe" ></iframe>';
  284. }else{
  285. echo '<iframe src="'.$burl.'" class="iframeStyle" id="myiframe" ></iframe>';
  286. }
  287. }
  288. //==============================以上是直链分析代码=======================================================
  289. }else if ($wd<> null){
  290. //=============================以下是搜索代码=======================================================
  291. if($searchable==0){
  292. echo 'php未开启搜索';
  293. exit;
  294. }
  295. if($page==null){
  296. $page=1;
  297. }
  298. $key=urlencode($wd);
  299. $search='https://mobileso.bz.mgtv.com/pc/search/v1?q={wd}&pn=1&pc=10&uid=';
  300. $geturl =str_replace("{wd}",$key,$search);
  301. $html = curl_get($geturl,$cookie,$UserAgent);
  302. $arr=json_decode($html,true);
  303. $arr_q1a=$arr['data']['contents'];
  304. $m=count($arr_q1a);
  305. $result='{"code":1,"page":'.$page.',"pagecount":'. $page.',"total":'. $m.',"list":[';
  306. for($i=0;$i<$m;$i++){
  307. $title = $arr_q1a[$i]['data']['title'];
  308. $link = $arr_q1a[$i]['data']['vid'];
  309. if( $link==null){
  310. $link = $arr_q1a[$i]['data']['sourceList'][0]['vid'];
  311. }
  312. if($title<>null && $link<>null && strpos($title,"《")===false && strpos($title,$wd)<>false){
  313. $result=$result.'{"vod_id":"'.$link.'","vod_name":"'.$title.'"},';
  314. }
  315. }
  316. $result=substr($result, 0, strlen($result)-1).']}';
  317. echo $result;
  318. //==============================以上是搜索代码=======================================================
  319. }else{
  320. if($indexable==0){
  321. echo $movietype;
  322. }else{
  323. $html = curl_get('https://pianku.api.mgtv.com/rider/list/pcweb/v3?platform=pcweb&channelId=2&pn=1&pc=80&hudong=1&_support=10000000&kind=a1&area=a1&year=all&edition=all&feature=all&chargeInfo=a1&sort=c1',$cookie,$UserAgent);
  324. $arr=json_decode($html,true);
  325. $arr_q1a=$arr['data']['hitDocs'];
  326. $m=count($arr_q1a);
  327. $guolv='';
  328. $m2=0;
  329. if($m==0){
  330. echo $movietype;
  331. }else{
  332. $result=',"list": [';
  333. for ($i = 0; $i < $m; $i++) {
  334. $text=$arr['data']['hitDocs'][$i]['updateInfo'];
  335. if($text==null){
  336. $text=$arr['data']['hitDocs'][$i]['rightCorner']['text'];
  337. }
  338. $clipId=$arr['data']['hitDocs'][$i]['clipId'];
  339. $playPartId=$arr['data']['hitDocs'][$i]['playPartId'];
  340. $link =$playPartId;
  341. $title =$arr['data']['hitDocs'][$i]['title'];
  342. $pic = $arr['data']['hitDocs'][$i]['img'];
  343. if (substr($pic,0,2)=='//'){
  344. $pic = 'https:'.$pic;
  345. }
  346. if($title<>null && $link<>null){
  347. if($guolv==null){
  348. $result=$result.'{"vod_id":"'.$link.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  349. $guolv=$guolv."{".$link."}";
  350. $m2=$m2+1;
  351. }else if(strpos($guolv, "{".$link."}")===false){
  352. $result=$result.'{"vod_id":"'.$link.'","vod_name":"'.$title.'","vod_pic":"'.$pic.'","vod_remarks":"'.$text.'"},';
  353. $guolv=$guolv."{".$link2."}";
  354. $m2=$m2+1;
  355. }
  356. }
  357. if($m2>=$indexnum){
  358. break;
  359. }
  360. }
  361. $result=substr($result, 0, strlen($result)-1).']}';
  362. echo substr($movietype, 0, strlen($movietype)-1).$result;
  363. }
  364. }
  365. }
  366. function curl_get($url,$cookie2,$UserAgent2){
  367. $header = array(
  368. 'Accept: */*',
  369. 'Accept-Language: zh-cn',
  370. 'Referer: '.$url,
  371. 'User-Agent: '.$UserAgent2,
  372. 'Content-Type: application/x-www-form-urlencoded'
  373. );
  374. $curl = curl_init();
  375. curl_setopt($curl, CURLOPT_URL, $url);
  376. curl_setopt($curl, CURLOPT_HEADER, 0);
  377. curl_setopt($curl, CURLOPT_TIMEOUT, 20);
  378. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  379. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  380. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  381. curl_setopt ($curl, CURLOPT_HTTPHEADER , $header);
  382. curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent2);
  383. if($cookie2<>null){
  384. curl_setopt($curl, CURLOPT_COOKIE, $cookie2);
  385. }
  386. $data = curl_exec($curl);
  387. if (curl_error($curl)) {
  388. return "Error: ".curl_error($curl);
  389. } else {
  390. curl_close($curl);
  391. return $data;
  392. }
  393. }
  394. function curl_post($url,$postdata,$cookie2,$UserAgent2){
  395. $header = array(
  396. 'Accept: */*',
  397. 'Accept-Language: zh-cn',
  398. 'Referer: '.$url,
  399. 'User-Agent: '.$UserAgent2,
  400. 'Content-Type: application/x-www-form-urlencoded'
  401. );
  402. $curl = curl_init();
  403. curl_setopt($curl, CURLOPT_URL, $url);
  404. curl_setopt($curl, CURLOPT_HEADER, 0);
  405. curl_setopt($curl, CURLOPT_TIMEOUT, 20);
  406. curl_setopt($curl, CURLOPT_RETURNTRANSFER, 1);
  407. curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
  408. curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
  409. curl_setopt ($curl, CURLOPT_HTTPHEADER , $header);
  410. curl_setopt($curl, CURLOPT_USERAGENT, $UserAgent2);
  411. curl_setopt($curl, CURLOPT_POST, 1);
  412. curl_setopt($curl, CURLOPT_POSTFIELDS, $postdata);
  413. if($cookie2<>null){
  414. curl_setopt($curl, CURLOPT_COOKIE, $cookie2);
  415. }
  416. $data = curl_exec($curl);
  417. if (curl_error($curl)) {
  418. return "Error: ".curl_error($curl);
  419. } else {
  420. curl_close($curl);
  421. return $data;
  422. }
  423. }
  424. function getSubstr($str, $leftStr, $rightStr)
  425. {
  426. if($leftStr<>null && $rightStr<>null){
  427. $left = strpos($str, $leftStr);
  428. $right = strpos($str, $rightStr,$left+strlen($leftStr));
  429. if($left < 0 or $right < $left){
  430. return '';
  431. }
  432. return substr($str, $left + strlen($leftStr),$right-$left-strlen($leftStr));
  433. }else{
  434. $str2=$str;
  435. if($leftStr<>null){
  436. $str2=str_replace($leftStr,'',$str2);
  437. }
  438. if($rightStr<>null){
  439. $str2=str_replace($rightStr,'',$str2);
  440. }
  441. return $str2;
  442. }
  443. }
  444. function replacestr($str2){
  445. $test2=$str2;
  446. $test2=str_replace(" ","",$test2);
  447. $test2=str_replace(" ","",$test2);
  448. $test2 = preg_replace('/\s*/', '', $test2);
  449. return $test2;
  450. }
  451. ?>