Skip to content

Commit

Permalink
Port detection for 1.0.37.150.gad02a02e
Browse files Browse the repository at this point in the history
  • Loading branch information
tma02 committed Sep 14, 2016
1 parent 7066246 commit 4691c5e
Showing 1 changed file with 7 additions and 2 deletions.
9 changes: 7 additions & 2 deletions lib/main.js
Original file line number Diff line number Diff line change
Expand Up @@ -136,13 +136,14 @@ function getUrl(path) {
}

function getJson(config, callback) {
var port = config.port;
https.get(config, function(res) {
var body = '';
res.on('data', function (d) {
body += d;
});
res.on('end', function () {
callback(JSON.parse(body));
callback(JSON.parse(body), port);
});
});
}
Expand Down Expand Up @@ -226,13 +227,17 @@ let waitForSpotify = setInterval(function() {
config = copyConfig();
config.host = generateLocalHostname();
config.path = '/service/version.json?service=remote';
getJson(config, function(data) {
getJson(config, function(data, port) {
if (!('running' in data)) {
data.running = true;
}
version = data;
console.log(version);
console.log(port);
config.port = port;
});
console.log('waiting for spotify...');
console.log(config.port);
config.port++;
}
}, 500);

0 comments on commit 4691c5e

Please sign in to comment.