Skip to content

Commit

Permalink
Remove All Missing Episodes On Refresh (#176)
Browse files Browse the repository at this point in the history
  • Loading branch information
scampower3 authored Oct 29, 2024
1 parent 6df261b commit 4eee979
Show file tree
Hide file tree
Showing 3 changed files with 36 additions and 12 deletions.
11 changes: 8 additions & 3 deletions Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -52,14 +52,19 @@ public int CacheDurationInDays
public bool ImportSeasonName { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether to include missing specials.
/// Gets or sets a value indicating whether to fallback to original language.
/// </summary>
public bool FallbackToOriginalLanguage { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether to include missing specials for Missing Episode Provider.
/// </summary>
public bool IncludeMissingSpecials { get; set; } = true;

/// <summary>
/// Gets or sets a value indicating whether to fallback to original language.
/// Gets or sets a value indicating whether to remove all missing episodes on refresh for Missing Episode Provider.
/// </summary>
public bool FallbackToOriginalLanguage { get; set; } = false;
public bool RemoveAllMissingEpisodesOnRefresh { get; set; } = false;

/// <summary>
/// Gets or sets a value indicating whether to include original country in tags.
Expand Down
23 changes: 18 additions & 5 deletions Jellyfin.Plugin.Tvdb/Configuration/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -44,15 +44,22 @@ <h2 class="sectionTitle">TheTVDB Settings:</h2>
</div>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="importSeasonName" />
<span>Import season name from provider.</span>
<span>Import season name from provider</span>
</label>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="fallbackToOriginalLanguage" />
<span>Fallback to Original Language (Last resort if other fallback languages fails)</span>
</label>
<div class="sectionTitleContainer flex align-items-center">
<h2 class="sectionTitle">Missing Episode Provider Settings:</h2>
</div>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="includeMissingSpecials" />
<span>Include missing specials</span>
</label>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="fallbackToOriginalLanguage" />
<span>Fallback to Original Language (Last resort if other fallback languages fails)</span>
<input is="emby-checkbox" type="checkbox" id="removeAllMissingEpisodesOnRefresh" />
<span>Remove All Missing Episodes On Refresh</span>
</label>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="includeOriginalCountryInTags" />
Expand Down Expand Up @@ -106,9 +113,12 @@ <h2 class="sectionTitle">Check for Metadata Updates Scheduled Task Settings:</h2
document.getElementById('cacheDurationInDays').value = config.CacheDurationInDays;
document.getElementById('fallbackLanguages').value = config.FallbackLanguages;
document.getElementById('importSeasonName').checked = config.ImportSeasonName
document.getElementById('includeMissingSpecials').checked = config.IncludeMissingSpecials;
document.getElementById('fallbackToOriginalLanguage').checked = config.FallbackToOriginalLanguage;
document.getElementById('includeOriginalCountryInTags').checked = config.IncludeOriginalCountryInTags;

// Missing Episode Provider Settings
document.getElementById('includeMissingSpecials').checked = config.IncludeMissingSpecials;
document.getElementById('removeAllMissingEpisodesOnRefresh').checked = config.RemoveAllMissingEpisodesOnRefresh;

// Check for Metadata Updates Scheduled Task Settings
document.getElementById('metadataUpdateInHours').value = config.MetadataUpdateInHours;
Expand All @@ -129,9 +139,12 @@ <h2 class="sectionTitle">Check for Metadata Updates Scheduled Task Settings:</h2
config.CacheDurationInDays = document.getElementById('cacheDurationInDays').value;
config.FallbackLanguages = document.getElementById('fallbackLanguages').value;
config.ImportSeasonName = document.getElementById('importSeasonName').checked;
config.IncludeMissingSpecials = document.getElementById('includeMissingSpecials').checked;
config.FallbackToOriginalLanguage = document.getElementById('fallbackToOriginalLanguage').checked;
config.IncludeOriginalCountryInTags = document.getElementById('includeOriginalCountryInTags').checked;

// Missing Episode Provider Settings
config.IncludeMissingSpecials = document.getElementById('includeMissingSpecials').checked;
config.RemoveAllMissingEpisodesOnRefresh = document.getElementById('removeAllMissingEpisodesOnRefresh').checked;

//Check for Metadata Updates Scheduled Task Settings
config.MetadataUpdateInHours = document.getElementById('metadataUpdateInHours').value;
Expand Down
14 changes: 10 additions & 4 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -64,6 +64,8 @@ public TvdbMissingEpisodeProvider(

private static bool IncludeMissingSpecials => TvdbPlugin.Instance?.Configuration.IncludeMissingSpecials ?? false;

private static bool RemoveAllMissingEpisodesOnRefresh => TvdbPlugin.Instance?.Configuration.RemoveAllMissingEpisodesOnRefresh ?? false;

private static bool EpisodeExists(EpisodeBaseRecord episodeRecord, IReadOnlyList<Episode> existingEpisodes)
{
return existingEpisodes.Any(episode => EpisodeEquals(episode, episodeRecord));
Expand Down Expand Up @@ -146,7 +148,9 @@ private async Task HandleSeries(Series series)
}
}

var allEpisodes = await GetAllEpisodes(tvdbId, series.DisplayOrder, series.GetPreferredMetadataLanguage()).ConfigureAwait(false);
var allEpisodes = RemoveAllMissingEpisodesOnRefresh
? Array.Empty<EpisodeBaseRecord>()
: await GetAllEpisodes(tvdbId, series.DisplayOrder, series.GetPreferredMetadataLanguage()).ConfigureAwait(false);

if (!IncludeMissingSpecials)
{
Expand Down Expand Up @@ -189,9 +193,11 @@ private async Task HandleSeason(Season season, IReadOnlyList<EpisodeBaseRecord>?
}

var tvdbId = series.GetTvdbId();
var allEpisodes = allEpisodesRemote ?? await GetAllEpisodes(tvdbId, series.DisplayOrder, season.GetPreferredMetadataLanguage())
.ConfigureAwait(false);

var allEpisodes = RemoveAllMissingEpisodesOnRefresh
? Array.Empty<EpisodeBaseRecord>()
: allEpisodesRemote ??
await GetAllEpisodes(tvdbId, series.DisplayOrder, season.GetPreferredMetadataLanguage())
.ConfigureAwait(false);
// Skip if called from HandleSeries since it will be filtered there, allEpisodesRemote will not be null when called from HandleSeries
// Remove specials if IncludeMissingSpecials is false
if (allEpisodesRemote is null && !IncludeMissingSpecials)
Expand Down

0 comments on commit 4eee979

Please sign in to comment.