@@ -22,10 +22,10 @@ protected function getHeaders($isJson = true) {
2222 public function homeContent ($ filter ) {
2323 $ classes = [
2424 ['type_id ' => '1 ' , 'type_name ' => '电影 ' ],
25- ['type_id ' => '2 ' , 'type_name ' => '逕オ隗�? ],
25+ ['type_id ' => '2 ' , 'type_name ' => '电视剧 ' ],
2626 ['type_id ' => '3 ' , 'type_name ' => '综艺 ' ],
2727 ['type_id ' => '5 ' , 'type_name ' => '动漫 ' ],
28- ['type_id ' => '4 ' , 'type_name ' => '郤ェ蠖慕? ],
28+ ['type_id ' => '4 ' , 'type_name ' => '纪录片 ' ],
2929 ['type_id ' => '6 ' , 'type_name ' => '短剧 ' ],
3030 ['type_id ' => '7 ' , 'type_name ' => '特别节目 ' ],
3131 ['type_id ' => '8 ' , 'type_name ' => '少儿内容 ' ]
@@ -36,7 +36,8 @@ public function homeContent($filter) {
3636
3737 return [
3838 'class ' => $ classes ,
39- 'list ' => $ data ['list ' ] ?? []
39+ 'list ' => $ data ['list ' ] ?? [],
40+ 'filters ' => (object )[]
4041 ];
4142 }
4243
@@ -58,21 +59,26 @@ public function categoryContent($tid, $pg = 1, $filter = [], $extend = []) {
5859 CURLOPT_POST => 1 ,
5960 CURLOPT_POSTFIELDS => json_encode ($ payload ),
6061 CURLOPT_HTTPHEADER => $ this ->getHeaders (),
61- CURLOPT_SSL_VERIFYPEER => false
62+ CURLOPT_SSL_VERIFYPEER => false ,
63+ CURLOPT_SSL_VERIFYHOST => false // 补全SSL校验关闭,避免HTTPS请求失败
6264 ]);
6365
64- $ jsonObj = json_decode ($ jsonStr , true );
66+ $ jsonObj = json_decode ($ jsonStr ?: ' {} ' , true );
6567 $ list = [];
6668
67- if (isset ($ jsonObj ['data ' ]['list ' ])) {
69+ if (isset ($ jsonObj ['data ' ]['list ' ]) && is_array ( $ jsonObj [ ' data ' ][ ' list ' ]) ) {
6870 $ list = $ this ->arr2vods ($ jsonObj ['data ' ]['list ' ]);
6971 }
72+ // 补全total参数,适配分页逻辑
73+ $ total = isset ($ jsonObj ['data ' ]['pagecount ' ]) ? $ jsonObj ['data ' ]['pagecount ' ] * 60 : 0 ;
7074
71- return $ this ->pageResult ($ list , $ pg , $ jsonObj [ ' data ' ][ ' pagecount ' ] ?? 0 );
75+ return $ this ->pageResult ($ list , $ pg , $ total , 60 );
7276 }
7377
7478 public function detailContent ($ ids ) {
75- $ id = is_array ($ ids ) ? $ ids [0 ] : $ ids ;
79+ $ id = is_array ($ ids ) ? ($ ids [0 ] ?? '' ) : $ ids ;
80+ if (empty ($ id )) return ['list ' => []]; // 空ID容错
81+
7682 $ apiUrl = $ this ->HOST . '/api.php/player/details/ ' ;
7783
7884 $ payload = ['id ' => (string )$ id ];
@@ -81,35 +87,36 @@ public function detailContent($ids) {
8187 CURLOPT_POST => 1 ,
8288 CURLOPT_POSTFIELDS => json_encode ($ payload ),
8389 CURLOPT_HTTPHEADER => $ this ->getHeaders (),
84- CURLOPT_SSL_VERIFYPEER => false
90+ CURLOPT_SSL_VERIFYPEER => false ,
91+ CURLOPT_SSL_VERIFYHOST => false
8592 ]);
8693
87- $ jsonObj = json_decode ($ jsonStr , true );
94+ $ jsonObj = json_decode ($ jsonStr ?: ' {} ' , true );
8895 $ vod = [];
8996
90- if (isset ($ jsonObj ['detailData ' ])) {
97+ if (isset ($ jsonObj ['detailData ' ]) && is_array ( $ jsonObj [ ' detailData ' ]) ) {
9198 $ d = $ jsonObj ['detailData ' ];
9299 $ vod = [
93- 'vod_id ' => $ d ['vod_id ' ],
94- 'vod_name ' => $ d ['vod_name ' ],
95- 'vod_pic ' => $ d ['vod_pic ' ],
96- 'vod_remarks ' => $ d ['vod_remarks ' ],
97- 'vod_year ' => $ d ['vod_year ' ],
98- 'vod_area ' => $ d ['vod_area ' ],
99- 'vod_actor ' => $ d ['vod_actor ' ],
100- 'vod_director ' => $ d ['vod_director ' ],
101- 'vod_content ' => $ d ['vod_content ' ],
102- 'vod_play_from ' => $ d ['vod_play_from ' ],
103- 'vod_play_url ' => $ d ['vod_play_url ' ],
104- 'type_name ' => $ d ['vod_class ' ]
100+ 'vod_id ' => $ d ['vod_id ' ] ?? '' ,
101+ 'vod_name ' => $ d ['vod_name ' ] ?? ' 未知影片 ' ,
102+ 'vod_pic ' => $ d ['vod_pic ' ] ?? '' ,
103+ 'vod_remarks ' => $ d ['vod_remarks ' ] ?? '' ,
104+ 'vod_year ' => $ d ['vod_year ' ] ?? '' ,
105+ 'vod_area ' => $ d ['vod_area ' ] ?? '' ,
106+ 'vod_actor ' => $ d ['vod_actor ' ] ?? '' ,
107+ 'vod_director ' => $ d ['vod_director ' ] ?? '' ,
108+ 'vod_content ' => $ d ['vod_content ' ] ?? ' 暂无影片介绍 ' ,
109+ 'vod_play_from ' => $ d ['vod_play_from ' ] ?? '' ,
110+ 'vod_play_url ' => $ d ['vod_play_url ' ] ?? '' ,
111+ 'type_name ' => $ d ['vod_class ' ] ?? ''
105112 ];
106113 }
107114
108115 return ['list ' => [$ vod ]];
109116 }
110117
111118 public function searchContent ($ key , $ quick = false , $ pg = 1 ) {
112- if ($ pg > 1 ) return $ this ->pageResult ([], $ pg , 0 );
119+ if (empty ( $ key ) || $ pg > 1 ) return $ this ->pageResult ([], $ pg , 0 );
113120
114121 $ apiUrl = $ this ->HOST . '/api.php/search/syntheticalSearch/ ' ;
115122 $ payload = ['keyword ' => $ key ];
@@ -118,23 +125,24 @@ public function searchContent($key, $quick = false, $pg = 1) {
118125 CURLOPT_POST => 1 ,
119126 CURLOPT_POSTFIELDS => json_encode ($ payload ),
120127 CURLOPT_HTTPHEADER => $ this ->getHeaders (),
121- CURLOPT_SSL_VERIFYPEER => false
128+ CURLOPT_SSL_VERIFYPEER => false ,
129+ CURLOPT_SSL_VERIFYHOST => false
122130 ]);
123131
124- $ jsonObj = json_decode ($ jsonStr , true );
132+ $ jsonObj = json_decode ($ jsonStr ?: ' {} ' , true );
125133 $ videos = [];
126134
127- if (isset ($ jsonObj ['data ' ])) {
135+ if (isset ($ jsonObj ['data ' ]) && is_array ( $ jsonObj [ ' data ' ]) ) {
128136 $ data = $ jsonObj ['data ' ];
129- if (!empty ($ data ['chasingFanCorrelation ' ])) {
137+ if (!empty ($ data ['chasingFanCorrelation ' ]) && is_array ( $ data [ ' chasingFanCorrelation ' ]) ) {
130138 $ videos = array_merge ($ videos , $ this ->arr2vods ($ data ['chasingFanCorrelation ' ]));
131139 }
132- if (!empty ($ data ['moviesCorrelation ' ])) {
140+ if (!empty ($ data ['moviesCorrelation ' ]) && is_array ( $ data [ ' moviesCorrelation ' ]) ) {
133141 $ videos = array_merge ($ videos , $ this ->arr2vods ($ data ['moviesCorrelation ' ]));
134142 }
135143 }
136144
137- return $ this ->pageResult ($ videos , $ pg , 1 );
145+ return $ this ->pageResult ($ videos , $ pg , count ( $ videos ) );
138146 }
139147
140148 public function playerContent ($ flag , $ id , $ vipFlags = []) {
@@ -157,7 +165,8 @@ public function playerContent($flag, $id, $vipFlags = []) {
157165 $ url = $ jsonObj ['data ' ]['url ' ];
158166 }
159167
160- // 蛹ケ驟咲ャャ荳画婿螟ァ遶吝シ蜷ッ隗」譫? if (preg_match('/(?:www\.iqiyi|v\.qq|v\.youku|www\.mgtv|www\.bilibili)\.com/', $url)) {
168+ // 匹配第三方大站开启解析
169+ if (preg_match ('/(?:www\.iqiyi|v\.qq|v\.youku|www\.mgtv|www\.bilibili)\.com/ ' , $ url )) {
161170 $ jx = 1 ;
162171 }
163172
@@ -175,15 +184,16 @@ public function playerContent($flag, $id, $vipFlags = []) {
175184 private function arr2vods ($ arr ) {
176185 $ videos = [];
177186 foreach ($ arr as $ i ) {
187+ // 修复符号错误
178188 $ remarks = ($ i ['vod_serial ' ] == '1 ' )
179- ? $ i ['vod_serial ' ] . '髮?
180- : '隸���? . ($ i ['vod_score ' ] ?? $ i ['vod_douban_score ' ] ?? '0 ' );
189+ ? $ i ['vod_serial ' ] . '集 '
190+ : '评分 ' . ($ i ['vod_score ' ] ?? $ i ['vod_douban_score ' ] ?? '0 ' );
181191
182192 $ videos [] = [
183- 'vod_id ' => $ i ['vod_id ' ],
184- 'vod_name ' => $ i ['vod_name ' ],
185- 'vod_pic ' => $ i ['vod_pic ' ],
186- 'vod_remarks ' => $ remarks
193+ 'vod_id ' => $ i ['vod_id ' ] ?? '' ,
194+ 'vod_name ' => $ i ['vod_name ' ] ?? '' ,
195+ 'vod_pic ' => $ i ['vod_pic ' ] ?? '' ,
196+ 'vod_remarks ' => $ remarks ?? ''
187197 ];
188198 }
189199 return $ videos ;
0 commit comments