From e7662ebec02950b2ecbe68f0c3ebc79fb3d0a288 Mon Sep 17 00:00:00 2001 From: Artin Date: Fri, 24 Aug 2018 11:57:15 +0800 Subject: [PATCH] =?UTF-8?q?ximalaya:=20=E6=9B=B4=E6=96=B0item=E5=86=85?= =?UTF-8?q?=E5=AE=B9=EF=BC=8C=E9=80=82=E9=85=8Ditunes=E6=92=AD=E5=AE=A2=20?= =?UTF-8?q?(#524)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit fix:#523 --- docs/README.md | 6 +++--- docs/joinus/README.md | 37 +++++++++++++++++++++++++++++++++++++ router.js | 1 + routes/ximalaya/album.js | 30 ++++++++++++++++++------------ views/rss.art | 2 ++ 5 files changed, 61 insertions(+), 15 deletions(-) diff --git a/docs/README.md b/docs/README.md index 30a42ab1e4..36b1d6788e 100644 --- a/docs/README.md +++ b/docs/README.md @@ -1512,10 +1512,10 @@ language,语言,可在 [Trending 页](https://github.com/trending/javascript ::: warning 注意 **付费内容可获取更新但无法收听** -目前[输出格式](https://docs.rsshub.app/#输出格式)中标明的格式只有 rss 支持,也就是说你**不能使用**以下链接来订阅播客: +目前支持泛用型播客订阅的[输出格式](https://docs.rsshub.app/#输出格式)中标明的格式只有 rss 支持,也就是说你**只能使用**以下链接来订阅播客: -- https://rsshub.app/ximalaya/album/299146.atom -- https://rsshub.app/ximalaya/album/299146.json +- https://rsshub.app/ximalaya/album/299146/ +- https://rsshub.app/ximalaya/album/299146.rss ::: diff --git a/docs/joinus/README.md b/docs/joinus/README.md index bf043e9d3c..eb5dbbad03 100644 --- a/docs/joinus/README.md +++ b/docs/joinus/README.md @@ -66,6 +66,43 @@ ctx.state.data = { }; ``` +
如果你想制作播客馈送型RSS,点这儿
+ +播客馈送是指向 XML 格式 RSS(丰富站点摘要)的网址(URL)。 + +这些多的字段能使你的 RSS 被泛用型播客软件订阅: + +- [Podcasts Connect 帮助 创建播客 - Apple](https://help.apple.com/itc/podcasts_connect/#/itca5b22233a) +- [Podcasts Connect 帮助 播客最佳做法 - Apple](https://help.apple.com/itc/podcasts_connect/#/itc2b3780e76) +- RSS 格式参考:https://codepen.io/jon-walstedt/pen/jsIup +- 播客验证:https://podba.se/validate/?url=https://rsshub.app/ximalaya/album/299146/ + +```js +ctx.state.data = { + title: '', // 项目的标题 + link: '', // 指向项目的链接 + itunes_author: '', // 主播名字,并且开启此项就认为该RSS是播客,会自动添加头部的xmlns + itunes_category: '',// 播客分类 + description: '', // 描述项目 + item: [ + // 其中一篇文章或一项内容 + { + title: '', // 文章标题 + description: '', // 文章内容或描述 + pubDate: '', // 文章发布时间 + guid: '', // 文章唯一标示,必须唯一,可选,默认为文章链接 + link: '', // 指向文章的链接 + itunes_item_image: '', // 图像 + enclosure_url: '', // 音频链接 + enclosure_length: '', // 时间戳(播放长度),一般是秒数 + enclosure_type: '', // [.mp3就填'audio/mpeg'] [.m4a就填'audio/m4a'] + itunes_duration: '', // 由enclosure_length转换为 时:分:秒 + }, + ], +}; +``` + +
## 参与讨论 1. [Telegram 群](https://t.me/rsshub) diff --git a/router.js b/router.js index 60e4f9b552..4dd97ea67b 100755 --- a/router.js +++ b/router.js @@ -296,6 +296,7 @@ router.get('/3dm/news', require('./routes/3dm/news_center')); // 喜马拉雅 router.get('/ximalaya/album/:classify/:id', require('./routes/ximalaya/album')); router.get('/ximalaya/album/:id', require('./routes/ximalaya/album')); + // EZTV router.get('/eztv/torrents/:imdb_id', require('./routes/eztv/imdb')); diff --git a/routes/ximalaya/album.js b/routes/ximalaya/album.js index 4a515b23bf..29adc01c57 100644 --- a/routes/ximalaya/album.js +++ b/routes/ximalaya/album.js @@ -14,15 +14,16 @@ module.exports = async (ctx) => { const authorinfo = AlbumInfoResponse.data.data.anchorInfo; // 作者数据 const trackinfo = AlbumInfoResponse.data.data.tracksInfo; // tracks数据 - const classify = albuminfo.crumbs.categoryPinyin; // 专辑分类 + const classify = albuminfo.crumbs.categoryPinyin; // 专辑分类的拼音 + const album_category = albuminfo.crumbs.categoryTitle; // 专辑分类 const albumUrl = '/' + classify + '/' + id + '/'; // 某分类的链接 - const ispaid = albuminfo.isPaid; - const album_title = albuminfo.albumTitle; - const album_url = baseUrl + albumUrl; - const album_desc = albuminfo.detailRichIntro + ' ' + authorinfo.anchorName + ' ' + authorinfo.personalIntroduction; + const ispaid = albuminfo.isPaid; // 是否需要付费 + const album_title = albuminfo.albumTitle; // 专辑标题 + const album_url = baseUrl + albumUrl; // 专辑链接 + const album_desc = authorinfo.anchorName + ' ' + authorinfo.personalIntroduction + '
' + albuminfo.detailRichIntro; const album_cover_url = albuminfo.cover.split('&')[0]; const album_author = authorinfo.anchorName; - const tracks_count = trackinfo.trackTotalCount + 1; + const tracks_count = trackinfo.trackTotalCount; const PlayInfoApi = `http://mobile.ximalaya.com/mobile/v1/album/track?albumId=${id}&pageSize=${tracks_count}`; // 声音播放数据 const PlayInfoResponse = await axios_ins.get(PlayInfoApi); @@ -31,12 +32,15 @@ module.exports = async (ctx) => { const resultItems = await Promise.all( playList.map(async (item) => { - let title = item.title; - let desc = '查看收听提示: ' + baseUrl + albumUrl + item.trackId; + const title = item.title; + let desc = title + '
查看收听提示:
' + baseUrl + albumUrl + item.trackId; if (ispaid) { - title = '[付费内容无法收听] ' + item.title; - desc = '[付费内容无法收听] 请到APP购买收听: ' + baseUrl + albumUrl + item.trackId; + desc = title + '
[付费内容无法收听] 原文链接:
' + baseUrl + albumUrl + item.trackId; } + const enclosure_length = item.duration; // 时间长度:单位(秒) + // itunes_duration格式:32:46 + const itunes_duration = Math.floor(enclosure_length / 3600) + ':' + Math.floor((enclosure_length % 3600) / 60) + ':' + (((enclosure_length % 3600) % 60) / 100).toFixed(2).slice(-2); + const resultItem = { title: title, link: baseUrl + albumUrl + item.trackId, @@ -44,8 +48,9 @@ module.exports = async (ctx) => { pubDate: new Date(item.createdAt).toUTCString(), itunes_item_image: item.coverLarge, enclosure_url: item.playPathAacv224, - enclosure_length: item.duration, - enclosure_type: 'audio/mpeg', + enclosure_length: enclosure_length, + enclosure_type: 'audio/m4a', + itunes_duration: itunes_duration, }; return Promise.resolve(resultItem); }) @@ -57,6 +62,7 @@ module.exports = async (ctx) => { description: album_desc, image: album_cover_url, itunes_author: album_author, + itunes_category: album_category, item: resultItems, }; }; diff --git a/views/rss.art b/views/rss.art index 6fa48c7c2a..a1aac4855f 100644 --- a/views/rss.art +++ b/views/rss.art @@ -11,6 +11,7 @@ RSSHub i@html.love (DIYgod) {{ if itunes_author }}{{ itunes_author}}{{ /if }} + {{ if itunes_category }}{{ /if }} zh-cn {{ if image }} @@ -30,6 +31,7 @@ {{ $value.link }} {{ if $value.itunes_item_image }}{{ /if }} {{ if $value.enclosure_url }}{{ /if }} + {{ if $value.itunes_duration }}{{ $value.itunes_duration }} {{ /if }} {{ if $value.author }}{{ /if }} {{ /each }}