diff --git a/docs/README.md b/docs/README.md index 9a809583f9..d8613fd2a7 100644 --- a/docs/README.md +++ b/docs/README.md @@ -924,6 +924,16 @@ GitHub 官方也提供了一些 RSS: ::: +### 字幕组(ZiMuZu.tv) + +::: tip 提示 + +跟官方提供的 RSS 相比:官方使用了不规范的 magnet 字段,无法被 BT 客户端识别并自动下载,其他数据相同 + +::: + + + ### Sankaku Complex diff --git a/docs/en/joinus/README.md b/docs/en/joinus/README.md index 185a2d1abb..8dd09f190c 100644 --- a/docs/en/joinus/README.md +++ b/docs/en/joinus/README.md @@ -129,30 +129,17 @@ ctx.state.data = { }; ``` -#### make a podcast feed +#### Podcast feed -these datas can make your podcast subscribeable: +Used for audio type feed, these **additional** datas can make your podcast subscribeable: ```js ctx.state.data = { - title: '', // The feed title - link: '', // The feed link itunes_author: '', // The channel's author, you must fill this data. itunes_category: '', // Channel category image: '', // Channel's image - description: '', // The feed description - language: '', // The language of the channel item: [ - // An item of the feed { - title: '', // The item title - author: '', // Author of the article - category: '', // Article category - // category: [''], // Multiple category - description: '', // The article summury or content - pubDate: '', // The item publishing datetime - guid: '', // The item unique identifier, optional, default to the item link below. - link: '', // The item link itunes_item_image: '', // The item image enclosure_url: '', // The item's audio link enclosure_length: '', // The audio length, the unit is seconds. @@ -162,6 +149,22 @@ ctx.state.data = { }; ``` +#### BT feed + +Used for download type feed, these **additional** datas can make your BT client subscribeable and can auto download: + +```js +ctx.state.data = { + item: [ + { + enclosure_url: '', // Magnet URI + enclosure_length: '', // The audio length, the unit is seconds, optional + enclosure_type: 'application/x-bittorrent', // Fixed to 'application/x-bittorrent' + }, + ], +}; +``` + ## Join the discussion diff --git a/docs/joinus/README.md b/docs/joinus/README.md index db3f3da5d2..c9cb8c8331 100644 --- a/docs/joinus/README.md +++ b/docs/joinus/README.md @@ -323,39 +323,42 @@ ctx.state.data = { }; ``` -#### 制作播客 Podcast Feed +##### 播客源 -这些字段能使你的 RSS 被泛用型播客软件订阅: +用于音频类 RSS,**额外**添加这些字段能使你的 RSS 被泛用型播客软件订阅: ```js ctx.state.data = { - title: '', // 项目的标题 - link: '', // 指向项目的链接 itunes_author: '', // 主播名字, 必须填充本字段才会被视为播客 itunes_category: '', // 播客分类 image: '', // 专辑图片, 作为播客源时必填 - description: '', // 描述项目 - language: '', // 频道语言 item: [ - // 其中一篇文章或一项内容 { - title: '', // 文章标题 - author: '', // 文章作者 - category: '', // 文章分类 - // category: [''], // 多个分类 - description: '', // 文章摘要或全文 - pubDate: '', // 文章发布时间 - guid: '', // 文章唯一标示, 必须唯一, 可选, 默认为文章链接 - link: '', // 指向文章的链接 itunes_item_image: '', // 图像 enclosure_url: '', // 音频链接 - enclosure_length: '', // 时间戳 (播放长度) , 一般是秒数 + enclosure_length: '', // 时间戳 (播放长度) , 一般是秒数,可选 enclosure_type: '', // [.mp3就填'audio/mpeg'] [.m4a就填'audio/x-m4a'] [.mp4就填'video/mp4'], 或其他类型. }, ], }; ``` +##### BT 源 + +用于下载类 RSS,**额外**添加这些字段能使你的 RSS 被 BT 客户端识别并自动下载: + +```js +ctx.state.data = { + item: [ + { + enclosure_url: '', // 磁力链接 + enclosure_length: '', // 时间戳 (播放长度) , 一般是秒数,可选 + enclosure_type: 'application/x-bittorrent', // 固定为 'application/x-bittorrent' + }, + ], +}; +``` + ### 步骤 2: 添加脚本路由 在 [/router.js](https://github.com/DIYgod/RSSHub/blob/master/router.js) 里添加路由: diff --git a/router.js b/router.js index daad0204a0..4c05eeeb21 100644 --- a/router.js +++ b/router.js @@ -885,4 +885,7 @@ router.get('/cpu/home', require('./routes/cpu/home')); router.get('/cpu/jwc', require('./routes/cpu/jwc')); router.get('/cpu/yjsy', require('./routes/cpu/yjsy')); +// 字幕组 +router.get('/zimuzu/resource/:id', require('./routes/zimuzu/resource')); + module.exports = router; diff --git a/routes/zimuzu/resource.js b/routes/zimuzu/resource.js new file mode 100644 index 0000000000..ecfee9b14d --- /dev/null +++ b/routes/zimuzu/resource.js @@ -0,0 +1,24 @@ +const Parser = require('rss-parser'); +const parser = new Parser({ + customFields: { + item: ['magnet'], + }, +}); + +module.exports = async (ctx) => { + const id = ctx.params.id; + const feed = await parser.parseURL(`http://diaodiaode.me/rss/feed/${id}`); + console.log(feed); + feed.items.map((item) => { + item.enclosure_url = item.magnet; + item.enclosure_type = 'application/x-bittorrent'; + return item; + }); + + ctx.state.data = { + title: feed.title, + link: feed.link, + description: feed.description, + item: feed.items, + }; +}; diff --git a/views/rss.art b/views/rss.art index 6cc0ec52ee..dd68fe46a1 100644 --- a/views/rss.art +++ b/views/rss.art @@ -30,7 +30,7 @@ {{ $value.guid || $value.link }} {{ $value.link }} {{ if $value.itunes_item_image }}{{ /if }} - {{ if $value.enclosure_url }}{{ /if }} + {{ if $value.enclosure_url }}{{ /if }} {{ if $value.itunes_duration }}{{ $value.itunes_duration }} {{ /if }} {{ if $value.author }}{{ /if }} {{ if typeof $value.category === 'string' }}