diff --git a/media/radarr.py b/media/radarr.py index d4d38d6..bc0c3af 100644 --- a/media/radarr.py +++ b/media/radarr.py @@ -1,7 +1,6 @@ -from urllib.parse import urljoin - import backoff import requests +import os.path from misc.log import logger from misc import helpers @@ -27,7 +26,11 @@ class Radarr: def validate_api_key(self): try: # request system status to validate api_key - req = requests.get(urljoin(self.server_url, 'api/system/status'), headers=self.headers, timeout=60) + req = requests.get( + os.path.join(self.server_url, 'api/system/status'), + headers=self.headers, + timeout=60 + ) log.debug("Request Response: %d", req.status_code) if req.status_code == 200 and 'version' in req.json(): @@ -41,7 +44,11 @@ class Radarr: def get_movies(self): try: # make request - req = requests.get(urljoin(self.server_url, 'api/movie'), headers=self.headers, timeout=60) + req = requests.get( + os.path.join(self.server_url, 'api/movie'), + headers=self.headers, + timeout=60 + ) log.debug("Request URL: %s", req.url) log.debug("Request Response: %d", req.status_code) @@ -59,7 +66,11 @@ class Radarr: def get_profile_id(self, profile_name): try: # make request - req = requests.get(urljoin(self.server_url, 'api/profile'), headers=self.headers, timeout=60) + req = requests.get( + os.path.join(self.server_url, 'api/profile'), + headers=self.headers, + timeout=60 + ) log.debug("Request URL: %s", req.url) log.debug("Request Response: %d", req.status_code) @@ -100,7 +111,7 @@ class Radarr: # make request req = requests.post( - urljoin(self.server_url, 'api/movie'), + os.path.join(self.server_url, 'api/movie'), headers=self.headers, json=payload, timeout=60 diff --git a/media/sonarr.py b/media/sonarr.py index e2167af..9315c62 100644 --- a/media/sonarr.py +++ b/media/sonarr.py @@ -1,7 +1,6 @@ -from urllib.parse import urljoin - import backoff import requests +import os.path from misc import helpers from misc.log import logger @@ -26,7 +25,7 @@ class Sonarr: def validate_api_key(self): try: # request system status to validate api_key - req = requests.get(urljoin(self.server_url, 'api/system/status'), headers=self.headers, timeout=60) + req = requests.get(os.path.join(self.server_url, 'api/system/status'), headers=self.headers, timeout=60) log.debug("Request Response: %d", req.status_code) if req.status_code == 200 and 'version' in req.json(): @@ -40,7 +39,11 @@ class Sonarr: def get_series(self): try: # make request - req = requests.get(urljoin(self.server_url, 'api/series'), headers=self.headers, timeout=60) + req = requests.get( + os.path.join(self.server_url, 'api/series'), + headers=self.headers, + timeout=60 + ) log.debug("Request URL: %s", req.url) log.debug("Request Response: %d", req.status_code) @@ -58,7 +61,11 @@ class Sonarr: def get_profile_id(self, profile_name): try: # make request - req = requests.get(urljoin(self.server_url, 'api/profile'), headers=self.headers, timeout=60) + req = requests.get( + os.path.join(self.server_url, 'api/profile'), + headers=self.headers, + timeout=60 + ) log.debug("Request URL: %s", req.url) log.debug("Request Response: %d", req.status_code) @@ -80,7 +87,11 @@ class Sonarr: def get_tag_id(self, tag_name): try: # make request - req = requests.get(urljoin(self.server_url, 'api/tag'), headers=self.headers, timeout=60) + req = requests.get( + os.path.join(self.server_url, 'api/tag'), + headers=self.headers, + timeout=60 + ) log.debug("Request URL: %s", req.url) log.debug("Request Response: %d", req.status_code) @@ -103,7 +114,11 @@ class Sonarr: tags = {} try: # make request - req = requests.get(urljoin(self.server_url, 'api/tag'), headers=self.headers, timeout=60) + req = requests.get( + os.path.join(self.server_url, 'api/tag'), + headers=self.headers, + timeout=60 + ) log.debug("Request URL: %s", req.url) log.debug("Request Response: %d", req.status_code) @@ -144,7 +159,7 @@ class Sonarr: # make request req = requests.post( - urljoin(self.server_url, 'api/series'), + os.path.join(self.server_url, 'api/series'), headers=self.headers, json=payload, timeout=60