From 4691c5e828569597153dc25b15151ab6bb896979 Mon Sep 17 00:00:00 2001 From: Tianyi Ma Date: Tue, 13 Sep 2016 23:09:41 -0500 Subject: [PATCH] Port detection for 1.0.37.150.gad02a02e --- lib/main.js | 9 +++++++-- 1 file changed, 7 insertions(+), 2 deletions(-) diff --git a/lib/main.js b/lib/main.js index ab5a5f9..711dbb4 100644 --- a/lib/main.js +++ b/lib/main.js @@ -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); }); }); } @@ -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);