mirror of
https://github.com/DIYgod/RSSHub.git
synced 2025-12-01 17:48:15 +08:00
* feat: /spotify/playlist/:id
* feat: /spotify/artist
* feat(spotify/artist): add to radar
* feat: /spotify/saved
* feat: /spotify/top/{tracks,artists}
* feat(spotify): add images for artist and playlist
* docs: /spotify/*
* docs/en: /spotify configurations
* chore(spotify): apiKey/Secret -> clientId/Secret
* fix(spotify/utils): genres can be empty
32 lines
868 B
JavaScript
32 lines
868 B
JavaScript
const utils = require('./utils');
|
|
const got = require('@/utils/got');
|
|
const { parseDate } = require('@/utils/parse-date');
|
|
|
|
module.exports = async (ctx) => {
|
|
const token = await utils.getPublicToken();
|
|
const { id } = ctx.params;
|
|
const meta = await got
|
|
.get(`https://api.spotify.com/v1/playlists/${id}`, {
|
|
headers: {
|
|
Authorization: `Bearer ${token}`,
|
|
},
|
|
})
|
|
.json();
|
|
const tracks = meta.tracks.items;
|
|
|
|
ctx.state.data = {
|
|
title: meta.name,
|
|
link: meta.external_urls.spotify,
|
|
description: meta.description,
|
|
allowEmpty: true,
|
|
item: tracks.map((x) => ({
|
|
...utils.parseTrack(x.track),
|
|
pubDate: parseDate(x.added_at),
|
|
})),
|
|
};
|
|
|
|
if (meta.images.length) {
|
|
ctx.state.data.image = meta.images[0].url;
|
|
}
|
|
};
|