rss:enhance ncm/userplaylist (#170)
* rss: enhance ncm/userplaylist * Update userplaylist.js
This commit is contained in:
parent
93ff5c61c4
commit
cf6ea44b48
|
|
@ -20,21 +20,43 @@ module.exports = async (ctx) => {
|
|||
}),
|
||||
});
|
||||
|
||||
const playlist = response.data.playlist || [{ creator: {} }];
|
||||
const playlist = response.data.playlist || [];
|
||||
|
||||
const creator = playlist[0].creator;
|
||||
const creator = (playlist[0] || {}).creator;
|
||||
|
||||
const { nickname, signature } = creator;
|
||||
const { nickname, signature, avatarUrl } = creator;
|
||||
|
||||
ctx.state.data = {
|
||||
title: `${nickname} 的所有歌单`,
|
||||
link: `http://music.163.com/user/home?id=${uid}`,
|
||||
subtitle: signature,
|
||||
description: signature,
|
||||
item: playlist.map((pl) => ({
|
||||
title: pl.name,
|
||||
description: pl.description,
|
||||
pubDate: new Date(pl.createTime).toUTCString(),
|
||||
link: `http://music.163.com/playlist?id=${pl.id}`,
|
||||
})),
|
||||
author: nickname,
|
||||
updated: response.headers.date,
|
||||
icon: avatarUrl,
|
||||
item: playlist.map((pl) => {
|
||||
const image = `<img 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 content = 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: content,
|
||||
content: { src, value: content },
|
||||
category: pl.tags,
|
||||
};
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
|
|
|||
Loading…
Reference in New Issue