/
classification.ts
61 lines (54 loc) · 2.19 KB
/
classification.ts
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
import { Route } from '@/types';
import got from '@/utils/got';
export const route: Route = {
path: '/movie/classification/:sort?/:score?/:tags?',
categories: ['social-media'],
example: '/douban/movie/classification/R/7.5/Netflix,2020',
parameters: { sort: '排序方式,默认为U', score: '最低评分,默认不限制', tags: '分类标签,多个标签之间用英文逗号分隔,常见的标签到豆瓣电影的分类页面查看,支持自定义标签' },
features: {
requireConfig: false,
requirePuppeteer: false,
antiCrawler: false,
supportBT: false,
supportPodcast: false,
supportScihub: false,
},
name: '豆瓣电影分类',
maintainers: ['zzwab'],
handler,
description: `排序方式可选值如下
| 近期热门 | 标记最多 | 评分最高 | 最近上映 |
| -------- | -------- | -------- | -------- |
| U | T | S | R |`,
};
async function handler(ctx) {
const sort = ctx.req.param('sort') || 'U';
const score = Number.parseFloat(ctx.req.param('score')) || 0;
const tags = ctx.req.param('tags') || '';
const response = await got({
method: 'get',
url: `https://movie.douban.com/j/new_search_subjects?sort=${sort}&range=0,10&tags=${tags}&start=0`,
});
const movies = response.data.data;
return {
title: `豆瓣电影分类${score ? `超过 ${score} 分的` : ''}影视`,
link: `https://movie.douban.com/tag/#/?sort=U&range=0,10&tags=`,
item: movies
.map((item) => {
const itemScore = Number.parseFloat(item.rate) || 0;
return itemScore >= score
? {
title: item.title,
description: `标题:${item.title}<br>
评分:${item.rate}<br>
导演:${item.directors.join(' / ')}<br>
主演:${item.casts.join(' / ')}<br>
<img src="${item.cover}">`,
link: item.url,
}
: null;
})
.filter(Boolean),
allowEmpty: true,
};
}