diff --git a/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs b/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs
index b23e224..e438bb0 100644
--- a/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs
+++ b/Jellyfin.Plugin.MetaShark/Configuration/PluginConfiguration.cs
@@ -49,6 +49,10 @@ public class PluginConfiguration : BasePluginConfiguration
/// 是否获取电影系列信息
///
public bool EnableTmdbCollection { get; set; } = false;
+ ///
+ /// 是否获取tmdb分级信息
+ ///
+ public bool EnableTmdbOfficialRating { get; set; } = false;
public string TmdbApiKey { get; set; } = string.Empty;
diff --git a/Jellyfin.Plugin.MetaShark/Configuration/configPage.html b/Jellyfin.Plugin.MetaShark/Configuration/configPage.html
index 1d39105..d684d6e 100644
--- a/Jellyfin.Plugin.MetaShark/Configuration/configPage.html
+++ b/Jellyfin.Plugin.MetaShark/Configuration/configPage.html
@@ -93,6 +93,14 @@
勾选后,刮削会变慢,会自动创建电影系列合集(需先在媒体库配置中打开自动添加到合集功能)
+
+
+
勾选后,刮削会变慢
+
@@ -131,6 +139,7 @@
document.querySelector('#EnableTmdbSearch').checked = config.EnableTmdbSearch;
document.querySelector('#EnableTmdbBackdrop').checked = config.EnableTmdbBackdrop;
document.querySelector('#EnableTmdbCollection').checked = config.EnableTmdbCollection;
+ document.querySelector('#EnableTmdbOfficialRating').checked = config.EnableTmdbOfficialRating;
document.querySelector('#TmdbApiKey').value = config.TmdbApiKey;
document.querySelector('#TmdbHost').value = config.TmdbHost;
@@ -151,6 +160,7 @@
config.EnableTmdbSearch = document.querySelector('#EnableTmdbSearch').checked;
config.EnableTmdbBackdrop = document.querySelector('#EnableTmdbBackdrop').checked;
config.EnableTmdbCollection = document.querySelector('#EnableTmdbCollection').checked;
+ config.EnableTmdbOfficialRating = document.querySelector('#EnableTmdbOfficialRating').checked;
config.TmdbApiKey = document.querySelector('#TmdbApiKey').value;
config.TmdbHost = document.querySelector('#TmdbHost').value;
ApiClient.updatePluginConfiguration(TemplateConfig.pluginUniqueId, config).then(function (result) {
diff --git a/Jellyfin.Plugin.MetaShark/Controllers/MetaBotController.cs b/Jellyfin.Plugin.MetaShark/Controllers/MetaSharkController.cs
similarity index 100%
rename from Jellyfin.Plugin.MetaShark/Controllers/MetaBotController.cs
rename to Jellyfin.Plugin.MetaShark/Controllers/MetaSharkController.cs
diff --git a/Jellyfin.Plugin.MetaShark/Providers/MovieProvider.cs b/Jellyfin.Plugin.MetaShark/Providers/MovieProvider.cs
index 559b81b..473e917 100644
--- a/Jellyfin.Plugin.MetaShark/Providers/MovieProvider.cs
+++ b/Jellyfin.Plugin.MetaShark/Providers/MovieProvider.cs
@@ -164,13 +164,23 @@ namespace Jellyfin.Plugin.MetaShark.Providers
// 通过imdb获取电影系列信息
if (this.config.EnableTmdbCollection && !string.IsNullOrEmpty(tmdbId))
{
- var collectionName = await this.GetBelongsToCollection(info, tmdbId, cancellationToken).ConfigureAwait(false);
+ var collectionName = await this.GetTmdbCollection(info, tmdbId, cancellationToken).ConfigureAwait(false);
if (!string.IsNullOrEmpty(collectionName))
{
movie.CollectionName = collectionName;
}
}
+ // 通过imdb获取电影分级信息
+ if (this.config.EnableTmdbOfficialRating && !string.IsNullOrEmpty(tmdbId))
+ {
+ var officialRating = await this.GetTmdbOfficialRating(info, tmdbId, cancellationToken).ConfigureAwait(false);
+ if (!string.IsNullOrEmpty(officialRating))
+ {
+ movie.OfficialRating = officialRating;
+ }
+ }
+
result.Item = movie;
result.QueriedById = true;
@@ -203,6 +213,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
var movie = new Movie
{
Name = movieResult.Title ?? movieResult.OriginalTitle,
+ OriginalTitle = movieResult.OriginalTitle,
Overview = movieResult.Overview?.Replace("\n\n", "\n", StringComparison.InvariantCulture),
Tagline = movieResult.Tagline,
ProductionLocations = movieResult.ProductionCountries.Select(pc => pc.Name).ToArray()
@@ -226,6 +237,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
}
movie.CommunityRating = (float)System.Math.Round(movieResult.VoteAverage, 2);
+ movie.OfficialRating = this.GetTmdbOfficialRatingByData(movieResult, info.MetadataCountryCode);
movie.PremiereDate = movieResult.ReleaseDate;
movie.ProductionYear = movieResult.ReleaseDate?.Year;
@@ -349,7 +361,7 @@ namespace Jellyfin.Plugin.MetaShark.Providers
}
- private async Task GetBelongsToCollection(MovieInfo info, string tmdbId, CancellationToken cancellationToken)
+ private async Task GetTmdbCollection(MovieInfo info, string tmdbId, CancellationToken cancellationToken)
{
var movieResult = await _tmdbApi
@@ -363,6 +375,50 @@ namespace Jellyfin.Plugin.MetaShark.Providers
return null;
}
+ private async Task GetTmdbOfficialRating(ItemLookupInfo info, string tmdbId, CancellationToken cancellationToken)
+ {
+
+ var movieResult = await _tmdbApi
+ .GetMovieAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, info.MetadataLanguage, cancellationToken)
+ .ConfigureAwait(false);
+
+ return GetTmdbOfficialRatingByData(movieResult, info.MetadataCountryCode);
+ }
+
+ private String? GetTmdbOfficialRatingByData(TMDbLib.Objects.Movies.Movie? movieResult, string preferredCountryCode)
+ {
+ if (movieResult == null || movieResult.Releases?.Countries == null)
+ {
+ return null;
+ }
+
+ var releases = movieResult.Releases.Countries.Where(i => !string.IsNullOrWhiteSpace(i.Certification)).ToList();
+
+ var ourRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, preferredCountryCode, StringComparison.OrdinalIgnoreCase));
+ var usRelease = releases.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
+ var minimumRelease = releases.FirstOrDefault();
+
+ if (ourRelease != null)
+ {
+ var ratingPrefix = string.Equals(preferredCountryCode, "us", StringComparison.OrdinalIgnoreCase) ? string.Empty : preferredCountryCode + "-";
+ var newRating = ratingPrefix + ourRelease.Certification;
+
+ newRating = newRating.Replace("de-", "FSK-", StringComparison.OrdinalIgnoreCase);
+
+ return newRating;
+ }
+ else if (usRelease != null)
+ {
+ return usRelease.Certification;
+ }
+ else if (minimumRelease != null)
+ {
+ return minimumRelease.Certification;
+ }
+
+ return null;
+ }
+
///
diff --git a/Jellyfin.Plugin.MetaShark/Providers/SeriesProvider.cs b/Jellyfin.Plugin.MetaShark/Providers/SeriesProvider.cs
index 6fcabb4..9130c84 100644
--- a/Jellyfin.Plugin.MetaShark/Providers/SeriesProvider.cs
+++ b/Jellyfin.Plugin.MetaShark/Providers/SeriesProvider.cs
@@ -136,6 +136,16 @@ namespace Jellyfin.Plugin.MetaShark.Providers
item.SetProviderId(MetadataProvider.Tmdb, tmdbId);
}
+ // 通过imdb获取电影分级信息
+ if (this.config.EnableTmdbOfficialRating && !string.IsNullOrEmpty(tmdbId))
+ {
+ var officialRating = await this.GetTmdbOfficialRating(info, tmdbId, cancellationToken).ConfigureAwait(false);
+ if (!string.IsNullOrEmpty(officialRating))
+ {
+ item.OfficialRating = officialRating;
+ }
+ }
+
result.Item = item;
result.QueriedById = true;
@@ -215,6 +225,42 @@ namespace Jellyfin.Plugin.MetaShark.Providers
return null;
}
+ private async Task GetTmdbOfficialRating(ItemLookupInfo info, string tmdbId, CancellationToken cancellationToken)
+ {
+
+ var tvShow = await _tmdbApi
+ .GetSeriesAsync(Convert.ToInt32(tmdbId, CultureInfo.InvariantCulture), info.MetadataLanguage, info.MetadataLanguage, cancellationToken)
+ .ConfigureAwait(false);
+ return this.GetTmdbOfficialRatingByData(tvShow, info.MetadataCountryCode);
+ }
+
+ private String GetTmdbOfficialRatingByData(TvShow? tvShow, string preferredCountryCode)
+ {
+ if (tvShow != null)
+ {
+ var contentRatings = tvShow.ContentRatings.Results ?? new List();
+
+ var ourRelease = contentRatings.FirstOrDefault(c => string.Equals(c.Iso_3166_1, preferredCountryCode, StringComparison.OrdinalIgnoreCase));
+ var usRelease = contentRatings.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
+ var minimumRelease = contentRatings.FirstOrDefault();
+
+ if (ourRelease != null)
+ {
+ return ourRelease.Rating;
+ }
+ else if (usRelease != null)
+ {
+ return usRelease.Rating;
+ }
+ else if (minimumRelease != null)
+ {
+ return minimumRelease.Rating;
+ }
+ }
+
+ return null;
+ }
+
private Series MapTvShowToSeries(TvShow seriesResult, string preferredCountryCode)
{
var series = new Series
@@ -281,24 +327,8 @@ namespace Jellyfin.Plugin.MetaShark.Providers
}
}
series.SetProviderId(Plugin.ProviderId, MetaSource.Tmdb);
- var contentRatings = seriesResult.ContentRatings.Results ?? new List();
+ series.OfficialRating = this.GetTmdbOfficialRatingByData(seriesResult, preferredCountryCode);
- var ourRelease = contentRatings.FirstOrDefault(c => string.Equals(c.Iso_3166_1, preferredCountryCode, StringComparison.OrdinalIgnoreCase));
- var usRelease = contentRatings.FirstOrDefault(c => string.Equals(c.Iso_3166_1, "US", StringComparison.OrdinalIgnoreCase));
- var minimumRelease = contentRatings.FirstOrDefault();
-
- if (ourRelease != null)
- {
- series.OfficialRating = ourRelease.Rating;
- }
- else if (usRelease != null)
- {
- series.OfficialRating = usRelease.Rating;
- }
- else if (minimumRelease != null)
- {
- series.OfficialRating = minimumRelease.Rating;
- }
return series;
}