Skip to content

Commit fb6b721

Browse files
committed
update:优化分类接口机制
1 parent 4af1509 commit fb6b721

File tree

3 files changed

+34
-3
lines changed

3 files changed

+34
-3
lines changed

Diff for: controllers/api.js

+5-2
Original file line numberDiff line numberDiff line change
@@ -72,10 +72,13 @@ export default (fastify, options, done) => {
7272
const filter = 'filter' in query ? query.filter : 1;
7373
const resultHome = await drpy.home(modulePath, env, filter);
7474
const resultHomeVod = await drpy.homeVod(modulePath, env);
75-
const result = {
75+
let result = {
7676
...resultHome,
77-
list: resultHomeVod,
77+
// list: resultHomeVod,
7878
};
79+
if (Array.isArray(resultHomeVod) && resultHomeVod.length > 0) {
80+
Object.assign(result, {list: resultHomeVod})
81+
}
7982

8083
reply.send(result);
8184

Diff for: docs/updateRecord.md

+3
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
11
# drpyS更新记录
2+
23
### 20241208
34

45
更新至V1.0.5
@@ -7,6 +8,8 @@
78
2. drpyS支持class_name,class_url,filter等属性了
89
3. 星芽短剧新增筛选
910
4. 新增源老白故事
11+
5. 优化首页分类接口机制,支持在class_parse里返回list,然后推荐留空。
12+
6. 推荐函数注入this变量
1013

1114
### 20241207
1215

Diff for: libs/drpyS.js

+26-1
Original file line numberDiff line numberDiff line change
@@ -314,6 +314,12 @@ async function invokeMethod(filePath, env, method, args = [], injectVars = {}) {
314314
return {}
315315
}
316316
break
317+
case '推荐':
318+
injectVars = await homeVodParse(moduleObject, ...args);
319+
if (!injectVars) {
320+
return {}
321+
}
322+
break
317323
case '一级':
318324
injectVars = await cateParse(moduleObject, ...args);
319325
if (!injectVars) {
@@ -522,12 +528,31 @@ async function homeParseAfter(d, _type, injectVars) {
522528
d.class = classes;
523529
}
524530
if (!d.filters) {
525-
d.filters = filters
531+
d.filters = filters;
532+
}
533+
if (!d.list) {
534+
d.list = [];
526535
}
527536
d.class = d.class.filter(it => !cate_exclude || !(new RegExp(cate_exclude).test(it.type_name)));
528537
return d
529538
}
530539

540+
async function homeVodParse(rule) {
541+
let url = rule.homeUrl;
542+
const jsp = new jsoup(url);
543+
return {
544+
TYPE: 'home',
545+
input: url,
546+
MY_URL: url,
547+
HOST: rule.host,
548+
double: rule.double,
549+
jsp: jsp,
550+
pdfh: jsp.pdfh,
551+
pd: jsp.pd,
552+
pdfa: jsp.pdfa,
553+
}
554+
}
555+
531556
async function cateParse(rule, tid, pg, filter, extend) {
532557
log(tid, pg, filter, extend);
533558
let url = rule.url.replaceAll('fyclass', tid);

0 commit comments

Comments
 (0)