feat: 为蜻蜓FM输出播客源 (#11061)

* feat: 为蜻蜓FM输出播客源

Signed-off-by: huyyi <nadph513@outlook.com>

* Update time process impl

Signed-off-by: huyyi <nadph513@outlook.com>

* refactor: migrate to v2

Signed-off-by: huyyi <nadph513@outlook.com>
This commit is contained in:
Jinkin
2022-10-13 22:15:42 +08:00
committed by GitHub
parent 62ac95fc70
commit 91775af1f4
7 changed files with 120 additions and 11 deletions
+9
View File
@@ -1469,6 +1469,15 @@ JavDB 有多个备用域名,本路由默认使用永久域名 <https://javdb.c
<Route author="nczitzk" example="/qingting/channel/293411" path="/qingting/channel/:id" :paramsDesc="['专辑id, 可在专辑页 URL 中找到']"/>
### 播客
<Route author="RookieZoe huyyi" example="/qingting/podcast/293411" path="/qingting/podcast/:id" :paramsDesc="['专辑id, 可在专辑页 URL 中找到']" radar="1" supportPodcast="1">
获取的播放URL有效期只有1天,需要开启播客APP的自动下载功能。
</Route>
## 秋爸日字
### 分类
+1 -1
View File
@@ -2747,7 +2747,7 @@ router.get('/qlwb/news', lazyloadRouteHandler('./routes/qlwb/news'));
router.get('/qlwb/city/:city', lazyloadRouteHandler('./routes/qlwb/city'));
// 蜻蜓FM
router.get('/qingting/channel/:id', lazyloadRouteHandler('./routes/qingting/channel'));
// router.get('/qingting/channel/:id', lazyloadRouteHandler('./routes/qingting/channel'));
// 金色财经
router.get('/jinse/lives', lazyloadRouteHandler('./routes/jinse/lives'));
@@ -1,22 +1,18 @@
const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const channelUrl = `https://i.qingting.fm/capi/v3/channel/${ctx.params.id}`;
let response = await got({
method: 'get',
url: channelUrl,
});
let response = await got(channelUrl);
const title = response.data.data.title;
const programUrl = `https://i.qingting.fm/capi/channel/${ctx.params.id}/programs/${response.data.data.v}?curpage=1&pagesize=10&order=asc`;
response = await got({
method: 'get',
url: programUrl,
});
response = await got(programUrl);
const items = response.data.data.programs.map((item) => ({
title: item.title,
link: `https://www.qingting.fm/channels/${ctx.params.id}/programs/${item.id}/`,
pubDate: new Date(item.update_time).toUTCString(),
pubDate: timezone(parseDate(item.update_time), +8),
}));
ctx.state.data = {
@@ -25,7 +21,7 @@ module.exports = async (ctx) => {
item: await Promise.all(
items.map((item) =>
ctx.cache.tryGet(item.link, async () => {
response = await got({ method: 'get', url: item.link });
response = await got(item.link);
const data = JSON.parse(response.data.match(/},"program":(.*?),"plist":/)[1]);
item.description = data.richtext;
return item;
+4
View File
@@ -0,0 +1,4 @@
module.exports = {
'/channel/:id': ['nczitzk'],
'/podcast/:id': ['RookieZoe', 'huyyi'],
};
+77
View File
@@ -0,0 +1,77 @@
const crypto = require('crypto');
const got = require('@/utils/got');
const timezone = require('@/utils/timezone');
const { parseDate } = require('@/utils/parse-date');
module.exports = async (ctx) => {
const channelUrl = `https://i.qingting.fm/capi/v3/channel/${ctx.params.id}`;
let response = await got({
method: 'get',
url: channelUrl,
headers: {
Referer: 'https://www.qingting.fm/',
},
});
const title = response.data.data.title;
const channel_img = response.data.data.thumbs['400_thumb'];
const authors = response.data.data.podcasters.map((author) => author.nick_name).join(',');
const desc = response.data.data.description;
const programUrl = `https://i.qingting.fm/capi/channel/${ctx.params.id}/programs/${response.data.data.v}?curpage=1&pagesize=10&order=asc`;
response = await got({
method: 'get',
url: programUrl,
headers: {
Referer: 'https://www.qingting.fm/',
},
});
const resultItems = await Promise.all(
response.data.data.programs.map((item) =>
ctx.cache.tryGet(`qingting:podcast:${ctx.params.id}:${item.id}`, async () => {
const link = `https://www.qingting.fm/channels/${ctx.params.id}/programs/${item.id}/`;
const path = `/audiostream/redirect/${ctx.params.id}/${item.id}?access_token=&device_id=MOBILESITE&qingting_id=&t=${new Date().getTime()}`;
const sign = crypto.createHmac('md5', 'fpMn12&38f_2e').update(path).digest('hex').toString();
const [detailRes, mediaRes] = await Promise.all([
got({
method: 'get',
url: link,
headers: {
Referer: 'https://www.qingting.fm/',
},
}),
got({
method: 'get',
url: `https://audio.qingting.fm${path}&sign=${sign}`,
headers: {
Referer: 'https://www.qingting.fm/',
},
}),
]);
const detail = JSON.parse(detailRes.data.match(/},"program":(.*?),"plist":/)[1]);
return {
title: item.title,
link,
itunes_item_image: item.cover,
itunes_duration: item.duration,
pubDate: timezone(parseDate(item.update_time), +8),
description: detail.richtext,
enclosure_url: mediaRes.url,
enclosure_type: 'audio/x-m4a',
};
})
)
);
ctx.state.data = {
title: `${title} - 蜻蜓FM`,
description: desc,
itunes_author: authors,
image: channel_img,
link: `https://www.qingting.fm/channels/${ctx.params.id}`,
item: resultItems,
};
};
+19
View File
@@ -0,0 +1,19 @@
module.exports = {
'qingting.fm': {
_name: '蜻蜓 FM',
'.': [
{
title: '专辑',
docs: 'https://docs.rsshub.app/multimedia.html#qing-ting-fm',
source: '/channels/:id',
target: '/qingting/channels/:id',
},
{
title: '播客',
docs: 'https://docs.rsshub.app/multimedia.html#qing-ting-fm',
source: '/channels/:id',
target: '/qingting/podcast/:id',
},
],
},
};
+4
View File
@@ -0,0 +1,4 @@
module.exports = (router) => {
router.get('/channel/:id', require('./channel'));
router.get('/podcast/:id', require('./podcast'));
};