diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 1def47391a..fe8d618362 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -96,5 +96,10 @@ namespace MediaBrowser.Controller.Entities { return Name; } + + public bool IsType(string type) + { + return string.Equals(Type, type, StringComparison.OrdinalIgnoreCase) || string.Equals(Role, type, StringComparison.OrdinalIgnoreCase); + } } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 6684c4efbe..7f63dac332 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -423,7 +423,38 @@ namespace MediaBrowser.Server.Implementations.Dto // Ordering by person type to ensure actors and artists are at the front. // This is taking advantage of the fact that they both begin with A // This should be improved in the future - var people = item.People.OrderBy(i => i.SortOrder ?? int.MaxValue).ThenBy(i => i.Type).ToList(); + var people = item.People.OrderBy(i => i.SortOrder ?? int.MaxValue) + .ThenBy(i => + { + if (i.IsType(PersonType.Actor)) + { + return 0; + } + if (i.IsType(PersonType.GuestStar)) + { + return 1; + } + if (i.IsType(PersonType.Director)) + { + return 2; + } + if (i.IsType(PersonType.Writer)) + { + return 3; + } + if (i.IsType(PersonType.Producer)) + { + return 4; + } + if (i.IsType(PersonType.Composer)) + { + return 4; + } + + return 10; + }) + .ThenBy(i => i.Name) + .ToList(); // Attach People by transforming them into BaseItemPerson (DTO) dto.People = new BaseItemPerson[people.Count]; diff --git a/MediaBrowser.ServerApplication/ApplicationHost.cs b/MediaBrowser.ServerApplication/ApplicationHost.cs index 5c84b92af5..96aa9c9d59 100644 --- a/MediaBrowser.ServerApplication/ApplicationHost.cs +++ b/MediaBrowser.ServerApplication/ApplicationHost.cs @@ -277,19 +277,19 @@ namespace MediaBrowser.ServerApplication LogManager.RemoveConsoleOutput(); } - public override Task Init(IProgress progress) + public override async Task Init(IProgress progress) { PerformVersionMigration(); - return base.Init(progress); + await base.Init(progress).ConfigureAwait(false); + + MigrateModularConfigurations(); + ApplyDefaultMetadataSettings(); } private void PerformVersionMigration() { DeleteDeprecatedModules(); - - MigrateModularConfigurations(); - ApplyDefaultMetadataSettings(); } private void MigrateModularConfigurations() diff --git a/MediaBrowser.XbmcMetadata/Savers/XmlSaverHelpers.cs b/MediaBrowser.XbmcMetadata/Savers/XmlSaverHelpers.cs index 85829b1556..7f817f5912 100644 --- a/MediaBrowser.XbmcMetadata/Savers/XmlSaverHelpers.cs +++ b/MediaBrowser.XbmcMetadata/Savers/XmlSaverHelpers.cs @@ -382,8 +382,9 @@ namespace MediaBrowser.XbmcMetadata.Savers } var writers = item.People - .Where(i => IsPersonType(i, PersonType.Director)) + .Where(i => IsPersonType(i, PersonType.Writer)) .Select(i => i.Name) + .Distinct(StringComparer.OrdinalIgnoreCase) .ToList(); foreach (var person in writers) @@ -391,11 +392,9 @@ namespace MediaBrowser.XbmcMetadata.Savers builder.Append("" + SecurityElement.Escape(person) + ""); } - var credits = writers.Distinct(StringComparer.OrdinalIgnoreCase).ToList(); - - if (credits.Count > 0) + if (writers.Count > 0) { - builder.Append("" + SecurityElement.Escape(string.Join(" / ", credits.ToArray())) + ""); + builder.Append("" + SecurityElement.Escape(string.Join(" / ", writers.ToArray())) + ""); } var hasTrailer = item as IHasTrailers; @@ -850,6 +849,11 @@ namespace MediaBrowser.XbmcMetadata.Savers builder.Append("" + SecurityElement.Escape(person.Role ?? string.Empty) + ""); builder.Append("" + SecurityElement.Escape(person.Type ?? string.Empty) + ""); + if (person.SortOrder.HasValue) + { + builder.Append("" + SecurityElement.Escape(person.SortOrder.Value.ToString(UsCulture)) + ""); + } + try { var personEntity = libraryManager.GetPerson(person.Name);