Skip to content

Commit

Permalink
Merge pull request #119 from rfsbraz/chore/generic-fixes
Browse files Browse the repository at this point in the history
Maintenance
  • Loading branch information
rfsbraz authored Jul 11, 2024
2 parents 9e817c1 + 8d91dbe commit 65bca0f
Show file tree
Hide file tree
Showing 3 changed files with 21 additions and 14 deletions.
7 changes: 5 additions & 2 deletions app/media_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,10 @@ def process_library(self, library, sonarr_instance, unfiltered_all_show_data):
return 0

all_show_data = self.filter_shows(library, unfiltered_all_show_data)
logger.info("Instance has %s items to process", len(all_show_data))
logger.info("Instance has %s items to process of type '%s'", len(all_show_data), library.get("series_type", DEFAULT_SONARR_SERIES_TYPE))

if not all_show_data:
return 0

max_actions_per_run = _get_config_value(
library, "max_actions_per_run", DEFAULT_MAX_ACTIONS_PER_RUN
Expand Down Expand Up @@ -423,7 +426,7 @@ def match_year(self, plex_media_item, year):
not year
or not plex_media_item.year
or plex_media_item.year == year
or (abs(plex_media_item.year - year)) <= 1
or (abs(plex_media_item.year - year)) <= 2 # Allow 2 years of difference in the release date
):
return True
return False
Expand Down
24 changes: 14 additions & 10 deletions app/modules/trakt.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,16 +39,20 @@ def _get_all_items_for_url(self, media_type, trakt_config):
def _fetch_list_items(
self, media_type, username, listname, recurrence, max_items_per_list
):
if username and listname:
return self._fetch_user_list_items(
media_type, username, listname, max_items_per_list
)
elif listname and recurrence:
return self._fetch_recurrent_list_items(media_type, listname)
elif listname:
return self._fetch_general_list_items(
media_type, listname, max_items_per_list
)
try:
if username and listname:
return self._fetch_user_list_items(
media_type, username, listname, max_items_per_list
)
elif listname and recurrence:
return self._fetch_recurrent_list_items(media_type, listname)
elif listname:
return self._fetch_general_list_items(
media_type, listname, max_items_per_list
)
except Exception as e:
logger.error(f"Failed to fetch list items for {media_type} {listname}")
logger.debug(f"Error: {e}")
return []

def _fetch_user_list_items(
Expand Down
4 changes: 2 additions & 2 deletions tests/test_media_cleaner.py
Original file line number Diff line number Diff line change
Expand Up @@ -1282,8 +1282,8 @@ def test_find_by_guid_not_found(standard_config):
(2022, 2022, True), # Exact match
(2023, 2022, True), # Plex year is one more than input year
(2021, 2022, True), # Plex year is one less than input year
(2024, 2022, False), # Plex year is more than one more than input year
(2020, 2022, False), # Plex year is more than one less than input year
(2025, 2022, False), # Plex year is more than two more than input year
(2020, 2023, False), # Plex year is more than two less than input year
],
)
def test_match_year(standard_config, plex_year, year, expected):
Expand Down

0 comments on commit 65bca0f

Please sign in to comment.