Created
January 4, 2017 20:30
-
-
Save rooreynolds/d25b6bf648bed62c73926e177741bdad to your computer and use it in GitHub Desktop.
What's on Radio 4 right now? via Node JS
This file contains 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
const request = require('request') | |
,url = 'http://www.bbc.co.uk/radio4/programmes/schedules/fm.json' | |
request(url, (error, response, body)=> { | |
if (!error && response.statusCode === 200) { | |
const data = JSON.parse(body) | |
var schedule=data.schedule.day.broadcasts; | |
var myDate = new Date(); | |
for (var i=0; i<schedule.length; i++) { | |
var startDate = Date.parse(schedule[i].start); | |
var endDate = Date.parse(schedule[i].end); | |
if (myDate > startDate && myDate < endDate) { | |
console.log(schedule[i].programme.display_titles.title); | |
console.log(schedule[i].programme.display_titles.subtitle); | |
console.log(schedule[i].programme.short_synopsis); | |
} | |
} | |
} else { | |
console.log("Got an error: ", error, ", status code: ", response.statusCode) | |
} | |
}) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment