Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Remove All Missing Episodes On Refresh #176

Open
wants to merge 3 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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 the metadata update in hours for the Check for Metadata Updates Scheduled Task.
Expand Down
23 changes: 16 additions & 7 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>
<div class="sectionTitleContainer flex align-items-center">
<h2 class="sectionTitle">Check for Metadata Updates Scheduled Task Settings:</h2>
Expand Down Expand Up @@ -102,9 +109,10 @@ <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;

// 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;
document.getElementById('updateSeriesScheduledTask').checked = config.UpdateSeriesScheduledTask;
Expand All @@ -124,9 +132,10 @@ <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;

// 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;
config.UpdateSeriesScheduledTask = document.getElementById('updateSeriesScheduledTask').checked;
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 ?
Enumerable.Empty<EpisodeBaseRecord>().ToList() :
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 ?
Enumerable.Empty<EpisodeBaseRecord>().ToList() :
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