Skip to content

Commit

Permalink
Merge pull request #2 from Amateur-God:unmonitor-hotfix
Browse files Browse the repository at this point in the history
Hot fix to unmonitor watched episodes but only delete after the DAYS period (Previously wouldnt do either if within DAYS period)
  • Loading branch information
Amateur-God authored Feb 17, 2024
2 parents 1cfadd8 + ee7acfc commit a04001f
Showing 1 changed file with 8 additions and 8 deletions.
16 changes: 8 additions & 8 deletions EmbyArrSync.py
Original file line number Diff line number Diff line change
Expand Up @@ -291,18 +291,18 @@ def main():
episode_ids = [episode_id]
air_date_utc = datetime.strptime(ep['airDateUtc'], '%Y-%m-%dT%H:%M:%SZ')
do_not_delete = datetime.now() - timedelta(days=DAYS)
# Unmonitor this specific episode in Sonarr
unmonitor_episodes([episode_id])
print(f"Unmonitored episode: {item_info}")
if air_date_utc < do_not_delete:
# Unmonitor this specific episode in Sonarr
unmonitor_episodes([episode_id])
print(f"Unmonitored episode: {item_info}")
#delete the episode from Emby (OPTIONAL), Sonarr and file system
delete_episode_file(series_id, season_number, episode_number, episode_name, series_name)
if EMBY_DELETE:
delete_item(item['Id'], item_info)
if not EMBY_DELETE:
print(f"Emby library update handled by Sonarr skipping Emby library delete for {series_name}: {episode_name} of Season{season_number}")
else:
print(f"{series_name}: {episode_name} is within the do_not_delete range.")
print(f"{series_name}: {episode_name} aired within the past {DAYS} days. Not Deleted")
else:
print(f"TVDB ID not found for series '{series_name}'.")

Expand All @@ -324,18 +324,18 @@ def main():
if release_dates: # Ensure there's at least one valid date
earliest_release_date = min(release_dates)
Do_not_delete = datetime.now() - timedelta(days=DAYS)
# Unmonitor movies in Radarr
unmonitor_movies(radarr_id, movie_name)
print(f"Unmonitored movie: {movie_name} with TMDB ID {tmdb_id}")
if earliest_release_date < Do_not_delete:
# Unmonitor movies in Radarr
unmonitor_movies(radarr_id, movie_name)
print(f"Unmonitored movie: {movie_name} with TMDB ID {tmdb_id}")
#delete the episode from Emby(OPTIONAL), Radarr and file system
delete_movie_file(radarr_id, movie_name)
if EMBY_DELETE:
delete_item(item['Id'], item_info)
if not EMBY_DELETE:
print(f"Emby library update handled by Sonarr skipping Emby library delete for {movie_name}")
else:
print(f"Not eligible for unmonitor/delete: {movie_name}")
print(f"{movie_name} aired within the past {DAYS} days. Not Deleted")
else:
print(f"No valid release dates available for comparison: {movie_name}")
else:
Expand Down

0 comments on commit a04001f

Please sign in to comment.