mirror of
https://github.com/karl0ss/homepage.git
synced 2025-05-09 16:31:33 +01:00
fix linting errors
This commit is contained in:
parent
ad10b48204
commit
70ee750e6b
@ -6,7 +6,9 @@ import { httpProxy } from "utils/proxy/http";
|
|||||||
import getServiceWidget from "utils/config/service-helpers";
|
import getServiceWidget from "utils/config/service-helpers";
|
||||||
import createLogger from "utils/logger";
|
import createLogger from "utils/logger";
|
||||||
import widgets from "widgets/widgets";
|
import widgets from "widgets/widgets";
|
||||||
|
|
||||||
const saltedMd5 = require('salted-md5');
|
const saltedMd5 = require('salted-md5');
|
||||||
|
|
||||||
const proxyName = "nextpvrProxyHandler";
|
const proxyName = "nextpvrProxyHandler";
|
||||||
|
|
||||||
const logger = createLogger(proxyName);
|
const logger = createLogger(proxyName);
|
||||||
@ -51,25 +53,25 @@ async function loginToNextPVR(endpoint, widget) {
|
|||||||
return [status, null];
|
return [status, null];
|
||||||
}
|
}
|
||||||
// Create md5 hash of pin / salt to to md5 login
|
// Create md5 hash of pin / salt to to md5 login
|
||||||
let hashedSalt = saltedMd5(':' + saltedMd5(widget.pin) + ':', dataAsJson.rsp.salt._text);
|
const hashedSalt = saltedMd5(`:${saltedMd5(widget.pin)}:`, dataAsJson.rsp.salt._text);
|
||||||
endpoint = 'session.login&md5='
|
url = `${new URL(formatApiCall(api, { 'endpoint': 'session.login&md5=', 'url': widget.url }))}${hashedSalt}&sid=${dataAsJson.rsp.sid._text}`;
|
||||||
url = new URL(formatApiCall(api, { endpoint, ...widget })) + hashedSalt + '&sid=' + dataAsJson.rsp.sid._text;
|
|
||||||
|
|
||||||
[status, contentType, data] = await httpProxy(url);
|
[status, contentType, data] = await httpProxy(url);
|
||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
logger.error("HTTP %d communicating with NextPVR. Data: %s", status, data.toString());
|
logger.error("HTTP %d communicating with NextPVR. Data: %s", status, contentType, data.toString());
|
||||||
return [status, data];
|
return [status, data];
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
const dataDecoded = xml2json(data.toString(), { compact: true });
|
const dataDecoded = xml2json(data.toString(), { compact: true });
|
||||||
let dataAsJson = JSON.parse(dataDecoded);
|
dataAsJson = JSON.parse(dataDecoded);
|
||||||
// Store the session id globally
|
// Store the session id globally
|
||||||
globalSid = dataAsJson.rsp.sid._text
|
globalSid = dataAsJson.rsp.sid._text
|
||||||
} catch (e) {
|
} catch (e) {
|
||||||
logger.error("Error decoding NextPVR API data. Data: %s", data.toString());
|
logger.error("Error decoding NextPVR API data. Data: %s", data.toString());
|
||||||
return [status, null];
|
return [status, null];
|
||||||
}
|
}
|
||||||
console.log('gettingSID')
|
logger.info('gettingSID')
|
||||||
|
return [status, true];
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
@ -78,9 +80,7 @@ async function fetchFromNextPVRAPI(endpoint, widget, sid) {
|
|||||||
if (!api) {
|
if (!api) {
|
||||||
return [403, null];
|
return [403, null];
|
||||||
}
|
}
|
||||||
|
const url = `${new URL(formatApiCall(api, { endpoint, ...widget }))}&sid=${sid}`
|
||||||
const url = new URL(formatApiCall(api, { endpoint, ...widget })) + '&sid=' + sid;
|
|
||||||
|
|
||||||
const [status, contentType, data] = await httpProxy(url);
|
const [status, contentType, data] = await httpProxy(url);
|
||||||
|
|
||||||
if (status !== 200) {
|
if (status !== 200) {
|
||||||
@ -116,7 +116,7 @@ export default async function nextPVRProxyHandler(req, res) {
|
|||||||
}
|
}
|
||||||
|
|
||||||
let recordingCount
|
let recordingCount
|
||||||
if (Array.isArray(apiData.rsp.recordings.recording) == false) {
|
if (Array.isArray(apiData.rsp.recordings.recording) === false) {
|
||||||
if (apiData.rsp.recordings.recording) {
|
if (apiData.rsp.recordings.recording) {
|
||||||
recordingCount = 1;
|
recordingCount = 1;
|
||||||
} else {
|
} else {
|
||||||
@ -132,7 +132,7 @@ export default async function nextPVRProxyHandler(req, res) {
|
|||||||
return res.status(status).json({ error: { message: "HTTP error communicating with NextPVR API", data: Buffer.from(apiData).toString() } });
|
return res.status(status).json({ error: { message: "HTTP error communicating with NextPVR API", data: Buffer.from(apiData).toString() } });
|
||||||
}
|
}
|
||||||
let readyCount
|
let readyCount
|
||||||
if (Array.isArray(apiData.rsp.recordings.recording) == false) {
|
if (Array.isArray(apiData.rsp.recordings.recording) === false) {
|
||||||
if (apiData.rsp.recordings.recording) {
|
if (apiData.rsp.recordings.recording) {
|
||||||
readyCount = 1;
|
readyCount = 1;
|
||||||
} else {
|
} else {
|
||||||
|
Loading…
x
Reference in New Issue
Block a user