forked from DIYgod/RSSHub
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
feat(route): 添加豆瓣电影-即将上映 (DIYgod#16757)
* 添加豆瓣电影即将上映 * 切换到art模板,添加radar * fix example route
- Loading branch information
Showing
2 changed files
with
95 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,68 @@ | ||
import { Route } from '@/types'; | ||
import got from '@/utils/got'; | ||
import { getCurrentPath } from '@/utils/helpers'; | ||
import { art } from '@/utils/render'; | ||
import path from 'node:path'; | ||
|
||
const __dirname = getCurrentPath(import.meta.url); | ||
|
||
export const route: Route = { | ||
path: '/movie/coming', | ||
categories: ['social-media'], | ||
example: '/douban/movie/coming', | ||
features: { | ||
requireConfig: false, | ||
requirePuppeteer: false, | ||
antiCrawler: false, | ||
supportBT: false, | ||
supportPodcast: false, | ||
supportScihub: false, | ||
}, | ||
name: '电影即将上映', | ||
maintainers: ['reonokiy'], | ||
radar: [ | ||
{ | ||
title: '豆瓣电影-即将上映', | ||
source: ['movie.douban.com/coming'], | ||
target: '/movie/coming', | ||
}, | ||
], | ||
handler, | ||
}; | ||
const renderDescription = (info: { title?: string; cover_url?: string; pubdate?: string[]; intro?: string; directors?: string[]; actors?: string[]; genres: string[]; wish_count?: number | string }) => | ||
art(path.join(__dirname, '../templates/movie_coming.art'), info); | ||
|
||
async function handler(ctx) { | ||
const response = await got({ | ||
method: 'get', | ||
url: 'https://m.douban.com/rexxar/api/v2/movie/coming_soon', | ||
headers: { | ||
Referer: 'https://m.douban.com/movie/', | ||
}, | ||
}); | ||
|
||
ctx.set('json', { response }); | ||
|
||
return { | ||
title: '豆瓣电影-即将上映', | ||
link: 'https://movie.douban.com/coming', | ||
item: response.data?.subjects?.map((item) => ({ | ||
title: item?.title, | ||
link: item?.url, | ||
guid: item?.url, | ||
description: renderDescription({ | ||
title: item?.title, | ||
intro: item?.intro, | ||
pubdate: item?.pubdate, | ||
cover_url: item?.cover_url, | ||
directors: item?.directors?.map((d) => d?.name), | ||
actors: item?.actors?.map((a) => a?.name), | ||
genres: item?.genres, | ||
wish_count: item?.wish_count, | ||
}), | ||
category: item?.genres, | ||
itunes_item_image: item?.cover_url, | ||
upvotes: item?.wish_count, | ||
})), | ||
}; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
{{if cover_url && title}} | ||
<img src="{{cover_url}}" alt="{{title}}" referrerpolicy="no-referrer"> | ||
{{/if}} | ||
|
||
<h2>电影信息</h2> | ||
<ul> | ||
{{if directors}} | ||
<li>导演:{{directors.join(', ')}}</li> | ||
{{/if}} | ||
{{if actors}} | ||
<li>演员:{{actors.join(', ')}}</li> | ||
{{/if}} | ||
{{if genres}} | ||
<li>类型:{{genres.join(' / ')}}</li> | ||
{{/if}} | ||
{{if pubdate}} | ||
<li>上映日期:{{pubdate.join(' / ')}}</li> | ||
{{/if}} | ||
{{if wish_count}} | ||
<li>想看:{{wish_count}}</li> | ||
{{/if}} | ||
</ul> | ||
|
||
{{ if intro }} | ||
<h2>剧情简介</h2> | ||
<p>{{ intro }}</p> | ||
{{/if}} |