Skip to content

Commit 73c372b

Browse files
committed
fix: only download select content ratings by default
1 parent 2f50967 commit 73c372b

File tree

3 files changed

+18
-3
lines changed

3 files changed

+18
-3
lines changed

Shoko.Server/Models/TMDB/TMDB_Show.cs

+7-2
Original file line numberDiff line numberDiff line change
@@ -192,8 +192,9 @@ public TMDB_Show(int showId)
192192
/// Populate the fields from the raw data.
193193
/// </summary>
194194
/// <param name="show">The raw TMDB Tv Show object.</param>
195+
/// <param name="crLanguages">Content rating languages.</param>
195196
/// <returns>True if any of the fields have been updated.</returns>
196-
public bool Populate(TvShow show)
197+
public bool Populate(TvShow show, HashSet<TitleLanguage>? crLanguages)
197198
{
198199
// Don't trust 'show.Name' for the English title since it will fall-back
199200
// to the original language if there is no title in English.
@@ -216,7 +217,11 @@ public bool Populate(TvShow show)
216217
),
217218
UpdateProperty(
218219
ContentRatings,
219-
show.ContentRatings.Results.Select(rating => new TMDB_ContentRating(rating.Iso_3166_1, rating.Rating)).OrderBy(c => c.CountryCode).ToList(),
220+
show.ContentRatings.Results
221+
.Select(rating => new TMDB_ContentRating(rating.Iso_3166_1, rating.Rating))
222+
.Where(c => crLanguages is null || crLanguages.Contains(c.Language))
223+
.OrderBy(c => c.CountryCode)
224+
.ToList(),
220225
v => ContentRatings = v,
221226
(a, b) => string.Equals(string.Join(",", a.Select(a1 => a1.ToString())), string.Join(",", b.Select(b1 => b1.ToString())))
222227
),

Shoko.Server/Providers/TMDB/TmdbMetadataService.cs

+2-1
Original file line numberDiff line numberDiff line change
@@ -909,8 +909,9 @@ public async Task<bool> UpdateShow(int showId, bool forceRefresh = false, bool d
909909
var settings = _settingsProvider.GetSettings();
910910
var preferredTitleLanguages = settings.TMDB.DownloadAllTitles ? null : Languages.PreferredNamingLanguages.Select(a => a.Language).ToHashSet();
911911
var preferredOverviewLanguages = settings.TMDB.DownloadAllOverviews ? null : Languages.PreferredDescriptionNamingLanguages.Select(a => a.Language).ToHashSet();
912+
var contentRantingLanguages = settings.TMDB.DownloadAllContentRatings ? null : Languages.PreferredNamingLanguages.Select(a => a.Language).Concat(Languages.PreferredEpisodeNamingLanguages.Select(a => a.Language)).ToHashSet();
912913
var shouldFireEvents = !quickRefresh || xrefs.Count > 0;
913-
var updated = tmdbShow.Populate(show);
914+
var updated = tmdbShow.Populate(show, contentRantingLanguages);
914915
var (titlesUpdated, overviewsUpdated) = UpdateTitlesAndOverviewsWithTuple(tmdbShow, show.Translations, preferredTitleLanguages, preferredOverviewLanguages);
915916
updated = titlesUpdated || overviewsUpdated || updated;
916917
updated = UpdateShowExternalIDs(tmdbShow, show.ExternalIds) || updated;

Shoko.Server/Settings/TMDBSettings.cs

+9
Original file line numberDiff line numberDiff line change
@@ -40,6 +40,15 @@ public class TMDBSettings
4040
/// </summary>
4141
public bool DownloadAllOverviews { get; set; } = false;
4242

43+
/// <summary>
44+
/// Indicates that all content-ratings should be stored locally for the TMDB
45+
/// entity, otherwise it will use
46+
/// <seealso cref="LanguageSettings.SeriesTitleLanguageOrder"/> or
47+
/// <seealso cref="LanguageSettings.EpisodeTitleLanguageOrder"/> depending
48+
/// on the entity type to determine which content-ratings to store locally.
49+
/// </summary>
50+
public bool DownloadAllContentRatings { get; set; } = false;
51+
4352
/// <summary>
4453
/// Image language preference order, in text form for storage.
4554
/// </summary>

0 commit comments

Comments
 (0)