diff --git a/lib/Jointspace/Client.js b/lib/Jointspace/Client.js index e6c0c8b..48ed1b0 100644 --- a/lib/Jointspace/Client.js +++ b/lib/Jointspace/Client.js @@ -426,24 +426,32 @@ class Client { // some newer models which use port 1926 still only listen // on port 1925 for the system endpoint return this.request("system", "GET", {}, {}, 1925, false, false).then(response => { - const encryptedAttributes = [ - 'serialnumber', - 'softwareversion', - 'model', - 'deviceid', - ]; - - encryptedAttributes.forEach((attribute) => { - if (typeof response[attribute + '_encrypted'] !== "undefined") { - try { - response[attribute] = AES.decrypt(decryptionKeyBase64, ivBase64, response[attribute + '_encrypted'].trim()); - } catch (e) { - } + if (response === "") { + // system endpoint for some TV models only works on https://:1926/system (on http://:1925/system receives HTTP 200 with empty response) + return this.request("system", "GET", {}, {}, 1926, true, false).then(r => this.decryptEncryptedAttributesInResponse(r)); } - }); + return this.decryptEncryptedAttributesInResponse(response); + }) + } - return response; + decryptEncryptedAttributesInResponse(response) { + const encryptedAttributes = [ + 'serialnumber', + 'softwareversion', + 'model', + 'deviceid', + ]; + + encryptedAttributes.forEach((attribute) => { + if (typeof response[attribute + '_encrypted'] !== "undefined") { + try { + response[attribute] = AES.decrypt(decryptionKeyBase64, ivBase64, response[attribute + '_encrypted'].trim()); + } catch (e) { + } + } }); + + return response; } getApplications() {