feat: add 荔枝FM电台更新 (#4939)
This commit is contained in:
parent
2aaa4bda28
commit
bde713fd24
|
|
@ -349,6 +349,12 @@ pageClass: routes
|
|||
|
||||
<Route author="SunShinenny" example="/kaiyan/index" path="/kaiyan/index"/>
|
||||
|
||||
## 荔枝 FM
|
||||
|
||||
### 电台更新
|
||||
|
||||
<Route author="nczitzk" example="/lizhi/user/27151442948222380" path="/lizhi/user/:id" :paramsDesc="['用户 id,可以在电台的 URL 中找到']"/>
|
||||
|
||||
## 猫眼电影
|
||||
|
||||
### 正在热映
|
||||
|
|
|
|||
|
|
@ -2834,4 +2834,7 @@ router.get('/egameqq/room/:id', require('./routes/tencent/egame/room'));
|
|||
// 国家税务总局
|
||||
router.get('/gov/chinatax/latest', require('./routes/gov/chinatax/latest'));
|
||||
|
||||
// 荔枝FM
|
||||
router.get('/lizhi/user/:id', require('./routes/lizhi/user'));
|
||||
|
||||
module.exports = router;
|
||||
|
|
|
|||
|
|
@ -0,0 +1,47 @@
|
|||
const got = require('@/utils/got');
|
||||
const cheerio = require('cheerio');
|
||||
|
||||
module.exports = async (ctx) => {
|
||||
const link = `https://www.lizhi.fm/api/user/audios/${ctx.params.id}/1`;
|
||||
const response = await got({
|
||||
method: 'get',
|
||||
url: link,
|
||||
});
|
||||
|
||||
const userUrl = `https://m.lizhi.fm/vod/user/${ctx.params.id}`;
|
||||
const userResponse = await got({
|
||||
method: 'get',
|
||||
url: userUrl,
|
||||
});
|
||||
const $ = cheerio.load(userResponse.data);
|
||||
|
||||
const list = response.data.audios.map((item) => ({
|
||||
title: item.name,
|
||||
enclosure_url: item.url,
|
||||
enclosure_length: item.duration,
|
||||
enclosure_type: 'audio/mpeg',
|
||||
link: `https://www.lizhi.fm/${$('div.user_info div.desc span').eq(0).text().replace('FM ', '')}/${item.id}`,
|
||||
pubDate: new Date(item.create_time).toUTCString(),
|
||||
}));
|
||||
|
||||
ctx.state.data = {
|
||||
title: `荔枝FM - ${$('div.username h3.name').text()}`,
|
||||
link: `https://www.lizhi.fm/user/${ctx.params.id}`,
|
||||
itunes_author: $('div.username h3.name').text(),
|
||||
itunes_category: '',
|
||||
image: `http://${$('div.user_info div.cover img').attr('src').replace('200x200', '320x320')}`,
|
||||
item: await Promise.all(
|
||||
list.map(
|
||||
async (item) =>
|
||||
await ctx.cache.tryGet(item.link, async () => {
|
||||
const res = await got({ method: 'get', url: item.link });
|
||||
const content = cheerio.load(res.data);
|
||||
item.description = content('div.desText').text();
|
||||
item.itunes_item_image = content('div.audioCover img').attr('src');
|
||||
return item;
|
||||
})
|
||||
)
|
||||
),
|
||||
description: `${$('div.isAll').text()}`,
|
||||
};
|
||||
};
|
||||
Loading…
Reference in New Issue