Skip to content

Instantly share code, notes, and snippets.

@kartben
Created August 18, 2015 16:24
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save kartben/d53fbf4ee9ddad20b636 to your computer and use it in GitHub Desktop.
Save kartben/d53fbf4ee9ddad20b636 to your computer and use it in GitHub Desktop.
var YouTube = require('../lib/youtube');
var config = require('./config');
var fs = require('fs');
var youTube = new YouTube();
youTube.setKey(config.key);
youTube.getPlayListsItemsById('PLy7t4z5SYNaQS1XZ8uiqqn0nNLi4qU-VW', function(error, result) {
if (error) {
console.log(error);
} else {
console.log(result.items);
for (var i = 0; i < result.items.length; i++) {
var item = result.items[i];
var contents = "+++\n";
contents += 'date = "' + item.snippet.publishedAt + '"\n';
contents += 'title = "' + item.snippet.title + '"\n';
contents += 'link = "https://youtu.be/' + item.contentDetails.videoId + '"\n';
contents += '+++\n';
contents += 'Virtual IoT meetup recording:\n' + item.snippet.title;
fs.writeFile(item.snippet.publishedAt.substr(0, 10) + '-virtual-iot-recording', contents, function(err) {
if (err) {
return console.log(err);
}
console.log("The file was saved!");
});
};
}
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment