rss: add zimuzu rss

This commit is contained in:
DIYgod
2018-11-29 11:05:45 +08:00
parent 05603048b5
commit 2269b3b7e7
6 changed files with 75 additions and 32 deletions
+10
View File
@@ -924,6 +924,16 @@ GitHub 官方也提供了一些 RSS:
:::
### 字幕组(ZiMuZu.tv)
::: tip 提示
跟官方提供的 RSS 相比:官方使用了不规范的 magnet 字段,无法被 BT 客户端识别并自动下载,其他数据相同
:::
<route name="影视" author="DIYgod" example="/zimuzu/resource/37031" path="/zimuzu/resource/:id" :paramsDesc="['影视 id,对应影视的 URL 中找到']"/>
### Sankaku Complex
<route name="Post" author="xyqfer" example="/sankakucomplex/post" path="/sankakucomplex/post"/>
+18 -15
View File
@@ -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'
},
],
};
```
</details>
## Join the discussion
+19 -16
View File
@@ -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) 里添加路由:
+3
View File
@@ -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;
+24
View File
@@ -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,
};
};
+1 -1
View File
@@ -30,7 +30,7 @@
<guid>{{ $value.guid || $value.link }}</guid>
<link>{{ $value.link }}</link>
{{ if $value.itunes_item_image }}<itunes:image href="{{ $value.itunes_item_image }}"/>{{ /if }}
{{ if $value.enclosure_url }}<enclosure url="{{ $value.enclosure_url }}" length="{{ $value.enclosure_length }}" type="{{ $value.enclosure_type }}" />{{ /if }}
{{ if $value.enclosure_url }}<enclosure url="{{ $value.enclosure_url }}" {{ if $value.enclosure_length }}length="{{ $value.enclosure_length }}"{{ /if }} {{ if $value.enclosure_type }}type="{{ $value.enclosure_type }}"{{ /if }} />{{ /if }}
{{ if $value.itunes_duration }}<itunes:duration>{{ $value.itunes_duration }}</itunes:duration> {{ /if }}
{{ if $value.author }}<author><![CDATA[{{ $value.author }}]]></author>{{ /if }}
{{ if typeof $value.category === 'string' }}