rss: add ncm/djradio (#333)
This commit is contained in:
@@ -48,6 +48,7 @@ RSSHub 是一个轻量、易于扩展的 RSS 生成器,可以给任何奇奇
|
||||
- 歌单歌曲
|
||||
- 用户歌单
|
||||
- 歌手专辑
|
||||
- 电台节目
|
||||
- 掘金
|
||||
- 分类
|
||||
- 简书
|
||||
|
||||
@@ -455,6 +455,14 @@ order: 排序方式,live_time 开播时间,online 人气
|
||||
|
||||
参数: id,歌手 id,可在歌手详情页 URL 中找到
|
||||
|
||||
### 电台节目
|
||||
|
||||
举例: [https://rsshub.app/ncm/djradio/347317067](https://rsshub.app/ncm/djradio/347317067)
|
||||
|
||||
路由: `/ncm/djradio/:id`
|
||||
|
||||
参数: id, 节目 id, 可在电台节目页 URL 中找到
|
||||
|
||||
## 掘金
|
||||
|
||||
### 分类
|
||||
|
||||
@@ -116,6 +116,7 @@ router.get('/weibo/keyword/:keyword', require('./routes/weibo/keyword'));
|
||||
router.get('/ncm/playlist/:id', require('./routes/ncm/playlist'));
|
||||
router.get('/ncm/user/playlist/:uid', require('./routes/ncm/userplaylist'));
|
||||
router.get('/ncm/artist/:id', require('./routes/ncm/artist'));
|
||||
router.get('/ncm/djradio/:id', require('./routes/ncm/djradio'));
|
||||
|
||||
// 掘金
|
||||
router.get('/juejin/category/:category', require('./routes/juejin/category'));
|
||||
|
||||
@@ -0,0 +1,60 @@
|
||||
const axios = require('../../utils/axios');
|
||||
const qs = require('querystring');
|
||||
const config = require('../../config');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const id = ctx.params.id;
|
||||
|
||||
const response = await axios({
|
||||
method: 'post',
|
||||
url: 'http://music.163.com/api/dj/program/byradio',
|
||||
headers: {
|
||||
'User-Agent': config.ua,
|
||||
Referer: 'https://music.163.com/',
|
||||
'Content-Type': 'application/x-www-form-urlencoded',
|
||||
},
|
||||
data: qs.stringify({
|
||||
radioId: id,
|
||||
limit: 1000,
|
||||
offset: 0,
|
||||
}),
|
||||
});
|
||||
|
||||
const programs = response.data.programs || [];
|
||||
|
||||
const { radio, dj } = programs[0] || { radio: {}, dj: {} };
|
||||
|
||||
ctx.state.data = {
|
||||
title: radio.name,
|
||||
link: `https://music.163.com/djradio?id=${id}`,
|
||||
subtitle: radio.desc,
|
||||
description: radio.desc,
|
||||
author: dj.nickname,
|
||||
updated: radio.lastProgramCreateTime,
|
||||
icon: radio.picUrl,
|
||||
item: programs.map((pg) => {
|
||||
const image = `<img src=${pg.coverUrl} />`;
|
||||
|
||||
const description = `<div>${(pg.description || '')
|
||||
.split('\n')
|
||||
.map((p) => `<p>${p}</p>`)
|
||||
.join('')}</div>`;
|
||||
|
||||
const src = `https://music.163.com/program/${pg.id}`;
|
||||
|
||||
const duration = ~~(pg.duration / 1000);
|
||||
|
||||
const content = image + description + `<div><p>时长: ${(duration / 60).toFixed(0).padStart(2, '0')}:${(duration % 60).toFixed(0).padStart(2, '0')}</p><p><a href="${src}">查看节目</a></p></div>`;
|
||||
|
||||
return {
|
||||
title: pg.mainSong.name,
|
||||
link: src,
|
||||
pubDate: new Date(pg.createTime).toUTCString(),
|
||||
published: new Date(pg.createTime).toISOString(),
|
||||
author: pg.dj.nickname,
|
||||
description: content,
|
||||
content: { src, value: content },
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
Reference in New Issue
Block a user