From 9f25a187eef4b61ec11d5199b118a3c32a2df087 Mon Sep 17 00:00:00 2001 From: Artin Date: Fri, 28 Sep 2018 10:57:08 +0800 Subject: [PATCH] =?UTF-8?q?ximalaya:=20=E4=BF=AE=E5=A4=8D=E8=8E=B7?= =?UTF-8?q?=E5=8F=96=E6=9D=A1=E7=9B=AE=E5=B0=81=E9=9D=A2=E5=87=BA=E9=94=99?= =?UTF-8?q?=20(#803)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- docs/en/joinus/README.md | 9 ++++----- routes/ximalaya/album.js | 22 ++++++++++++++++++---- 2 files changed, 22 insertions(+), 9 deletions(-) diff --git a/docs/en/joinus/README.md b/docs/en/joinus/README.md index 7b6478e76..85030f4e3 100644 --- a/docs/en/joinus/README.md +++ b/docs/en/joinus/README.md @@ -123,18 +123,17 @@ ctx.state.data = { Reference article: - [Create a podcast - Apple](https://help.apple.com/itc/podcasts_connect/?lang=en#/itca5b22233a) -- [Podcast best practices - Apple](https://help.apple.com/itc/podcasts_connect/?lang=en#/itc2b3780e76) -- Itunes podcast XML generator : https://codepen.io/jon-walstedt/pen/jsIup -- Feed Validation Service : https://podba.se/validate/?url=https://rsshub.app/ximalaya/album/299146/ +- Itunes podcast XML generator : https://codepen.io/jon-walstedt/pen/jsIup +- Feed Validation Service : https://podba.se/validate/?url=https://rsshub.app/ximalaya/album/299146/ -these datas can make your podcast subscribeable: +these 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 + itunes_category: '', // Channel category image: '', // Channel's image description: '', // The feed description item: [ diff --git a/routes/ximalaya/album.js b/routes/ximalaya/album.js index 9ed5a3789..244c4a9d3 100644 --- a/routes/ximalaya/album.js +++ b/routes/ximalaya/album.js @@ -2,6 +2,13 @@ const axios = require('../../utils/axios'); const baseUrl = 'http://www.ximalaya.com'; const axios_ins = axios.create({}); +const getFormatCode = function(strValue) { + return strValue + .replace(/(\r\n)+/g, '
') + .replace(/(\n)+/g, '
') + .replace(/(\s)+/g, ' '); +}; + module.exports = async (ctx) => { const id = ctx.params.id; // 专辑id @@ -15,7 +22,7 @@ module.exports = async (ctx) => { const albuminfo = AlbumInfoResponse.data.data.mainInfo; // 专辑数据 const album_title = albuminfo.albumTitle; // 专辑标题 - const album_cover = albuminfo.cover.split('&')[0]; + const album_cover = albuminfo.cover.split('!')[0]; const classify = albuminfo.crumbs.categoryPinyin; // 专辑分类 const album_category = albuminfo.crumbs.categoryTitle; // 专辑分类名字 const album_intro = albuminfo.richIntro; // 专辑介绍 @@ -42,9 +49,16 @@ module.exports = async (ctx) => { const track_item = track.data; const enclosure_length = track_item.duration; // 时间长度:单位(秒) const itunes_duration = Math.floor(enclosure_length / 3600) + ':' + Math.floor((enclosure_length % 3600) / 60) + ':' + (((enclosure_length % 3600) % 60) / 100).toFixed(2).slice(-2); - let desc = track_item.intro; + let desc = getFormatCode(track_item.intro); + let itunes_item_image = ''; if (ispaid) { - desc = '
[付费内容无法收听]
' + track_item.intro; + desc = ' [付费内容无法收听] 请打开网页收听: ' + `${link}` + '
' + desc; + } + + if (typeof track_item.coverLarge === 'undefined') { + itunes_item_image = albuminfo.cover.split('!')[0]; + } else { + itunes_item_image = track_item.coverLarge.split('!')[0]; } resultItem = { @@ -52,7 +66,7 @@ module.exports = async (ctx) => { link: link, description: desc, pubDate: new Date(track_item.createdAt).toUTCString(), - itunes_item_image: track_item.coverLarge.split('&')[0], + itunes_item_image: itunes_item_image, enclosure_url: track_item.playPathAacv224, enclosure_length: enclosure_length, enclosure_type: 'audio/x-m4a',