1.1.13 (what is a descriptive commit message?)
This commit is contained in:
@ -100,6 +100,17 @@ class Playlist {
|
||||
);
|
||||
this.tracks = tracksJson.data.map((t) => new Track(t));
|
||||
this.library = library;
|
||||
switch (json.STATUS) {
|
||||
case 0:
|
||||
this.type = 'public';
|
||||
break;
|
||||
case 1:
|
||||
this.type = 'private';
|
||||
break;
|
||||
case 2:
|
||||
this.type = 'collaborative'
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
//Extend tracks
|
||||
|
@ -128,20 +128,31 @@ app.delete('/playlist/:id', async (req, res) => {
|
||||
// {
|
||||
// desciption,
|
||||
// title,
|
||||
// type: 'public' || 'private',
|
||||
// type: 0, 1, 2 = public, private, collab
|
||||
// track: trackID
|
||||
// }
|
||||
app.post('/playlist', async (req, res) => {
|
||||
await deezer.callApi('playlist.create', {
|
||||
description: req.body.description,
|
||||
title: req.body.title,
|
||||
status: req.body.type == 'public' ? 2 : 1,
|
||||
status: req.body.type,
|
||||
songs: req.body.track ? [[req.body.track, 0]] : []
|
||||
});
|
||||
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
//PUT edit playlist, see above create
|
||||
app.put('/playlist/:id', async (req, res) => {
|
||||
await deezer.callApi('playlist.update', {
|
||||
description: req.body.description,
|
||||
title: req.body.title,
|
||||
status: req.body.type,
|
||||
playlist_id: parseInt(req.params.id.toString(), 10)
|
||||
});
|
||||
res.sendStatus(200);
|
||||
});
|
||||
|
||||
//POST track to playlist
|
||||
//Body {"track": "trackId"}
|
||||
app.post('/playlist/:id/tracks', async (req, res) => {
|
||||
|
Reference in New Issue
Block a user