From 5a8849e1b0d36698e282b77b6659595aad004d92 Mon Sep 17 00:00:00 2001 From: Bochun Bai Date: Tue, 8 Feb 2022 22:04:18 -0800 Subject: [PATCH] Empty list is not None --- helpers/radarr.py | 2 +- helpers/sonarr.py | 6 +++--- media/trakt.py | 7 ++----- traktarr.py | 2 +- 4 files changed, 7 insertions(+), 10 deletions(-) diff --git a/helpers/radarr.py b/helpers/radarr.py index 51c753f..fb9749f 100644 --- a/helpers/radarr.py +++ b/helpers/radarr.py @@ -41,7 +41,7 @@ def remove_existing_movies_from_trakt_list(radarr_movies, trakt_movies, callback try: # turn radarr movies result into a dict with tmdb id as keys processed_movies = movies_to_tmdb_dict(radarr_movies) - if not processed_movies: + if processed_movies is None: return None # loop list adding to movies that do not already exist diff --git a/helpers/sonarr.py b/helpers/sonarr.py index d8c2506..44aff50 100644 --- a/helpers/sonarr.py +++ b/helpers/sonarr.py @@ -67,19 +67,19 @@ def series_to_tvdb_dict(sonarr_series): def remove_existing_series_from_trakt_list(sonarr_series, trakt_series, callback=None): new_series_list = [] - if not sonarr_series or not trakt_series: + if sonarr_series is None or trakt_series is None: log.error("Inappropriate parameters were supplied.") return None try: # clean up trakt_series list trakt_series = filter_trakt_series_list(trakt_series, callback) - if not trakt_series: + if trakt_series is None: return None # turn sonarr series result into a dict with tvdb id as keys processed_series = series_to_tvdb_dict(sonarr_series) - if not processed_series: + if processed_series is None: return None # loop list adding to series that do not already exist diff --git a/media/trakt.py b/media/trakt.py index c8cf7e7..f90aaf4 100644 --- a/media/trakt.py +++ b/media/trakt.py @@ -218,11 +218,8 @@ class Trakt: log.error("Failed to retrieve %s %s, request response: %d", type_name, object_name, req.status_code) break - if len(processed): - log.debug("Found %d %s %s", len(processed), type_name, object_name) - return processed - - return None + log.debug("Found %d %s %s", len(processed), type_name, object_name) + return processed except Exception: log.exception("Exception retrieving %s %s: ", type_name, object_name) return None diff --git a/traktarr.py b/traktarr.py index 212efe0..1c4edc0 100755 --- a/traktarr.py +++ b/traktarr.py @@ -547,7 +547,7 @@ def shows( else: trakt_objects_list = trakt.get_user_list_shows(list_type, authenticate_user) - if not trakt_objects_list: + if trakt_objects_list is None: log.error("Aborting due to failure to retrieve Trakt \'%s\' shows list.", list_type.capitalize()) if notifications: callback_notify(