aboutsummaryrefslogtreecommitdiff
path: root/Jellyfin.Api/Controllers/ItemUpdateController.cs
diff options
context:
space:
mode:
authorCody Robibero <cody@robibe.ro>2023-02-23 07:04:44 -0700
committerGitHub <noreply@github.com>2023-02-23 07:04:44 -0700
commitecb5c48538fb46b4aab744d165bd525bd8a53cd3 (patch)
treef2fedbedf3556cc1c3c1036ea14fd373f52c15d1 /Jellyfin.Api/Controllers/ItemUpdateController.cs
parenteb3d187f27c34112689d37c50a1f734835a33ef3 (diff)
parent6300d01fcceba56932741251443f5b2aa4f76de2 (diff)
Merge pull request #8526 from Shadowghost/rating-overhaul
Diffstat (limited to 'Jellyfin.Api/Controllers/ItemUpdateController.cs')
-rw-r--r--Jellyfin.Api/Controllers/ItemUpdateController.cs49
1 files changed, 45 insertions, 4 deletions
diff --git a/Jellyfin.Api/Controllers/ItemUpdateController.cs b/Jellyfin.Api/Controllers/ItemUpdateController.cs
index 230fbfb2c..9c7148241 100644
--- a/Jellyfin.Api/Controllers/ItemUpdateController.cs
+++ b/Jellyfin.Api/Controllers/ItemUpdateController.cs
@@ -98,7 +98,7 @@ public class ItemUpdateController : BaseJellyfinApiController
}).ToList());
}
- UpdateItem(request, item);
+ await UpdateItem(request, item).ConfigureAwait(false);
item.OnMetadataChanged();
@@ -147,7 +147,7 @@ public class ItemUpdateController : BaseJellyfinApiController
var info = new MetadataEditorInfo
{
- ParentalRatingOptions = _localizationManager.GetParentalRatings().ToArray(),
+ ParentalRatingOptions = _localizationManager.GetParentalRatings().ToList(),
ExternalIdInfos = _providerManager.GetExternalIdInfos(item).ToArray(),
Countries = _localizationManager.GetCountries().ToArray(),
Cultures = _localizationManager.GetCultures().ToArray()
@@ -224,7 +224,7 @@ public class ItemUpdateController : BaseJellyfinApiController
return NoContent();
}
- private void UpdateItem(BaseItemDto request, BaseItem item)
+ private async Task UpdateItem(BaseItemDto request, BaseItem item)
{
item.Name = request.Name;
item.ForcedSortName = request.ForcedSortName;
@@ -266,9 +266,50 @@ public class ItemUpdateController : BaseJellyfinApiController
item.EndDate = request.EndDate.HasValue ? NormalizeDateTime(request.EndDate.Value) : null;
item.PremiereDate = request.PremiereDate.HasValue ? NormalizeDateTime(request.PremiereDate.Value) : null;
item.ProductionYear = request.ProductionYear;
- item.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating;
+
+ request.OfficialRating = string.IsNullOrWhiteSpace(request.OfficialRating) ? null : request.OfficialRating;
+ item.OfficialRating = request.OfficialRating;
item.CustomRating = request.CustomRating;
+ if (item is Series rseries)
+ {
+ foreach (Season season in rseries.Children)
+ {
+ season.OfficialRating = request.OfficialRating;
+ season.CustomRating = request.CustomRating;
+ season.OnMetadataChanged();
+ await season.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
+
+ foreach (Episode ep in season.Children)
+ {
+ ep.OfficialRating = request.OfficialRating;
+ ep.CustomRating = request.CustomRating;
+ ep.OnMetadataChanged();
+ await ep.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
+ }
+ }
+ }
+ else if (item is Season season)
+ {
+ foreach (Episode ep in season.Children)
+ {
+ ep.OfficialRating = request.OfficialRating;
+ ep.CustomRating = request.CustomRating;
+ ep.OnMetadataChanged();
+ await ep.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
+ }
+ }
+ else if (item is MusicAlbum album)
+ {
+ foreach (BaseItem track in album.Children)
+ {
+ track.OfficialRating = request.OfficialRating;
+ track.CustomRating = request.CustomRating;
+ track.OnMetadataChanged();
+ await track.UpdateToRepositoryAsync(ItemUpdateType.MetadataEdit, CancellationToken.None).ConfigureAwait(false);
+ }
+ }
+
if (request.ProductionLocations is not null)
{
item.ProductionLocations = request.ProductionLocations;