Skip to content

Instantly share code, notes, and snippets.

@tamascsaba
Created September 27, 2018 13:14
Show Gist options
  • Save tamascsaba/1ff870225fbb452b9db27bc0b71ebb04 to your computer and use it in GitHub Desktop.
Save tamascsaba/1ff870225fbb452b9db27bc0b71ebb04 to your computer and use it in GitHub Desktop.
const request = require('request');
const listID = 'PLXqGVIkwHK4IpJPTd7s88fqyjjYB2g8yo'
const listUrl = 'https://www.googleapis.com/youtube/v3/playlistItems?part=snippet&key=AIzaSyAvNgxcJ67EZuioDBOuQffHkQa4qBv_eCI&playlistId=' + listID;
request.get(listUrl, (e, res, b) => {
if (!e && res.tatusCode == 200) {
console.log(b);
}
for(const item of b.items) {
const id = item.snippet.resourceId.videoId;
const url = 'https://www.youtube.com/watch?v=' + id;
request.post(
'http://10.30.255.33:5000/player/tracks',
{ json: {url: url, user: 'Tonyo' } },
(error, response, body) => {
if (!error && response.statusCode == 200) {
console.log(body);
}
}
);
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment