-
Notifications
You must be signed in to change notification settings - Fork 159
/
Copy path16wMV[听].js
212 lines (212 loc) · 7.09 KB
/
16wMV[听].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
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
var mv_list = [];
var authors = [];
const starAuthors = '周杰伦,汪苏泷,李荣浩,蔡依林,筷子兄弟,凤凰传奇,程响';
const alphabetList = Array.from({length: 26}, (_, index) => {
const uppercase = String.fromCharCode(65 + index); // 大写字母 A-Z
const lowercase = String.fromCharCode(97 + index); // 小写字母 a-z
// return {n: uppercase, v: lowercase};
return {n: uppercase, v: uppercase};
});
alphabetList.unshift({n: '全部', v: ''});
var rule = {
类型: '搜索',
title: '16wMV',
alias: '16wMV搜索引擎',
desc: '仅搜索源纯js写法',
host: 'hiker://empty',
url: '',
searchUrl: 'hiker://empty',
headers: {
'User-Agent': 'PC_UA',
},
searchable: 1,
quickSearch: 0,
filterable: 1,
double: true,
play_parse: true,
limit: 100,
class_name: '歌手',
class_url: 'author',
filter: {
author: [
{key: 'letters', name: '首字母', value: alphabetList}
]
},
// 推荐样式
hikerListCol: 'icon_round_2',
// 分类列表样式
hikerClassListCol: 'avatar',
// home_flag: '3-0-S',
home_flag: '3',
// class_flag: '3-11-S',
class_flag: '1',
预处理: async function () {
let t1 = (new Date()).getTime();
let _url = rule.params;
log(`传入参数:${_url}`);
mv_list = (await request(_url)).split('\n').map((it) => {
it = it.trim();
let _tt = it.split(',')[0];
let _uu = it.split(',')[1];
if (_tt.includes('-')) {
return {title: _tt, url: _uu, author: _tt.split('-')[0].trim() || '未知', name: _tt.split('-')[1].trim()}
} else {
return {title: _tt, url: _uu, author: '未知', name: _tt.trim()}
}
});
authors = [...new Set(mv_list.filter(it => !it.author.includes('+')).map(it => it.author.trim()))];
// log(mv_list.slice(0, 3));
// authors = naturalSort(authors, 'author'); // 不要使用排序,数据太大了排不了
authors = authors.sort((a, b) => a.localeCompare(b, 'zh-CN', {numeric: true, sensitivity: 'base'}));
let t2 = (new Date()).getTime();
log(`读取文件并转json耗时:${t2 - t1}毫秒`);
},
lazy: async function (flag, id, flags) {
return {parse: 0, url: id}
},
proxy_rule: async function (params) {
let {input, proxyPath, getProxyUrl} = this;
let resp_not_found = [404, 'text/plain', 'not found'];
return resp_not_found
},
action: async function (action, value) {
if (action === 'only_search') {
return '此源为纯搜索源,你直接全局搜索这个源或者使用此页面的源内搜索就好了'
}
if (action === '源内搜索') {
let content = JSON.parse(value);
return JSON.stringify({
action: {
actionId: '__self_search__',
skey: '', //目标源key,可选,未设置或为空则使用当前源
name: '搜索: ' + content.wd,
tid: content.wd,
flag: '1',
msg: '源内搜索'
}
});
}
return `没有动作:${action}的可执行逻辑`
},
推荐: async function () {
let {publicUrl} = this;
let searchIcon = urljoin(publicUrl, './images/icon_cookie/搜索.jpg');
let selectData = starAuthors.split(',').map(it => `${it}:=${it}`).join(',');
return [{
vod_id: 'only_search',
vod_name: '这是个纯搜索源哦',
vod_pic: searchIcon,
vod_remarks: `歌手数量:${authors.length}`,
vod_tag: 'action'
},
{
vod_id: JSON.stringify({
actionId: '源内搜索',
id: 'wd',
type: 'input',
title: '源内搜索',
tip: '请输入搜索内容',
value: '',
selectData: selectData
}),
vod_name: '源内搜索',
vod_pic: searchIcon,
vod_tag: 'action',
}
]
},
一级: async function (tid, pg, filter, extend) {
let {MY_FL} = this;
let d = [];
if (tid === 'author') {
let _f = rule.limit * (pg - 1);
let _t = rule.limit * pg;
let _d = [];
let _authors = authors;
// log('_f:', _f, '_t:', _t);
// log('MY_FL.letters:', MY_FL.letters);
if (MY_FL.letters) {
_authors = authors.filter(_author => getFirstLetter(_author).startsWith(MY_FL.letters));
}
_d = _authors.slice(_f, _t);
_d.forEach(it => {
d.push({
vod_name: it,
vod_id: 'author#' + it,
});
});
return d;
}
// 仅搜索作者允许翻页,其他情况只有3个固定按钮
if (Number(pg) > 1) {
return []
}
d.push({
vod_name: '按歌手搜索',
vod_id: 'author#' + tid,
vod_remarks: '',
});
d.push({
vod_name: '按歌名搜索',
vod_id: 'name#' + tid,
vod_remarks: '',
});
d.push({
vod_name: '全名模糊搜索',
vod_id: 'all#' + tid,
vod_remarks: '',
});
return d
},
二级: async function () {
let {orId} = this;
let _stype = orId.split('#')[0];
let _sname = orId.split('#')[1];
let _vname = '';
let data = [];
switch (_stype) {
case 'author':
// log('_sname:', _sname);
_vname = '按歌手搜索';
data = mv_list.filter(it => it.author.includes(_sname));
break;
case 'name':
_vname = '按歌名搜索';
data = mv_list.filter(it => it.name.includes(_sname));
break;
default:
_vname = '全名模糊搜索';
data = mv_list.filter(it => it.title.includes(_sname));
break;
}
return {
vod_id: orId,
vod_name: `${_vname}:${_sname}`,
vod_remarks: `共计${data.length}`,
vod_play_from: '道长源内搜索',
vod_play_url: data.map(it => it.title + '$' + it.url).join('#')
}
},
搜索: async function (wd, quick, pg) {
if (Number(pg) > 1) {
return []
}
let d = [];
d.push({
vod_name: '按歌手搜索:' + wd,
vod_id: 'author#' + wd,
vod_remarks: '',
});
d.push({
vod_name: '按歌名搜索:' + wd,
vod_id: 'name#' + wd,
vod_remarks: '',
});
d.push({
vod_name: '全名模糊搜索:' + wd,
vod_id: 'all#' + wd,
vod_remarks: '',
});
return d
}
}