feat(route): add trakt collection (#6985)

Co-authored-by: NeverBehave <gayhub@never.pet>
This commit is contained in:
hoilc
2021-03-01 23:45:33 -05:00
committed by GitHub
co-authored by NeverBehave
parent 033ca9b2c1
commit acd6772528
5 changed files with 59 additions and 0 deletions
+11
View File
@@ -2731,6 +2731,17 @@
},
],
},
'trakt.tv': {
_name: 'Trakt.tv',
'.': [
{
title: '用户收藏',
docs: 'https://docs.rsshub.app/multimedia.html#trakt-tv-yong-hu-shou-cang',
source: ['/users/:username/collection/:type/added', '/users/:username/collection'],
target: (params) => `/trakt/collection/${params.username}/${params.type || 'all'}`,
},
],
},
'eagle.cool': {
_name: 'Eagle',
cn: [
+6
View File
@@ -116,6 +116,12 @@ Refer to [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/36004432703
<RouteEn author="fallenhh" example="/soundcloud/tracks/angeart" path="/soundcloud/tracks/:user" :paramsDesc="['User name']" />
## Trakt.tv
### User Collection
<Route author="hoilc" example="/trakt/collection/tomyangsh/movies" path="/trakt/collection/:username/:type?" :paramsDesc="['Username','Collection type, can be `movies`,`shows`,`episodes`,`all`, default to `all`']" radar="1" rssbud="1" />
## YouTube
Refer to [#youtube](/en/social-media.html#youtube)
+6
View File
@@ -621,6 +621,12 @@ pageClass: routes
<Route author="sakamossan" example="/yahoo-jp-tv/%E8%8A%B1%E6%BE%A4%E9%A6%99%E8%8F%9C" path="/yahoo-jp-tv/:query" :paramsDesc="['搜索查询']"/>
## Trakt.tv
### 用户收藏
<Route author="hoilc" example="/trakt/collection/tomyangsh/movies" path="/trakt/collection/:username/:type?" :paramsDesc="['用户名','收藏类型,可选`movies`,`shows`,`episodes`,`all`,默认为`all`']" radar="1" rssbud="1" />
## YouTube
见 [#youtube](/social-media.html#youtube)
+3
View File
@@ -3975,6 +3975,9 @@ router.get('/iyiou', require('./routes/iyiou'));
// 香港商报
router.get('/hkcd/pdf', require('./routes/hkcd/pdf'));
// Trakt.tv
router.get('/trakt/collection/:username/:type?', require('./routes/trakt/collection'));
// 全球化智库
router.get('/ccg/:category?', require('./routes/ccg/index'));
+33
View File
@@ -0,0 +1,33 @@
const got = require('@/utils/got');
const cheerio = require('cheerio');
module.exports = async (ctx) => {
const url = `https://trakt.tv/users/${ctx.params.username}/collection/${ctx.params.type || 'all'}/added`;
const response = await got(url);
const $ = cheerio.load(response.data);
const title = $('title').html();
const list = $('.posters .grid-item').get();
ctx.state.data = {
title: title,
link: url,
item: list.map((single) => {
const item = $(single);
const title = item.find('.titles > h3').text();
const link = item.find('meta[itemprop="url"]').attr('content');
const poster = item
.find('.poster > meta')
.attr('content');
const pubDate = new Date(item.find('.titles .format-date').attr('data-date'));
return {
title,
link,
author: ctx.params.username,
description: `<img src="${poster}" style="max-width: 100%;" >`,
pubDate,
};
}),
};
};