Skip to content

Commit

Permalink
Adds a option to include specials for missing episode provider (#144)
Browse files Browse the repository at this point in the history
  • Loading branch information
scampower3 authored May 22, 2024
1 parent f79c195 commit 41be79e
Show file tree
Hide file tree
Showing 3 changed files with 18 additions and 0 deletions.
5 changes: 5 additions & 0 deletions Jellyfin.Plugin.Tvdb/Configuration/PluginConfiguration.cs
Original file line number Diff line number Diff line change
Expand Up @@ -54,5 +54,10 @@ public int MetadataUpdateInHours
/// Gets or sets the fallback languages.
/// </summary>
public string FallbackLanguages { get; set; } = string.Empty;

/// <summary>
/// Gets or sets a value indicating whether to include missing specials.
/// </summary>
public bool IncludeMissingSpecials { get; set; } = true;
}
}
6 changes: 6 additions & 0 deletions Jellyfin.Plugin.Tvdb/Configuration/config.html
Original file line number Diff line number Diff line change
Expand Up @@ -49,6 +49,10 @@ <h2 class="sectionTitle">TheTVDB Settings:</h2>
If the preferred metadata language is not available, the plugin will attempt to retrieve metadata in these languages (in the order listed). Separate language codes with commas (e.g., en, fr, de, ja).
</div>
</div>
<label class="checkboxContainer">
<input is="emby-checkbox" type="checkbox" id="includeMissingSpecials" />
<span>Include missing specials</span>
</label>
<br />
<div>
<button is="emby-button" type="submit" data-theme="b" class="raised button-submit block">
Expand All @@ -72,6 +76,7 @@ <h2 class="sectionTitle">TheTVDB Settings:</h2>
document.getElementById('cacheDurationInDays').value = config.CacheDurationInDays;
document.getElementById('metadataUpdateInHours').value = config.MetadataUpdateInHours;
document.getElementById('fallbackLanguages').value = config.FallbackLanguages;
document.getElementById('includeMissingSpecials').checked = config.IncludeMissingSpecials || true;
Dashboard.hideLoadingMsg();
});
},
Expand All @@ -85,6 +90,7 @@ <h2 class="sectionTitle">TheTVDB Settings:</h2>
config.CacheDurationInDays = document.getElementById('cacheDurationInDays').value;
config.MetadataUpdateInHours = document.getElementById('metadataUpdateInHours').value;
config.FallbackLanguages = document.getElementById('fallbackLanguages').value;
config.IncludeMissingSpecials = document.getElementById('includeMissingSpecials').checked;
ApiClient.updatePluginConfiguration(TvdbPluginConfiguration.uniquePluginId, config).then(function (result) {
Dashboard.processPluginConfigurationUpdateResult(result);
});
Expand Down
7 changes: 7 additions & 0 deletions Jellyfin.Plugin.Tvdb/Providers/TvdbMissingEpisodeProvider.cs
Original file line number Diff line number Diff line change
Expand Up @@ -62,6 +62,8 @@ public TvdbMissingEpisodeProvider(
_logger = logger;
}

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

private static bool EpisodeExists(EpisodeBaseRecord episodeRecord, IReadOnlyList<Episode> existingEpisodes)
{
return existingEpisodes.Any(episode => EpisodeEquals(episode, episodeRecord));
Expand Down Expand Up @@ -161,6 +163,11 @@ private async Task HandleSeries(Series series)

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

if (!IncludeMissingSpecials)
{
allEpisodes = allEpisodes.Where(e => e.SeasonNumber != 0).ToList();
}

var allSeasons = allEpisodes
.Where(ep => ep.SeasonNumber.HasValue)
.Select(ep => ep.SeasonNumber!.Value)
Expand Down

0 comments on commit 41be79e

Please sign in to comment.