-
-
Save tmbritton/455c9a4c0ec0f3b2b100 to your computer and use it in GitHub Desktop.
Are tickets on sale yet for The Force Awakens?
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
var https = require('https'), | |
exec = require('child_process').exec; | |
// Check every 5 minutes | |
var checkDelay = 60000 * 5; | |
// Store the previous response body for comparison | |
var lastBody = null; | |
var checkTickets = function() | |
{ | |
// Start check... | |
process.stdout.write('May the force'); | |
https.get({ | |
protocol: 'https:', | |
host: 'drafthouse.com', | |
path: '/ajax/.showtimes-show-starwars/0000/A000010000%7CA000009999', | |
headers: { | |
'cache-control': 'max-age=0' | |
} | |
}, function(response) { | |
// console.log(response.body); | |
response.on('data', function(chunk) { | |
var body = chunk.toString(), | |
url = 'https://drafthouse.com/starwars/austin'; | |
if(body !== lastBody && lastBody !== null) | |
{ | |
// OMG THEY'RE READY, GOGOGOGO | |
process.stdout.write(' be with you!'); | |
console.log(url); | |
exec("open " + url); | |
return; | |
} | |
// NOPE, NO TICKETS YET | |
process.stdout.write("-- NOT YET.\n") | |
// Check again in checkDelay milliseconds | |
setTimeout(function() { | |
checkTickets(); | |
}, checkDelay) | |
lastBody = body; | |
}); | |
}); | |
}; | |
checkTickets(); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment