-
Notifications
You must be signed in to change notification settings - Fork 296
Expand file tree
/
Copy path金牌 ᵈᶻ.php
More file actions
228 lines (200 loc) · 7.96 KB
/
金牌 ᵈᶻ.php
File metadata and controls
228 lines (200 loc) · 7.96 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
<?php
require_once __DIR__ . '/lib/spider.php';
class Spider extends BaseSpider {
private $HOST = 'https://m.jiabaide.cn';
private $UA = 'Mozilla/5.0 (Linux; Android 11; Pixel 5) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/90.0.4430.91 Mobile Safari/537.36';
/**
* 核心签名算法:sha1(md5(query_string))
*/
private function getSignedHeaders($params) {
$t = (string)(time() * 1000); // 毫秒时间戳
$params['key'] = 'cb808529bae6b6be45ecfab29a4889bc';
$params['t'] = $t;
// 构建 QueryString
$query = [];
foreach ($params as $k => $v) {
$query[] = "$k=$v";
}
$queryStr = implode('&', $query);
// 签名逻辑:SHA1(MD5(str))
$sign = sha1(md5($queryStr));
return [
'User-Agent: ' . $this->UA,
'Referer: ' . $this->HOST,
't: ' . $t,
'sign: ' . $sign
];
}
public function homeContent($filter) {
// 5. 首页 (获取分类与筛选)
$typeUrl = $this->HOST . '/api/mw-movie/anonymous/get/filer/type';
$typeRes = $this->fetch($typeUrl, [], $this->getSignedHeaders([]));
$typeArr = json_decode($typeRes, true)['data'] ?? [];
$classes = [];
foreach ($typeArr as $item) {
$classes[] = ['type_id' => (string)$item['typeId'], 'type_name' => $item['typeName']];
}
// 获取筛选
$filterUrl = $this->HOST . '/api/mw-movie/anonymous/v1/get/filer/list';
$filterRes = $this->fetch($filterUrl, [], $this->getSignedHeaders([]));
$filterData = json_decode($filterRes, true)['data'] ?? [];
$filters = [];
$nameMap = [
'typeList' => ['key' => 'type', 'name' => '类型'],
'plotList' => ['key' => 'class', 'name' => '剧情'],
'districtList' => ['key' => 'area', 'name' => '地区'],
'languageList' => ['key' => 'lang', 'name' => '语言'],
'yearList' => ['key' => 'year', 'name' => '年份']
];
foreach ($classes as $cls) {
$tid = $cls['type_id'];
$fRow = [];
foreach ($nameMap as $apiKey => $cfg) {
if (!isset($filterData[$tid][$apiKey])) continue;
$values = [['n' => '全部', 'v' => '']];
foreach ($filterData[$tid][$apiKey] as $v) {
$values[] = [
'n' => $v['itemText'],
'v' => ($apiKey === 'typeList') ? $v['itemValue'] : $v['itemText']
];
}
$fRow[] = ['key' => $cfg['key'], 'name' => $cfg['name'], 'value' => $values];
}
// 增加排序
$fRow[] = [
'key' => 'by', 'name' => '排序',
'value' => [
['n' => '最近更新', 'v' => '1'],
['n' => '添加时间', 'v' => '2'],
['n' => '人气高低', 'v' => '3'],
['n' => '评分高低', 'v' => '4']
]
];
$filters[$tid] = $fRow;
}
// 首页推荐
$hotUrl = $this->HOST . '/api/mw-movie/anonymous/home/hotSearch';
$hotRes = $this->fetch($hotUrl, [], $this->getSignedHeaders([]));
$hotVods = json_decode($hotRes, true)['data'] ?? [];
$list = [];
foreach (array_slice($hotVods, 0, 20) as $it) {
$list[] = [
'vod_id' => $it['vodId'],
'vod_name' => $it['vodName'],
'vod_pic' => $it['vodPic'],
'vod_remarks' => $it['vodRemarks']
];
}
return [
'class' => $classes,
'filters' => $filters,
'list' => $list
];
}
public function categoryContent($tid, $pg = 1, $filter = [], $extend = []) {
$params = [
'area' => $extend['area'] ?? '',
'lang' => $extend['lang'] ?? '',
'pageNum' => $pg,
'pageSize' => '30',
'sort' => $extend['by'] ?? '1',
'sortBy' => '1',
'type' => $extend['type'] ?? '',
'type1' => $tid,
'v_class' => $extend['class'] ?? '',
'year' => $extend['year'] ?? '',
];
$apiUrl = $this->HOST . '/api/mw-movie/anonymous/video/list?' . http_build_query($params);
$res = $this->fetch($apiUrl, [], $this->getSignedHeaders($params));
$json = json_decode($res, true);
$list = [];
if (isset($json['data']['list'])) {
foreach ($json['data']['list'] as $it) {
$list[] = [
'vod_id' => $it['vodId'],
'vod_name' => $it['vodName'],
'vod_pic' => $it['vodPic'],
'vod_remarks' => $it['vodRemarks'] . '_' . $it['vodDoubanScore']
];
}
}
$total = $json['data']['total'] ?? 0;
return $this->pageResult($list, $pg, $total, 30);
}
public function detailContent($ids) {
$id = is_array($ids) ? $ids[0] : $ids;
$params = ['id' => $id];
$apiUrl = $this->HOST . '/api/mw-movie/anonymous/video/detail?' . http_build_query($params);
$res = $this->fetch($apiUrl, [], $this->getSignedHeaders($params));
$json = json_decode($res, true);
$kvod = $json['data'] ?? null;
if (!$kvod) {
return ['list' => []];
}
$episodes = [];
if (!empty($kvod['episodeList'])) {
foreach ($kvod['episodeList'] as $it) {
// 存入格式:名字$ID@NID
$episodes[] = $it['name'] . '$' . $kvod['vodId'] . '@' . $it['nid'];
}
}
$vod = [
'vod_id' => $kvod['vodId'],
'vod_name' => $kvod['vodName'],
'vod_pic' => $kvod['vodPic'],
'type_name' => $kvod['vodClass'],
'vod_remarks' => $kvod['vodRemarks'],
'vod_content' => trim(strip_tags($kvod['vodContent'] ?? '')),
'vod_play_from' => '金牌线路',
'vod_play_url' => implode('#', $episodes)
];
return ['list' => [$vod]];
}
public function searchContent($key, $quick = false, $pg = 1) {
$page = max(1, intval($pg));
$params = [
'keyword' => $key,
'pageNum' => $pg,
'pageSize' => '30'
];
$apiUrl = $this->HOST . '/api/mw-movie/anonymous/video/searchByWordPageable?' . http_build_query($params);
$res = $this->fetch($apiUrl, [], $this->getSignedHeaders($params));
$json = json_decode($res, true);
$list = [];
if (isset($json['data']['list'])) {
foreach ($json['data']['list'] as $it) {
$list[] = [
'vod_id' => $it['vodId'],
'vod_name' => $it['vodName'],
'vod_pic' => $it['vodPic'],
'vod_remarks' => $it['vodRemarks']
];
}
}
$total = $json['data']['total'] ?? 0;
return $this->pageResult($list, $pg, $total, 30);
}
public function playerContent($flag, $id, $vipFlags = []) {
// 格式: vodId@nid
list($sid, $nid) = explode('@', $id);
$params = [
'clientType' => '3',
'id' => $sid,
'nid' => $nid
];
$apiUrl = $this->HOST . '/api/mw-movie/anonymous/v2/video/episode/url?' . http_build_query($params);
$res = $this->fetch($apiUrl, [], $this->getSignedHeaders($params));
$json = json_decode($res, true);
$playUrl = "";
if (!empty($json['data']['list'])) {
// 取第一个清晰度的 URL
$playUrl = $json['data']['list'][0]['url'];
}
return [
'parse' => 0,
'url' => $playUrl,
'header' => ['User-Agent' => $this->UA]
];
}
}
(new Spider())->run();