Skip to content

Commit 4b89a57

Browse files
authored
feat: Add new source: 豆瓣热门电影 (#237)
* feat: Add new source 豆瓣热门电影 * refactor: Simplify the if condition
1 parent 5627cbe commit 4b89a57

6 files changed

Lines changed: 67 additions & 4 deletions

File tree

public/icons/douban.png

5.55 KB
Loading

server/glob.d.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,7 @@ declare module 'glob:./sources/{*.ts,**/index.ts}' {
88
export const chongbuluo: typeof import('./sources/chongbuluo')
99
export const cls: typeof import('./sources/cls/index')
1010
export const coolapk: typeof import('./sources/coolapk/index')
11+
export const douban: typeof import('./sources/douban')
1112
export const douyin: typeof import('./sources/douyin')
1213
export const fastbull: typeof import('./sources/fastbull')
1314
export const gelonghui: typeof import('./sources/gelonghui')

server/sources/douban.ts

Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
interface HotMoviesRes {
2+
category: string
3+
tags: []
4+
items: MovieItem[]
5+
recommend_tags: []
6+
total: number
7+
type: string
8+
}
9+
10+
interface MovieItem {
11+
rating: {
12+
count: number
13+
max: number
14+
star_count: number
15+
value: number
16+
}
17+
title: string
18+
pic: {
19+
large: string
20+
normal: string
21+
}
22+
is_new: boolean
23+
uri: string
24+
episodes_info: string
25+
card_subtitle: string
26+
type: string
27+
id: string
28+
}
29+
30+
export default defineSource(async () => {
31+
const baseURL = "https://m.douban.com/rexxar/api/v2/subject/recent_hot/movie"
32+
const res: HotMoviesRes = await myFetch(baseURL, {
33+
headers: {
34+
Referer: "https://movie.douban.com/",
35+
Accept: "application/json, text/plain, */*",
36+
},
37+
})
38+
return res.items.map(movie => ({
39+
id: movie.id,
40+
title: `《${movie.title}${movie.card_subtitle}`,
41+
url: `https://movie.douban.com/subject/${movie.id}`,
42+
extra: {
43+
hover: movie.card_subtitle,
44+
},
45+
}))
46+
})

shared/pinyin.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -41,5 +41,6 @@
4141
"juejin": "xitujuejin",
4242
"ifeng": "fenghuangwang-redianzixun",
4343
"chongbuluo-latest": "chongbuluo-zuixin",
44-
"chongbuluo-hot": "chongbuluo-zuire"
44+
"chongbuluo-hot": "chongbuluo-zuire",
45+
"douban": "douban-remendianying"
4546
}

shared/pre-sources.ts

Lines changed: 9 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -413,6 +413,14 @@ export const originSources = {
413413
},
414414
},
415415
},
416+
"douban": {
417+
name: "豆瓣",
418+
column: "china",
419+
title: "热门电影",
420+
color: "green",
421+
type: "hottest",
422+
home: "https://www.douban.com",
423+
},
416424
} as const satisfies Record<string, OriginSource>
417425

418426
export function genSources() {
@@ -461,10 +469,8 @@ export function genSources() {
461469
_.filter(([_, v]) => {
462470
if (v.disable === "cf" && process.env.CF_PAGES) {
463471
return false
464-
} else if (v.disable === true) {
465-
return false
466472
} else {
467-
return true
473+
return v.disable !== true
468474
}
469475
}),
470476
)

shared/sources.json

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -472,5 +472,14 @@
472472
"color": "green",
473473
"interval": 1800000,
474474
"title": "最热"
475+
},
476+
"douban": {
477+
"title": "热门电影",
478+
"name": "豆瓣",
479+
"type": "hottest",
480+
"column": "china",
481+
"home": "https://www.douban.com",
482+
"color": "green",
483+
"interval": 600000
475484
}
476485
}

0 commit comments

Comments
 (0)