diff --git a/docs/en/joinus/README.md b/docs/en/joinus/README.md
index 39e7a8899a..c04138a30c 100644
--- a/docs/en/joinus/README.md
+++ b/docs/en/joinus/README.md
@@ -96,7 +96,7 @@ ctx.state.data = {
itunes_item_image: '', // The item image
enclosure_url: '', // The item's audio link
enclosure_length: '', // The audio length, the unit is seconds.
- enclosure_type: '', // 'audio/mpeg' or 'audio/m4a' or others
+ enclosure_type: '', // 'audio/mpeg' or 'audio/x-m4a' or others
itunes_duration: '', // Covert the 'enclosure_length' to hh:mm:ss (1:33:52)
},
],
diff --git a/docs/joinus/README.md b/docs/joinus/README.md
index 1ee13ba0ec..156839294a 100644
--- a/docs/joinus/README.md
+++ b/docs/joinus/README.md
@@ -96,7 +96,7 @@ ctx.state.data = {
itunes_item_image: '', // 图像
enclosure_url: '', // 音频链接
enclosure_length: '', // 时间戳 (播放长度) , 一般是秒数
- enclosure_type: '', // [.mp3就填'audio/mpeg'] [.m4a就填'audio/m4a'], 或其他类型.
+ enclosure_type: '', // [.mp3就填'audio/mpeg'] [.m4a就填'audio/x-m4a'], 或其他类型.
itunes_duration: '', // 由enclosure_length转换为 时:分:秒
},
],
diff --git a/routes/bilibili/partion-ranking.js b/routes/bilibili/partion-ranking.js
index 37f5edf80a..0173f8bbbb 100644
--- a/routes/bilibili/partion-ranking.js
+++ b/routes/bilibili/partion-ranking.js
@@ -40,7 +40,7 @@ module.exports = async (ctx) => {
item = {
title: `${item.title} - ${item.author}`,
- description: `${item.description}
Tags:${item.tag}`,
+ description: `${item.description}
Tags:${item.tag}`,
pubDate: new Date(item.pubdate).toUTCString(),
link: item.arcurl,
};
diff --git a/routes/ximalaya/album.js b/routes/ximalaya/album.js
index 29adc01c57..3e4fde7077 100644
--- a/routes/ximalaya/album.js
+++ b/routes/ximalaya/album.js
@@ -1,67 +1,77 @@
const axios = require('../../utils/axios');
const baseUrl = 'http://www.ximalaya.com';
-const axios_ins = axios.create({
- responseType: 'json',
-});
+const axios_ins = axios.create({});
module.exports = async (ctx) => {
const id = ctx.params.id; // 专辑id
- const AlbumInfoApi = `http://www.ximalaya.com/revision/album?albumId=${id}`; // 专辑数据的API
+ const TrackInfoApi = 'http://mobile.ximalaya.com/v1/track/baseInfo?device=android&trackId=';
+ const AlbumInfoApi = `https://www.ximalaya.com/revision/album?albumId=${id}`; // 专辑数据的API
const AlbumInfoResponse = await axios_ins.get(AlbumInfoApi);
- const albuminfo = AlbumInfoResponse.data.data.mainInfo; // 专辑数据
const authorinfo = AlbumInfoResponse.data.data.anchorInfo; // 作者数据
- const trackinfo = AlbumInfoResponse.data.data.tracksInfo; // tracks数据
+ const author = authorinfo.anchorName;
+ const author_intro = authorinfo.personalIntroduction;
- const classify = albuminfo.crumbs.categoryPinyin; // 专辑分类的拼音
- const album_category = albuminfo.crumbs.categoryTitle; // 专辑分类
+ const albuminfo = AlbumInfoResponse.data.data.mainInfo; // 专辑数据
+ const album_title = albuminfo.albumTitle; // 专辑标题
+ const album_cover = albuminfo.cover.split('&')[0];
+ const classify = albuminfo.crumbs.categoryPinyin; // 专辑分类
+ const album_category = albuminfo.crumbs.categoryTitle; // 专辑分类名字
+ const album_intro = albuminfo.richIntro; // 专辑介绍
+ const album_desc = author_intro + '
' + album_intro;
const albumUrl = '/' + classify + '/' + id + '/'; // 某分类的链接
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;
- const PlayInfoApi = `http://mobile.ximalaya.com/mobile/v1/album/track?albumId=${id}&pageSize=${tracks_count}`; // 声音播放数据
- const PlayInfoResponse = await axios_ins.get(PlayInfoApi);
-
- const playList = PlayInfoResponse.data.data.list;
+ const tracksinfo = AlbumInfoResponse.data.data.tracksInfo; // 专辑数据
+ const playList = tracksinfo.tracks;
const resultItems = await Promise.all(
playList.map(async (item) => {
const title = item.title;
- let desc = title + '查看收听提示: ' + baseUrl + albumUrl + item.trackId;
- if (ispaid) {
- desc = title + ' [付费内容无法收听] 原文链接: ' + baseUrl + albumUrl + item.trackId;
+ const trackId = item.trackId;
+ const trackUrl = item.url;
+ const link = baseUrl + trackUrl;
+
+ let resultItem = {};
+ const value = await ctx.cache.get(link);
+ if (value) {
+ resultItem = JSON.parse(value);
+ } else {
+ const track = await axios_ins.get(TrackInfoApi + trackId);
+ 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;
+ if (ispaid) {
+ desc = '
[付费内容无法收听]
' + track_item.intro;
+ }
+
+ resultItem = {
+ title: title,
+ link: link,
+ description: desc,
+ pubDate: new Date(track_item.createdAt).toUTCString(),
+ itunes_item_image: track_item.coverLarge.split('&')[0],
+ enclosure_url: track_item.downloadUrl,
+ enclosure_length: enclosure_length,
+ enclosure_type: 'audio/aac',
+ itunes_duration: itunes_duration,
+ };
+
+ ctx.cache.set(link, JSON.stringify(resultItem), 24 * 60 * 60);
}
- 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,
- description: desc,
- pubDate: new Date(item.createdAt).toUTCString(),
- itunes_item_image: item.coverLarge,
- enclosure_url: item.playPathAacv224,
- enclosure_length: enclosure_length,
- enclosure_type: 'audio/m4a',
- itunes_duration: itunes_duration,
- };
return Promise.resolve(resultItem);
})
);
ctx.state.data = {
title: `${album_title}`,
- link: `${album_url}`,
+ link: `${baseUrl + albumUrl}`,
description: album_desc,
- image: album_cover_url,
- itunes_author: album_author,
+ image: album_cover,
+ itunes_author: author,
itunes_category: album_category,
item: resultItems,
};