Skip to content

Commit

Permalink
Skip incremental update since Anilist combines them anyway
Browse files Browse the repository at this point in the history
  • Loading branch information
reconman committed Jan 1, 2024
1 parent 69fe8b0 commit 710bc0a
Showing 1 changed file with 5 additions and 14 deletions.
19 changes: 5 additions & 14 deletions plexanisync/anilist.py
Original file line number Diff line number Diff line change
Expand Up @@ -570,7 +570,7 @@ def __update_entry(
"AniList entry to completed"
)

self.__update_episode_incremental(series, watched_episode_count, anilist_episodes_watched, "COMPLETED", plex_rating)
self.__update_episodes(series, watched_episode_count, "COMPLETED", plex_rating)
return
elif (
watched_episode_count > anilist_episodes_watched
Expand All @@ -584,7 +584,7 @@ def __update_entry(
f"episodes | updating AniList entry to {new_status}"
)

self.__update_episode_incremental(series, watched_episode_count, anilist_episodes_watched, new_status, plex_rating)
self.__update_episodes(series, watched_episode_count, new_status, plex_rating)
return
elif watched_episode_count == anilist_episodes_watched:
if plex_rating and series.score != plex_rating and self.graphql.sync_ratings:
Expand Down Expand Up @@ -635,19 +635,10 @@ def __update_entry(
"AniList total episodes was 0 so most likely invalid data"
)

def __update_episode_incremental(
self, series: AnilistSeries, watched_episode_count: int, anilist_episodes_watched: int, new_status: str,
plex_rating: int
def __update_episodes(
self, series: AnilistSeries, watched_episode_count: int, new_status: str, plex_rating: int
):
# calculate episode difference and iterate up so activity stream lists
# episodes watched if episode difference exceeds 32 only update most
# recent as otherwise will flood the notification feed
episode_difference = watched_episode_count - anilist_episodes_watched
if episode_difference > 32:
self.graphql.update_series(series.anilist_id, watched_episode_count, new_status, plex_rating)
else:
for current_episodes_watched in range(anilist_episodes_watched + 1, watched_episode_count + 1):
self.graphql.update_series(series.anilist_id, current_episodes_watched, new_status, plex_rating)
self.graphql.update_series(series.anilist_id, watched_episode_count, new_status, plex_rating)

def __retrieve_season_mappings(self, title: str, season: int) -> List[AnilistCustomMapping]:
season_mappings: List[AnilistCustomMapping] = []
Expand Down

0 comments on commit 710bc0a

Please sign in to comment.