From 96d9769a0faee15adf9f0b8e78700fa6a1bf6bb6 Mon Sep 17 00:00:00 2001 From: l3uddz Date: Wed, 7 Mar 2018 01:00:49 +0000 Subject: [PATCH] show error message when adding movie/series fails. --- media/radarr.py | 5 ++--- media/sonarr.py | 5 ++--- 2 files changed, 4 insertions(+), 6 deletions(-) diff --git a/media/radarr.py b/media/radarr.py index 14fca3e..a2dad65 100644 --- a/media/radarr.py +++ b/media/radarr.py @@ -98,9 +98,8 @@ class Radarr: if req.status_code == 201 and req.json()['tmdbId'] == movie_tmdbid: log.debug("Successfully added %s (%d)", movie_title, movie_tmdbid) return True - elif req.status_code == 401: - log.error("Failed to add %s (%d), reason: %s", movie_title, movie_tmdbid, - req.json()['errorMessage'] if '{' in req.text else "\n{}".format(req.text)) + elif req.status_code == 409 and 'message' in req.text: + log.error("Failed to add %s (%d), reason: %s", movie_title, movie_tmdbid, req.json()['message']) return False else: log.error("Failed to add %s (%d), unexpected response:\n%s", movie_title, movie_tmdbid, req.text) diff --git a/media/sonarr.py b/media/sonarr.py index 7857c98..8b14abc 100644 --- a/media/sonarr.py +++ b/media/sonarr.py @@ -98,9 +98,8 @@ class Sonarr: if req.status_code == 201 and req.json()['tvdbId'] == series_tvdbid: log.debug("Successfully added %s (%d)", series_title, series_tvdbid) return True - elif req.status_code == 401: - log.error("Failed to add %s (%d), reason: %s", series_title, series_tvdbid, - req.json()['errorMessage'] if '{' in req.text else "\n{}".format(req.text)) + elif req.status_code == 401 and 'errorMessage' in req.text: + log.error("Failed to add %s (%d), reason: %s", series_title, series_tvdbid, req.json()['errorMessage']) return False else: log.error("Failed to add %s (%d), unexpected response:\n%s", series_title, series_tvdbid, req.text)