Skip to content

Instantly share code, notes, and snippets.

@coleww
Created October 22, 2015 13:19
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 coleww/971066804a4e5e6a524e to your computer and use it in GitHub Desktop.
Save coleww/971066804a4e5e6a524e to your computer and use it in GitHub Desktop.
neko_atsume_alert
var config = require('./config') // yr api keys and stuff
var Twit = require('twit')
var T = new Twit(config)
var fs = require('fs')
var $ = require('cheerio')
var request = require('request')
function doThatThang (link, type) {
request(link, function (err, resp, html) {
if (err) return console.error(err)
console.log("BING") // U GOT SOME DATA!
var parsedHTML = $.load(html) // PARSE THAT HTML!
var v = parsedHTML((type == 'ios' ? 'span' : 'div') + "[itemprop='softwareVersion']").text().replace(/\s/g, '') // ios wraps the vnumber in a span, whereas googleplay has it in a div, but both have the same itemProp. (SHRUG EMOTICON)
if (fs.readFileSync('./' + type).toString() !== v){ // ok now that we have the current version, grab the v we have saved and compare it
fs.writeFileSync('./' + type, v) // if they are different, overwite the one we have saved
console.log(v, type)// and then tweet about it
T.post('statuses/update', {status: "NEW NEKO ATSUME! VERSION " + v + " OUT ON " + type.toUpperCase() +"!!!!!!"}, function (err, data, response) {
console.log(err)
console.log(data)
})
}
})
}
;;;;;;;;
[{link: "https://play.google.com/store/apps/details?id=jp.co.hit_point.nekoatsume&hl=en", type: 'android'},
{link: "https://itunes.apple.com/us/app/nekoatsume/id923917775?mt=8", type: 'ios'}].forEach(function(x){
doThatThang(x.link, x.type)
})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment