Skip to content
Snippets Groups Projects
Commit 7b501ed0 authored by Daniel Kovacs's avatar Daniel Kovacs
Browse files

asd

parent bad10c46
No related branches found
No related tags found
No related merge requests found
......@@ -236,43 +236,45 @@ app.post('/saveplaylist/:id', (req,res) => {
const userId=req.body.userid
const playListName = req.body.playlistname;
console.log(JSON.stringify(req.headers));
res.status(200);
// axios.post(`https://api.spotify.com/v1/users/${userId}/playlists`, {name: playListName},config).then(result => {
// if (result.status == 200 || result.status==201) {
// const playlistId = result.data.id
// db.all('SELECT song_id, song_author, song_title, song_duration, COUNT(id) AS occurrence FROM songs WHERE party_id=? GROUP BY song_id ORDER BY occurrence LIMIT (SELECT num_tracks FROM party WHERE ID=?)',
// [req.params.id,req.params.id], (err,rows) => {
// let track_ids="uris=";
// rows.forEach(row=>{
// track_ids+=`spotify:track:${row.song_id},`
// })
// track_ids=track_ids.substr(0,track_ids.length-1)
// axios.post(`https://api.spotify.com/v1/playlists/${playlistId}/tracks?${track_ids}`,{},config).then(result =>{
// console.log(result.data)
// db.run('DELETE FROM party WHERE id=?',[req.params.id], () => {
// console.log("one")
// db.run('DELETE FROM songs WHERE party_id=?', [req.params.id],
// () => {
// console.log("two")
// db.run('DELETE FROM party_members WHERE party_id =?',
// [req.params.id], () => {
// res.status(200);
//
// }
// )
// })
// });
//
// }).catch(error=>{
// console.log(error)
// res.status(500)
// })
// })
// }
//
// })
axios.post(`https://api.spotify.com/v1/users/${userId}/playlists`, {name: playListName},config).then(result => {
if (result.status == 200 || result.status==201) {
const playlistId = result.data.id
db.all('SELECT song_id, song_author, song_title, song_duration, COUNT(id) AS occurrence FROM songs WHERE party_id=? GROUP BY song_id ORDER BY occurrence LIMIT (SELECT num_tracks FROM party WHERE ID=?)',
[req.params.id,req.params.id], (err,rows) => {
let track_ids="uris=";
rows.forEach(row=>{
track_ids+=`spotify:track:${row.song_id},`
})
track_ids=track_ids.substr(0,track_ids.length-1)
axios.post(`https://api.spotify.com/v1/playlists/${playlistId}/tracks?${track_ids}`,{},config).then(result =>{
console.log(result.data)
db.run('DELETE FROM party WHERE id=?',[req.params.id], () => {
db.run('DELETE FROM songs WHERE party_id=?', [req.params.id],
() => {
db.run('DELETE FROM party_members WHERE party_id =?',
[req.params.id], () => {
res.send(status(200));
}
)
})
});
}).catch(error=>{
console.log(error)
res.send(status(500))
})
})
}
})
});
app.post('/teszt' , (req,res) => {
res.send(status(200))
});
const port = process.env.PORT || 8888
......
......@@ -44,7 +44,7 @@ class UnsavedPlaylists extends Component {
<td>{playlist.memberCount}</td>
<td style={{textAlign: 'right'}}>
<button className="btn btn-light"
onClick={this.onCopyUrl.bind(this, `http://localhost:3000/playlist/${playlist.id}`)}>
onClick={this.onCopyUrl.bind(this, `http://localhost:3000/join/${playlist.id}`)}>
Copy URL
</button>
<Link to={`/playlist/${playlist.id}`}>
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment