Recursively update rating
This commit is contained in:
parent
ed2280a060
commit
c8d80450e0
|
@ -98,7 +98,7 @@ public class ItemUpdateController : BaseJellyfinApiController
|
||||||
}).ToList());
|
}).ToList());
|
||||||
}
|
}
|
||||||
|
|
||||||
UpdateItem(request, item);
|
await UpdateItem(request, item).ConfigureAwait(false);
|
||||||
|
|
||||||
item.OnMetadataChanged();
|
item.OnMetadataChanged();
|
||||||
|
|
||||||
|
@ -224,7 +224,7 @@ public class ItemUpdateController : BaseJellyfinApiController
|
||||||
return NoContent();
|
return NoContent();
|
||||||
}
|
}
|
||||||
|
|
||||||
private void UpdateItem(BaseItemDto request, BaseItem item)
|
private async Task UpdateItem(BaseItemDto request, BaseItem item)
|
||||||
{
|
{
|
||||||
item.Name = request.Name;
|
item.Name = request.Name;
|
||||||
item.ForcedSortName = request.ForcedSortName;
|
item.ForcedSortName = request.ForcedSortName;
|
||||||
|
@ -266,9 +266,50 @@ public class ItemUpdateController : BaseJellyfinApiController
|
||||||
item.EndDate = request.EndDate.HasValue ? NormalizeDateTime(request.EndDate.Value) : null;
|
item.EndDate = request.EndDate.HasValue ? NormalizeDateTime(request.EndDate.Value) : null;
|
||||||
item.PremiereDate = request.PremiereDate.HasValue ? NormalizeDateTime(request.PremiereDate.Value) : null;
|
item.PremiereDate = request.PremiereDate.HasValue ? NormalizeDateTime(request.PremiereDate.Value) : null;
|
||||||
item.ProductionYear = request.ProductionYear;
|
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;
|
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)
|
if (request.ProductionLocations is not null)
|
||||||
{
|
{
|
||||||
item.ProductionLocations = request.ProductionLocations;
|
item.ProductionLocations = request.ProductionLocations;
|
||||||
|
|
|
@ -554,7 +554,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
public string OfficialRating { get; set; }
|
public string OfficialRating { get; set; }
|
||||||
|
|
||||||
[JsonIgnore]
|
[JsonIgnore]
|
||||||
public int InheritedParentalRatingValue { get; set; }
|
public int? InheritedParentalRatingValue { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Gets or sets the critic rating.
|
/// Gets or sets the critic rating.
|
||||||
|
@ -2517,7 +2517,7 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
var item = this;
|
var item = this;
|
||||||
|
|
||||||
var inheritedParentalRatingValue = item.GetInheritedParentalRatingValue() ?? 0;
|
var inheritedParentalRatingValue = item.GetInheritedParentalRatingValue() ?? null;
|
||||||
if (inheritedParentalRatingValue != item.InheritedParentalRatingValue)
|
if (inheritedParentalRatingValue != item.InheritedParentalRatingValue)
|
||||||
{
|
{
|
||||||
item.InheritedParentalRatingValue = inheritedParentalRatingValue;
|
item.InheritedParentalRatingValue = inheritedParentalRatingValue;
|
||||||
|
|
Loading…
Reference in New Issue
Block a user