-
Notifications
You must be signed in to change notification settings - Fork 285
Expand file tree
/
Copy pathpush_agent.js
More file actions
462 lines (461 loc) · 23.6 KB
/
push_agent.js
File metadata and controls
462 lines (461 loc) · 23.6 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
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
/*
@header({
searchable: 0,
filterable: 0,
quickSearch: 0,
title: '推送',
'类型': '影视',
lang: 'ds'
})
*/
const {getHtml} = $.require('./_lib.request.js')
const {
formatPlayUrl,
} = misc;
const aliTranscodingCache = {};
const aliDownloadingCache = {};
var rule = {
title: '推送',
host: '',
class_name: '推送',
class_url: 'push',
url: '',
play_parse: true,
推荐: async function () {
let {publicUrl} = this;
let icon = urljoin(publicUrl, './images/icon_cookie/推送.jpg');
return [{
vod_id: 'https://vdse.bdstatic.com//628ca08719cef5987ea2ae3c6f0d2386.mp4',
vod_name: '测试推送直链',
vod_pic: icon,
vod_remarks: '纯二级源'
}]
},
一级: async function (tid, pg, filter, extend) {
let {MY_CATE, MY_PAGE, input} = this;
return []
},
二级: async function (ids) {
let {input, orId, publicUrl} = this;
let playform = []
let playurls = []
// log('[push_agent] orId:', orId);
input = decodeURIComponent(orId);
// 清理输入,只保留有效的URL部分,移除可能的日志内容
input = input.replace(/\[\d{4}-\d{2}-\d{2}.*$/, '').trim();
let icon = urljoin(publicUrl, './images/icon_cookie/推送.jpg');
let vod = {
vod_pic: icon,
vod_id: orId,
vod_content: 'DS推送:道长&秋秋倾情打造',
}
let playPans = [];
if (/^[\[{]/.test(input.trim())) {
try {
let push_vod = JSON.parse(input);
push_vod = Array.isArray(push_vod) ? push_vod[0] : push_vod;
vod.vod_actor = push_vod.actor || push_vod.vod_actor || '';
vod.vod_content = push_vod.content || push_vod.vod_content || '';
vod.vod_director = push_vod.director || push_vod.vod_director || '';
vod.vod_play_from = push_vod.from || push_vod.vod_play_from || '';
vod.vod_name = push_vod.name || push_vod.vod_name || '';
vod.vod_pic = push_vod.pic || push_vod.vod_pic || '';
vod.vod_play_url = push_vod.url || push_vod.vod_play_url || '';
// 推送json兼容依赖播放属性
vod.vod_play_api = push_vod.vod_play_api || '';
vod.vod_play_flag = push_vod.vod_play_flag || null;
vod.vod_play_index = push_vod.vod_play_index || null;
vod.vod_play_position = push_vod.vod_play_position || null;
log('[push_agent] vod success:', vod);
return vod
} catch (e) {
log('[push_agent] vod error:', e.message);
}
}
log('[push_agent] decode input:', input);
if (input.indexOf('@') > -1) {
let list = input.split('@');
// log(list);
for (let i = 0; i < list.length; i++) {
if (/pan.quark.cn|drive.uc.cn|www.alipan.com|www.aliyundrive.com|cloud.189.cn|yun.139.com|caiyun.139.com|www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com|pan.baidu.com/.test(list[i])) {
if (/pan.quark.cn/.test(list[i])) {
playPans.push(list[i]);
const shareData = Quark.getShareData(list[i]);
if (shareData) {
const videos = await Quark.getFilesByShareUrl(shareData);
if (videos.length > 0) {
playform.push('Quark-' + shareData.shareId);
playurls.push(videos.map((v) => {
const list = [shareData.shareId, v.stoken, v.fid, v.share_fid_token, v.subtitle ? v.subtitle.fid : '', v.subtitle ? v.subtitle.share_fid_token : ''];
return v.file_name + '$' + list.join('*');
}).join('#'))
} else {
playform.push('Quark-' + shareData.shareId);
playurls.push("资源已经失效,请访问其他资源")
}
}
}
if (/drive.uc.cn/.test(list[i])) {
playPans.push(list[i]);
const shareData = UC.getShareData(list[i]);
if (shareData) {
const videos = await UC.getFilesByShareUrl(shareData);
if (videos.length > 0) {
playform.push('UC-' + shareData.shareId);
playurls.push(videos.map((v) => {
const list = [shareData.shareId, v.stoken, v.fid, v.share_fid_token, v.subtitle ? v.subtitle.fid : '', v.subtitle ? v.subtitle.share_fid_token : ''];
return v.file_name + '$' + list.join('*');
}).join('#'))
} else {
playform.push('UC-' + shareData.shareId);
playurls.push("资源已经失效,请访问其他资源")
}
}
}
if (/www.alipan.com|www.aliyundrive.com/.test(list[i])) {
playPans.push(list[i]);
const shareData = Ali.getShareData(list[i]);
if (shareData) {
const videos = await Ali.getFilesByShareUrl(shareData);
log(videos)
if (videos.length > 0) {
playform.push('Ali-' + shareData.shareId);
playurls.push(videos.map((v) => {
const ids = [v.share_id, v.file_id, v.subtitle ? v.subtitle.file_id : ''];
return formatPlayUrl('', v.name) + '$' + ids.join('*');
}).join('#'))
} else {
playform.push('Ali-' + shareData.shareId);
playurls.push("资源已经失效,请访问其他资源")
}
}
}
if (/cloud.189.cn/.test(list[i])) {
playPans.push(list[i]);
let data = await Cloud.getShareData(list[i])
let hasValidFiles = false;
Object.keys(data).forEach(it => {
if (Array.isArray(data[it]) && data[it].length > 0) {
playform.push('Cloud-' + it)
const urls = data[it].map(item => item.name + "$" + [item.fileId, item.shareId].join('*')).join('#');
playurls.push(urls);
hasValidFiles = true;
}
})
if (!hasValidFiles) {
playform.push('Cloud-' + Date.now());
playurls.push("资源已经失效,请访问其他资源")
}
}
if (/yun.139.com|caiyun.139.com/.test(list[i])) {
playPans.push(list[i]);
let data = await Yun.getShareData(list[i])
let hasValidFiles = false;
Object.keys(data).forEach(it => {
if (Array.isArray(data[it]) && data[it].length > 0) {
playform.push('Yun-' + it)
const urls = data[it].map(item => item.name + "$" + [item.contentId, item.linkID].join('*')).join('#');
playurls.push(urls);
hasValidFiles = true;
}
})
if (!hasValidFiles) {
playform.push('Yun-' + Date.now());
playurls.push("资源已经失效,请访问其他资源")
}
}
if (/www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com/.test(list[i])) {
playPans.push(list[i]);
let shareData = await Pan.getShareData(list[i])
let videos = await Pan.getFilesByShareUrl(shareData)
let allVideos = Array.isArray(videos) ? videos : Object.values(videos).flat();
if (allVideos.length > 0) {
playform.push('Pan123-' + shareData);
playurls.push(allVideos.map((v) => {
const list = [v.ShareKey, v.FileId, v.S3KeyFlag, v.Size, v.Etag];
return v.FileName + '$' + list.join('*');
}).join('#'))
}
}
if (/pan.baidu.com/.test(list[i])) {
let data = await Baidu2.getShareData(list[i])
let vod_content_add = [vod.vod_content];
Object.keys(data).forEach((it, index) => {
playform.push('Baidu-' + Number(index + 1));
vod_content_add.push(it);
const urls = data[it].map(item => item.name + "$" + [item.path, item.uk, item.shareid, item.fsid].join('*')).join('#');
playurls.push(urls);
})
vod.vod_content = vod_content_add.join('\n');
}
} else {
playform.push('推送');
playurls.push("推送" + '$' + list[i])
}
}
} else if (/pan.quark.cn|drive.uc.cn|www.alipan.com|www.aliyundrive.com|cloud.189.cn|yun.139.com|caiyun.139.com|www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com|pan.baidu.com/.test(input)) {
if (/pan.quark.cn/.test(input)) {
playPans.push(input);
const shareData = Quark.getShareData(input);
if (shareData) {
const videos = await Quark.getFilesByShareUrl(shareData);
if (videos.length > 0) {
playform.push('Quark-' + shareData.shareId);
playurls.push(videos.map((v) => {
const list = [shareData.shareId, v.stoken, v.fid, v.share_fid_token, v.subtitle ? v.subtitle.fid : '', v.subtitle ? v.subtitle.share_fid_token : ''];
return v.file_name + '$' + list.join('*');
}).join('#'))
} else {
playform.push('Quark-' + shareData.shareId);
playurls.push("资源已经失效,请访问其他资源")
}
}
}
if (/drive.uc.cn/.test(input)) {
playPans.push(input);
const shareData = UC.getShareData(input);
if (shareData) {
const videos = await UC.getFilesByShareUrl(shareData);
if (videos.length > 0) {
playform.push('UC-' + shareData.shareId);
playurls.push(videos.map((v) => {
const list = [shareData.shareId, v.stoken, v.fid, v.share_fid_token, v.subtitle ? v.subtitle.fid : '', v.subtitle ? v.subtitle.share_fid_token : ''];
return v.file_name + '$' + list.join('*');
}).join('#'))
} else {
playform.push('UC-' + shareData.shareId);
playurls.push("资源已经失效,请访问其他资源")
}
}
}
if (/www.alipan.com|www.aliyundrive.com/.test(input)) {
playPans.push(input);
const shareData = Ali.getShareData(input);
if (shareData) {
const videos = await Ali.getFilesByShareUrl(shareData);
log(videos);
if (videos.length > 0) {
playform.push('Ali-' + shareData.shareId);
playurls.push(videos.map((v) => {
const ids = [v.share_id, v.file_id, v.subtitle ? v.subtitle.file_id : ''];
return formatPlayUrl('', v.name) + '$' + ids.join('*');
}).join('#'))
} else {
playform.push('Ali-' + shareData.shareId);
playurls.push("资源已经失效,请访问其他资源")
}
}
}
if (/cloud.189.cn/.test(input)) {
playPans.push(input);
let data = await Cloud.getShareData(input)
let hasValidFiles = false;
Object.keys(data).forEach(it => {
if (Array.isArray(data[it]) && data[it].length > 0) {
playform.push('Cloud-' + it)
const urls = data[it].map(item => item.name + "$" + [item.fileId, item.shareId].join('*')).join('#');
playurls.push(urls);
hasValidFiles = true;
}
})
if (!hasValidFiles) {
playform.push('Cloud-' + Date.now());
playurls.push("资源已经失效,请访问其他资源")
}
}
if (/yun.139.com|caiyun.139.com/.test(input)) {
playPans.push(input);
let data = await Yun.getShareData(input)
let hasValidFiles = false;
Object.keys(data).forEach(it => {
if (Array.isArray(data[it]) && data[it].length > 0) {
playform.push('Yun-' + it)
const urls = data[it].map(item => item.name + "$" + [item.contentId, item.linkID].join('*')).join('#');
playurls.push(urls);
hasValidFiles = true;
}
})
if (!hasValidFiles) {
playform.push('Yun-' + Date.now());
playurls.push("资源已经失效,请访问其他资源")
}
}
if (/www.123684.com|www.123865.com|www.123912.com|www.123pan.com|www.123pan.cn|www.123592.com/.test(input)) {
playPans.push(input);
let shareData = await Pan.getShareData(input)
let videos = await Pan.getFilesByShareUrl(shareData)
let allVideos = Array.isArray(videos) ? videos : Object.values(videos).flat();
if (allVideos.length > 0) {
playform.push('Pan123-' + shareData);
playurls.push(allVideos.map((v) => {
const list = [v.ShareKey, v.FileId, v.S3KeyFlag, v.Size, v.Etag];
return v.FileName + '$' + list.join('*');
}).join('#'));
}
}
if (/pan.baidu.com/.test(input)) {
let data = await Baidu2.getShareData(input)
let vod_content_add = [vod.vod_content];
Object.keys(data).forEach((it, index) => {
playform.push('Baidu-' + Number(index + 1));
vod_content_add.push(it);
const urls = data[it].map(item => item.name + "$" + [item.path, item.uk, item.shareid, item.fsid].join('*')).join('#');
playurls.push(urls);
})
vod.vod_content = vod_content_add.join('\n');
}
} else {
playform.push('推送');
playurls.push("推送" + '$' + input)
}
vod.vod_play_from = playform.join("$$$")
vod.vod_play_url = playurls.join("$$$")
vod.vod_play_pan = playPans.join("$$$")
return vod
},
lazy: async function (flag, id, flags) {
let {input, mediaProxyUrl} = this;
const urls = [];
// 如果id包含完整的URL(比如playParse直接传入完整URL),尝试从中提取云盘链接
if (id && id.includes('http')) {
// 使用正则表达式提取有效的云盘URL
const urlRegex = /https?:\/\/[\w.-]+(?:\.[\w\.-]+)+[\w\-\._~:/?#[\]@!\$&'\(\)\*\+,;=.]+/g;
const matches = id.match(urlRegex);
if (matches && matches.length > 0) {
input = matches[0];
}
}
if (flag === '推送') {
if (tellIsJx(input)) {
return {parse: 1, jx: 1, url: input}
} else {
// 确保返回parse: 0和正确的URL格式,避免前端创建新的播放列表
return {parse: 0, url: ["原画", input]}
}
} else if (/Quark-|UC-|Ali-|Cloud-|Yun-|Pan123-|Baidu-/.test(flag)) {
const ids = id.split('*');
let UCDownloadingCache = {};
let downUrl = ''
if (flag.startsWith('Quark-')) {
log("夸克网盘解析开始")
const down = await Quark.getDownload(ids[0], ids[1], ids[2], ids[3], true);
const headers = {
// 'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/130.0.0.0 Safari/537.36 QuarkPC/4.5.5.535 quark-cloud-drive/2.5.40 Channel/pckk_other_ch',
// 'origin': 'https://pan.quark.cn',
// 'referer': 'https://pan.quark.cn/',
'Cookie': ENV.get('quark_cookie')
};
down.forEach((t) => {
if(t.url!==undefined){
urls.push("猫"+t.name, `http://127.0.0.1:5575/proxy?thread=${ENV.get('thread') || 6}&chunkSize=256&url=` + encodeURIComponent(t.url));
urls.push(t.name, t.url+ "#isVideo=true##fastPlayMode##threads=20#")
}
});
const transcoding = (await Quark.getLiveTranscoding(ids[0], ids[1], ids[2], ids[3])).filter((t) => t.accessable);
transcoding.forEach((t) => {
urls.push(t.resolution === 'low' ? "流畅" : t.resolution === 'high' ? "高清" : t.resolution === 'super' ? "超清" : t.resolution, t.video_info.url+ "#isVideo=true##fastPlayMode##threads=20#")
});
// urls.push("原画", down.download_url + '#fastPlayMode##threads=10#');
// urls.push("原代服", mediaProxyUrl + `?thread=${ENV.get('thread') || 6}&form=urlcode&randUa=1&url=` + encodeURIComponent(down.download_url) + '&header=' + encodeURIComponent(JSON.stringify(headers)));
// if (ENV.get('play_local_proxy_type', '1') === '2') {
// urls.push("原代本", `http://127.0.0.1:7777/?thread=${ENV.get('thread') || 6}&form=urlcode&randUa=1&url=` + encodeURIComponent(down.download_url) + '&header=' + encodeURIComponent(JSON.stringify(headers)));
// } else {
// urls.push("原代本", `http://127.0.0.1:5575/proxy?thread=${ENV.get('thread') || 6}&chunkSize=256&url=` + encodeURIComponent(down.download_url));
// }
// const transcoding = (await Quark.getLiveTranscoding(ids[0], ids[1], ids[2], ids[3])).filter((t) => t.accessable);
// transcoding.forEach((t) => {
// urls.push(t.resolution === 'low' ? "流畅" : t.resolution === 'high' ? "高清" : t.resolution === 'super' ? "超清" : t.resolution, t.video_info.url)
// });
return {
parse: 0,
url: urls,
header: headers
}
}
if (flag.startsWith('UC-')) {
console.log("UC网盘解析开始");
if (!UCDownloadingCache[ids[1]]) {
const down = await UC.getDownload(ids[0], ids[1], ids[2], ids[3], true);
if (down) UCDownloadingCache[ids[1]] = down;
}
const downCache = UCDownloadingCache[ids[1]];
return await UC.getLazyResult(downCache, mediaProxyUrl)
}
if (flag.startsWith('Ali-')) {
const transcoding_flag = {
UHD: "4K 超清",
QHD: "2K 超清",
FHD: "1080 全高清",
HD: "720 高清",
SD: "540 标清",
LD: "360 流畅"
};
log("网盘解析开始");
const down = await Ali.getDownload(ids[0], ids[1], flag === 'down');
urls.push("原画", down.url + "#isVideo=true##ignoreMusic=true#");
urls.push("极速原画", down.url + "#fastPlayMode##threads=10#");
const transcoding = (await Ali.getLiveTranscoding(ids[0], ids[1])).sort((a, b) => b.template_width - a.template_width);
transcoding.forEach((t) => {
if (t.url !== '') {
urls.push(transcoding_flag[t.template_id], t.url);
}
});
return {
parse: 0,
url: urls,
header: {
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/131.0.0.0 Safari/537.36',
'Referer': 'https://www.aliyundrive.com/',
},
}
}
if (flag.startsWith('Cloud-')) {
log("天翼云盘解析开始")
const url = await Cloud.getShareUrl(ids[0], ids[1]);
urls.push("原画", url + "#isVideo=true#")
return {
parse: 0,
url: urls
}
}
if (flag.startsWith('Yun-')) {
log('移动云盘解析开始')
const url = await Yun.getSharePlay(ids[0], ids[1])
urls.push("原画", url + "#isVideo=true#")
return {
parse: 0,
url: urls
}
}
if (flag.startsWith('Pan123-')) {
log('盘123解析开始')
const url = await Pan.getDownload(ids[0], ids[1], ids[2], ids[3], ids[4])
urls.push("原画", url)
let data = await Pan.getLiveTranscoding(ids[0], ids[1], ids[2], ids[3], ids[4])
data.forEach((item) => {
urls.push(item.name, item.url)
})
return {
parse: 0,
url: urls
}
}
if (flag.startsWith('Baidu-')) {
log('百度网盘开始解析')
//App原画不转存
let url = await Baidu2.getAppShareUrl(ids[0], ids[1], ids[2], ids[3])
urls.push("原画", url + "#isVideo=true##fastPlayMode##threads=10#")
return {
parse: 0,
url: urls,
header: {
"User-Agent": 'netdisk;P2SP;2.2.91.136;android-android;',
"Cookie": ENV.get('baidu_cookie'),
}
}
}
} else {
return input
}
},
}