diff --git a/src/cache/redisMock.js b/src/cache/redisMock.js index affa673..f7ca3df 100644 --- a/src/cache/redisMock.js +++ b/src/cache/redisMock.js @@ -12,7 +12,7 @@ const redisMockClient = { return Promise.resolve(callback(null, "OK")); }, expire(key, TTL) { - // console.log(`redis-dummy expire: ${key} with TTL ${TTL}`); // eslint-disable-line no-console + console.log(`redis-dummy expire: ${key} with TTL ${TTL}`); // eslint-disable-line no-console } }; diff --git a/src/plex/plex.js b/src/plex/plex.js index b7d8a78..b97d9dc 100644 --- a/src/plex/plex.js +++ b/src/plex/plex.js @@ -116,7 +116,7 @@ class Plex { headers: { Accept: "application/json" } }; - return new Promise((resolve, reject) => + return new Promise((resolve, reject) => { this.cache .get(cacheKey) .then(machineInfo => resolve(machineInfo?.machineIdentifier)) @@ -132,8 +132,8 @@ class Plex { } reject(new PlexUnexpectedError()); - }) - ); + }); + }); } async existsInPlex(tmdb) { @@ -185,16 +185,19 @@ class Plex { const url = `http://${this.plexIP}:${ this.plexPort - }/hubs/search?query=${fixedEncodeURIComponent(query)}`; + }/hubs/search?query=${fixedEncodeURIComponent(query)}&X-Plex-Token=${ + this.token + }`; + const options = { timeout: 20000, headers: { Accept: "application/json" } }; - return new Promise((resolve, reject) => + return new Promise((resolve, reject) => { this.cache .get(cacheKey) - .catch(error => { + .catch(() => { // else fetch fresh data return fetch(url, options) .then(successfullResponse) @@ -208,8 +211,8 @@ class Plex { } reject(new PlexUnexpectedError()); - }) - ); + }); + }); } // this is not guarenteed to work, but if we see a movie or @@ -224,7 +227,7 @@ class Plex { // TODO improve cache key matching by lowercasing it on the backend. // what do we actually need to check for if the key was deleted or not // it might be an error or another response code. - console.log("Unable to delete, key might not exists"); + console.log("Unable to delete, key might not exists"); // eslint-disable-line no-console return response === 1; }); }