Created
April 27, 2013 22:46
-
-
Save rascode/5475054 to your computer and use it in GitHub Desktop.
Create a Calendar of the most recent Google Developer Live Videos
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| //Fetch the Google Developers Live (GDL) Live Calenar Using the YouTube API | |
| function getGdlEvents(){ | |
| var channelID = "UC_x5XG1OV2P6uZZ5FSM9Ttw"; | |
| var yt = "https://www.googleapis.com/youtube/v3/activities"; | |
| var part = "snippet"; | |
| var maxResults = "50"; | |
| var key = "Your Google API Key"; | |
| var url = yt + "?part=" + part + "&channelId=" + channelID + "&maxResults=" + maxResults + "&key=" + key; | |
| var data = JSON.parse(UrlFetchApp.fetch(url).getContentText()); | |
| return data; | |
| } | |
| //Loop through each event adding to Calendar | |
| function createCalendarEvents(data){ | |
| var cal = CalendarApp.createCalendar("GDL"); | |
| events = data.items; | |
| for (i in events){ | |
| var event = events[i].snippet; | |
| var title = event.title; | |
| var published = event.publishedAt; | |
| var description = event.description; | |
| cal.createEvent(title, new Date(published), new Date(published)); | |
| } | |
| } | |
| //Fetch GDL's and add them to the GDL Calendar | |
| function addEventsToCalendar(){ | |
| var data = getGdlEvents(); | |
| createCalendarEvents(data); | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment