1.1.13 (what is a descriptive commit message?)

This commit is contained in:
exttex
2021-01-21 22:51:51 +01:00
parent 87eb351e80
commit def6d5286d
7 changed files with 106 additions and 24 deletions

View File

@ -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

View File

@ -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) => {