diff --git a/assets/radar-rules.js b/assets/radar-rules.js index 39c11e072b..f760a9cf3e 100644 --- a/assets/radar-rules.js +++ b/assets/radar-rules.js @@ -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: [ diff --git a/docs/en/multimedia.md b/docs/en/multimedia.md index 79ef68b38b..872ccab45f 100644 --- a/docs/en/multimedia.md +++ b/docs/en/multimedia.md @@ -116,6 +116,12 @@ Refer to [Pornhub F.A.Qs](https://help.pornhub.com/hc/en-us/articles/36004432703 +## Trakt.tv + +### User Collection + + + ## YouTube Refer to [#youtube](/en/social-media.html#youtube) diff --git a/docs/multimedia.md b/docs/multimedia.md index cf16ff51af..7bb71502cb 100644 --- a/docs/multimedia.md +++ b/docs/multimedia.md @@ -621,6 +621,12 @@ pageClass: routes +## Trakt.tv + +### 用户收藏 + + + ## YouTube 见 [#youtube](/social-media.html#youtube) diff --git a/lib/router.js b/lib/router.js index c2a1b544f2..078c3792d5 100644 --- a/lib/router.js +++ b/lib/router.js @@ -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')); diff --git a/lib/routes/trakt/collection.js b/lib/routes/trakt/collection.js new file mode 100644 index 0000000000..a97eaaa165 --- /dev/null +++ b/lib/routes/trakt/collection.js @@ -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: ``, + pubDate, + }; + }), + }; +};