-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy pathPTT[优].js
146 lines (145 loc) · 5.95 KB
/
PTT[优].js
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
var rule = {
类型: '影视',//影视|听书|漫画|小说
title: 'PTT[优]',
host: 'https://ptt.red',
homeUrl: '/zh-cn',
url: '/zh-cn/p/fyclassfyfilter',
searchUrl: '/zh-cn/q/**?page=fypage',
searchable: 2,
quickSearch: 0,
filterable: 1,
filter: 'H4sIAAAAAAAAAO2X32saQRDH/5d76JMQ74d3Z8C/pIRytD6UpimYtBCCYCIGY9qoIbWVSltIqia1UUkQf+TSf8bdPf+Luml0ZtcsBFqf9HH3M+vOznxnvNnRdG316Y72Kr6trWqk0iLv+1pI2/Bex/H6nbf+Nn5nuMG3M/VRus63xwstGbrfPauNyvv3u0+8RNx79vJFzJjyUbVMu02ZR+B8vkV7tzK34Py3c/LFl7nuTA3opx+00pgxcMGgUWO3R7KBDfyq9dANYXDxQ4v0qzMG4CPJdIaDkmxgask1bvE3yKw9IF8PIcjT9WOCPLypssIkyCvPV0wT7s7Vh34FEIpsqUIOakDgxSzbpukMEAgmqxVJbwAERXG3QFMlIFE4k2sy/wIIihzNfh72DxDSsd/05idCIJmx14J7OryW9S+I/xEFAt2112ClIkIWvoudoFeZkYdTN0YWvDionQbNa3TKEBJKetfDgY+qZrJ+TEKNsGFN9LId9xKxuw1ETZmamBoyNTDVZapjGpZpGFE9KlE9iqkrUxdTR6YOprZMbUwjMo1gKseK1x5KBT06Jv08pGK6FlPB9tv0+JecClpJ0VJrcsHmm8RWbN3b3OIXrIU0Yy59kota0QJ50UHMhe7JESpI3Pd4QUIehZ7JEQhAaIbcDVdZCjxBS70vmN7NueldLWqUkZlS0JV6d02l3l1DqXekHOF/n1eJoSwFw1yWwsKVgjWvUjBstahttagdtagdtXLdpXIXTrkR3MX/afAIOleskEbTBeSbNS9FBI+n3S7N5hGCfIwbvHDKRt/2flFEigGLt+plP148Vdv2/1I1y/riZAzRCeopYfa0Iazs/HfQyQFy1LOng+bc/Flwimdt9NmS9kl3D3V4+EF2UiGX3xECRQblAt09REg9zDrWskwWrEySfwAneSZu2xMAAA==',
filter_url: '{% if fyclass !="1" %}{{fl.地区}}?page=fypage{% else %}{{fl.类型}}?page=fypage{{fl.地区|safe}}{% endif %}{{fl.年份|safe}}{{fl.排序|safe}}',
filter_def: {},
headers: {
'User-Agent': 'MOBILE_UA',
},
timeout: 5000,
// class_parse: '.nav-tabs&&a;a&&Text;a&&href;(\\d+)',
cate_exclude: '',
play_parse: true,
class_parse: async function () {
let {input, pdfa, pdfh, pd} = this;
let html = await request(input);
let d = [];
let data = pdfa(html, '.nav-tabs&&a');
data.forEach((it) => {
d.push({
type_name: pdfh(it, 'a&&Text'),
type_id: pd(it, 'a&&href').match(/(\d+)/)[1],
})
});
return {
class: d
}
},
lazy: async function () {
let {input} = this;
let html = await request(input);
let sdata = pdfh(html, '.container-fluid&&script&&Html');
let json = JSON.parse(sdata);
if (json.contentUrl) {
return {parse: 0, url: json.contentUrl, js: ''};
}
return input
},
double: false,
推荐: async function () {
let {input, pdfa, pdfh, pd} = this;
let html = await request(input);
let d = [];
let data = pdfa(html, '#videos&&.card:not(:has(.badge-success:contains(广告)))');
data.forEach((it) => {
d.push({
title: pdfh(it, 'a:eq(-1)&&Text'),
pic_url: pd(it, 'img&&src'),
desc: pdfh(it, '.badge-success&&Text'),
url: pd(it, 'a:eq(-1)&&href'),
})
});
return setResult(d)
},
一级: async function () {
let {input, pdfa, pdfh, pd} = this;
let html = await request(input);
let d = [];
let data = pdfa(html, '#videos&&.card:not(:has(.badge-success:contains(广告)))');
data.forEach((it) => {
d.push({
title: pdfh(it, 'a:eq(-1)&&Text'),
pic_url: pd(it, 'img&&src'),
desc: pdfh(it, '.badge-success&&Text'),
url: pd(it, 'a:eq(-1)&&href'),
})
});
return setResult(d)
},
二级: async function () {
let {input, pdfh, pd} = this;
let html = await request(input);
let data = html.split('node:')[1].split('},')[0] + '}';
data = data.trim();
let json = JSON.parse(data);
let VOD = {};
VOD.vod_name = json.title;
VOD.type_name = json.type;
VOD.vod_id = input;
VOD.vod_pic = urljoin(input, json.thumbnail);
VOD.vod_year = json.year;
VOD.vod_area = json._area;
VOD.vod_remarks = json.note;
VOD.vod_content = json.description;
VOD.vod_director = json.director;
VOD.vod_actor = json.actors;
let v_tabs = pdfa(html, '.nav-tabs&&li');
let v_tab_urls = v_tabs.map(it => pd(it, 'a&&href', input));
v_tabs = v_tabs.map(it => pdfh(it, 'a&&title'));
VOD.vod_play_from = v_tabs.join('$$$');
let lists = [];
let list1 = pdfa(html, '.mb-2.fullwidth&&a').map(it => pdfh(it, 'a&&Text') + '$' + pd(it, 'a&&href', input));
// log(list1);
lists.push(list1);
// log(v_tab_urls);
if (v_tab_urls.length > 1) {
let t1 = (new Date()).getTime();
let reqUrls = v_tab_urls.slice(1).map(it => {
return {
url: it,
options: {
timeout: 5000,
headers: rule.headers
}
}
});
let htmls = await batchFetch(reqUrls);
let t2 = (new Date()).getTime();
log(`批量请求二级 ${input} 耗时${t2 - t1}毫秒:`);
htmls.forEach((ht) => {
if (ht) {
let list0 = pdfa(ht, '.mb-2.fullwidth&&a').map(it => pdfh(it, 'a&&Text') + '$' + pd(it, 'a&&href', input));
lists.push(list0);
} else {
lists.push([]);
}
});
}
let playUrls = lists.map(it => it.join('#'));
VOD.vod_play_url = playUrls.join('$$$');
return VOD
},
搜索: async function () {
let {input, pdfa, pdfh, pd} = this;
let html = await request(input);
let d = [];
let data = pdfa(html, '#videos&&.card:not(:has(.badge-success:contains(广告)))');
data.forEach((it) => {
d.push({
title: pdfh(it, 'a:eq(-1)&&Text'),
pic_url: pd(it, 'img&&src'),
desc: pdfh(it, '.badge-success&&Text'),
url: pd(it, 'a:eq(-1)&&href'),
})
});
return setResult(d)
}
}