diff --git a/seasoned_api/src/plex/plex.js b/seasoned_api/src/plex/plex.js index 9eb1b29..1568596 100644 --- a/seasoned_api/src/plex/plex.js +++ b/seasoned_api/src/plex/plex.js @@ -10,6 +10,12 @@ const redisCache = new RedisCache(); const sanitize = string => string.toLowerCase().replace(/[^\w]/gi, ""); +function fixedEncodeURIComponent(str) { + return encodeURIComponent(str).replace(/[!'()*]/g, function (c) { + return "%" + c.charCodeAt(0).toString(16).toUpperCase(); + }); +} + const matchingTitleAndYear = (plex, tmdb) => { let matchingTitle, matchingYear; @@ -152,7 +158,7 @@ class Plex { ) return false; - const keyUriComponent = encodeURIComponent(matchingObjectInPlex.key); + const keyUriComponent = fixedEncodeURIComponent(matchingObjectInPlex.key); return `https://app.plex.tv/desktop#!/server/${machineIdentifier}/details?key=${keyUriComponent}`; }); } @@ -162,7 +168,7 @@ class Plex { const url = `http://${this.plexIP}:${ this.plexPort - }/hubs/search?query=${encodeURIComponent(query)}`; + }/hubs/search?query=${fixedEncodeURIComponent(query)}`; const options = { timeout: 20000, headers: { Accept: "application/json" }