Fixed an issue that could clear episodes history in case Sonarr API return something else than valid series or episodes.

pull/2258/head v1.3.2-beta.15
morpheus65535 1 year ago
parent addae11b61
commit 97bdf0066e

@ -85,5 +85,11 @@ def get_movies_from_radarr_api(apikey_radarr, radarr_id=None):
except requests.exceptions.RequestException:
logging.exception("BAZARR Error trying to get movies from Radarr.")
return
except Exception as e:
logging.exception(f"Exception raised while getting movies from Radarr API: {e}")
return
else:
return r.json()
if r.status_code == 200:
return r.json()
else:
return

@ -78,6 +78,8 @@ def sync_episodes(series_id, send_event=True):
episodes_to_update.append(parsed_episode)
else:
episodes_to_add.append(episodeParser(episode))
else:
return
# Remove old episodes from DB
episodes_to_delete = list(set(current_episodes_id_db_list) - set(current_episodes_sonarr))

@ -43,7 +43,7 @@ def update_series(send_event=True):
tagsDict = get_tags()
# Get shows data from Sonarr
series = get_series_from_sonarr_api(url=url_sonarr(), apikey_sonarr=apikey_sonarr)
series = get_series_from_sonarr_api(apikey_sonarr=apikey_sonarr)
if not isinstance(series, list):
return
else:
@ -157,8 +157,7 @@ def update_one_series(series_id, action):
# Get series data from sonarr api
series = None
series_data = get_series_from_sonarr_api(url=url_sonarr(), apikey_sonarr=settings.sonarr.apikey,
sonarr_series_id=int(series_id))
series_data = get_series_from_sonarr_api(apikey_sonarr=settings.sonarr.apikey, sonarr_series_id=int(series_id))
if not series_data:
return

@ -67,7 +67,7 @@ def get_tags():
return tagsDict.json()
def get_series_from_sonarr_api(url, apikey_sonarr, sonarr_series_id=None):
def get_series_from_sonarr_api(apikey_sonarr, sonarr_series_id=None):
url_sonarr_api_series = (f"{url_api_sonarr()}series/{sonarr_series_id if sonarr_series_id else ''}?"
f"apikey={apikey_sonarr}")
try:
@ -87,12 +87,18 @@ def get_series_from_sonarr_api(url, apikey_sonarr, sonarr_series_id=None):
except requests.exceptions.RequestException:
logging.exception("BAZARR Error trying to get series from Sonarr.")
return
except Exception as e:
logging.exception(f"Exception raised while getting series from Sonarr API: {e}")
return
else:
result = r.json()
if isinstance(result, dict):
return [result]
if r.status_code == 200:
result = r.json()
if isinstance(result, dict):
return [result]
else:
return r.json()
else:
return r.json()
return
def get_episodes_from_sonarr_api(apikey_sonarr, series_id=None, episode_id=None):
@ -118,8 +124,14 @@ def get_episodes_from_sonarr_api(apikey_sonarr, series_id=None, episode_id=None)
except requests.exceptions.RequestException:
logging.exception("BAZARR Error trying to get episodes from Sonarr.")
return
except Exception as e:
logging.exception(f"Exception raised while getting episodes from Sonarr API: {e}")
return
else:
return r.json()
if r.status_code == 200:
return r.json()
else:
return
def get_episodesFiles_from_sonarr_api(apikey_sonarr, series_id=None, episode_file_id=None):
@ -146,5 +158,11 @@ def get_episodesFiles_from_sonarr_api(apikey_sonarr, series_id=None, episode_fil
except requests.exceptions.RequestException:
logging.exception("BAZARR Error trying to get episodeFiles from Sonarr.")
return
except Exception as e:
logging.exception(f"Exception raised while getting episodes from Sonarr API: {e}")
return
else:
return r.json()
if r.status_code == 200:
return r.json()
else:
return

Loading…
Cancel
Save