diff --git a/media/radarr.py b/media/radarr.py index 57e761c..3f517cc 100644 --- a/media/radarr.py +++ b/media/radarr.py @@ -93,9 +93,11 @@ class Radarr: req = requests.post(urljoin(self.server_url, 'api/movie'), json=payload, headers=self.headers, timeout=30) log.debug("Request URL: %s", req.url) log.debug("Request Payload: %s", payload) - log.debug("Request Response: %d", req.status_code) + log.debug("Request Response Code: %d", req.status_code) + log.debug("Request Response Text:\n%s", req.text) - if (req.status_code == 201 or req.status_code == 200) and req.json()['tmdbId'] == movie_tmdbid: + if (req.status_code == 201 or req.status_code == 200) and 'json' in req.headers['Content-Type'].lower() \ + and req.json()['tmdbId'] == movie_tmdbid: log.debug("Successfully added %s (%d)", movie_title, movie_tmdbid) return True elif 'json' in req.headers['Content-Type'].lower() and 'message' in req.text: diff --git a/media/sonarr.py b/media/sonarr.py index 11e86ad..1d10f16 100644 --- a/media/sonarr.py +++ b/media/sonarr.py @@ -139,9 +139,11 @@ class Sonarr: req = requests.post(urljoin(self.server_url, 'api/series'), json=payload, headers=self.headers, timeout=30) log.debug("Request URL: %s", req.url) log.debug("Request Payload: %s", payload) - log.debug("Request Response: %d", req.status_code) - - if (req.status_code == 201 or req.status_code == 200) and req.json()['tvdbId'] == series_tvdbid: + log.debug("Request Response Code: %d", req.status_code) + log.debug("Request Response Text:\n%s", req.text) + + if (req.status_code == 201 or req.status_code == 200) and 'json' in req.headers['Content-Type'].lower() \ + and req.json()['tvdbId'] == series_tvdbid: log.debug("Successfully added %s (%d)", series_title, series_tvdbid) return True elif 'json' in req.headers['Content-Type'].lower() and 'errorMessage' in req.text: