mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-09 23:00:48 +08:00
61 lines
1.8 KiB
JavaScript
61 lines
1.8 KiB
JavaScript
const axios = require('@/utils/axios');
|
|
const qs = require('querystring');
|
|
|
|
module.exports = async (ctx) => {
|
|
const uid = ctx.params.uid;
|
|
|
|
const response = await axios({
|
|
method: 'post',
|
|
url: 'http://music.163.com/api/user/playlist',
|
|
headers: {
|
|
Referer: 'https://music.163.com/',
|
|
'Content-Type': 'application/x-www-form-urlencoded',
|
|
},
|
|
data: qs.stringify({
|
|
uid: uid,
|
|
limit: 1000,
|
|
offset: 0,
|
|
}),
|
|
});
|
|
|
|
const playlist = response.data.playlist || [];
|
|
|
|
const creator = (playlist[0] || {}).creator;
|
|
|
|
const { nickname, signature, avatarUrl } = creator;
|
|
|
|
ctx.state.data = {
|
|
title: `${nickname} 的所有歌单`,
|
|
link: `http://music.163.com/user/home?id=${uid}`,
|
|
subtitle: signature,
|
|
description: signature,
|
|
author: nickname,
|
|
updated: response.headers.date,
|
|
icon: avatarUrl,
|
|
item: playlist.map((pl) => {
|
|
const image = `<img referrerpolicy="no-referrer" src=${pl.coverImgUrl} />`;
|
|
|
|
const description = `<div>${(pl.description || '')
|
|
.split('\n')
|
|
.map((p) => `<p>${p}</p>`)
|
|
.join('')}</div>`;
|
|
|
|
const src = `http://music.163.com/playlist/${pl.id}`;
|
|
|
|
const html = image + description + `<div><a href="${src}">查看歌单</a></div>`;
|
|
|
|
return {
|
|
title: pl.name,
|
|
link: src,
|
|
pubDate: new Date(pl.createTime).toUTCString(),
|
|
published: new Date(pl.createTime).toISOString(),
|
|
updated: new Date(pl.updateTime).toISOString(),
|
|
author: pl.creator.nickname,
|
|
description: html,
|
|
content: { html },
|
|
category: pl.tags,
|
|
};
|
|
}),
|
|
};
|
|
};
|