From 6277da39710a06c10f1192fa22f0117adf21bb5a Mon Sep 17 00:00:00 2001 From: RandomNinjaAtk Date: Sat, 4 Nov 2023 14:44:55 -0400 Subject: [PATCH] v1.5 - If non-daily series keep entire season worth of media #105 This change ignores your custom episode count for series that are not considered daily and keeps the number of episodes that match the latest season episode count. Which is likely more desirable for TV series that want to have a rolling episode count, to ensure you can pickup watching the series at any given time during the latest season and miss anything... --- sonarr/DailySeriesEpisodeTrimmer.bash | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/sonarr/DailySeriesEpisodeTrimmer.bash b/sonarr/DailySeriesEpisodeTrimmer.bash index 8a83c21..412402a 100644 --- a/sonarr/DailySeriesEpisodeTrimmer.bash +++ b/sonarr/DailySeriesEpisodeTrimmer.bash @@ -1,5 +1,5 @@ #!/usr/bin/env bash -scriptVersion="1.4" +scriptVersion="1.5" scriptName="SeriesEpisodeTrimmer" #### Import Settings @@ -45,14 +45,19 @@ else fi done fi + # Verify series is marked as "daily" type by sonarr, skip if not... if [ $seriesType != "daily" ] && [ "$tagMatch" == "false" ]; then log "$seriesTitle (ID:$seriesId) :: ERROR :: Series does not match TYPE: Daily or TAG: $sonarrSeriesEpisodeTrimmerTag, skipping..." exit fi - -# Skip processing if less than 14 episodes were found to be downloaded +# If non-daily series, set maximum episode count to match latest season total episode count +if [ $seriesType != "daily" ]; then + maximumDailyEpisodes=$(echo "$seriesData" | jq -r ".seasons | sort_by(.seasonNumber) | reverse | .[].statistics.totalEpisodeCount" | head -n1) +fi + +# Skip processing if less than the maximumDailyEpisodes setting were found to be downloaded if [ $seriesEpisodeIdsCount -lt $maximumDailyEpisodes ]; then log "$seriesTitle (ID:$seriesId) :: ERROR :: Series has not exceeded $maximumDailyEpisodes downloaded episodes ($seriesEpisodeIdsCount files found), skipping..." exit