diff --git a/Emby.Server.Implementations/Data/SqliteItemRepository.cs b/Emby.Server.Implementations/Data/SqliteItemRepository.cs index b7e2687ec8..e8a9b2eaa5 100644 --- a/Emby.Server.Implementations/Data/SqliteItemRepository.cs +++ b/Emby.Server.Implementations/Data/SqliteItemRepository.cs @@ -345,7 +345,10 @@ namespace Emby.Server.Implementations.Data // items by name "create index if not exists idx_ItemValues6 on ItemValues(ItemId,Type,CleanValue)", - "create index if not exists idx_ItemValues7 on ItemValues(Type,CleanValue,ItemId)" + "create index if not exists idx_ItemValues7 on ItemValues(Type,CleanValue,ItemId)", + + // Used to update inherited tags + "create index if not exists idx_ItemValues8 on ItemValues(Type, ItemId, Value)", }; connection.RunQueries(postQueries); @@ -1293,16 +1296,13 @@ namespace Emby.Server.Implementations.Data return false; } - if (_config.Configuration.SkipDeserializationForAudio) + if (type == typeof(Audio)) { - if (type == typeof(Audio)) - { - return false; - } - if (type == typeof(MusicAlbum)) - { - return false; - } + return false; + } + if (type == typeof(MusicAlbum)) + { + return false; } return true; @@ -4695,41 +4695,65 @@ namespace Emby.Server.Implementations.Data private async Task UpdateInheritedTags(CancellationToken cancellationToken) { - var newValues = new List>(); + var newValues = new List>(); - var commandText = "select Guid,(select group_concat(Tags, '|') from TypedBaseItems where (guid=outer.guid) OR (guid in (Select AncestorId from AncestorIds where ItemId=Outer.guid))) as NewInheritedTags from typedbaseitems as Outer"; + var commandText = @"select guid, +(select group_concat(Value, '|') from ItemValues where (ItemValues.ItemId = Outer.Guid OR ItemValues.ItemId in ((Select AncestorId from AncestorIds where AncestorIds.ItemId=Outer.guid))) and ItemValues.Type = 4) NewInheritedTags, +(select group_concat(Value, '|') from ItemValues where ItemValues.ItemId = Outer.Guid and ItemValues.Type = 6) CurrentInheritedTags +from typedbaseitems as Outer +where (NewInheritedTags <> CurrentInheritedTags or (NewInheritedTags is null) <> (CurrentInheritedTags is null)) +limit 100"; using (WriteLock.Write()) { using (var connection = CreateConnection()) { - foreach (var row in connection.Query(commandText)) + connection.RunInTransaction(db => { - var id = row.GetGuid(0); - string value = row.IsDBNull(2) ? null : row.GetString(2); - - newValues.Add(new Tuple(id, value)); - } - - Logger.Debug("UpdateInheritedTags - {0} rows", newValues.Count); - if (newValues.Count == 0) - { - return; - } - - // write lock here - using (var statement = PrepareStatement(connection, "Update TypedBaseItems set InheritedTags=@InheritedTags where Guid=@Guid")) - { - foreach (var item in newValues) + foreach (var row in connection.Query(commandText)) { - var paramList = new List(); + var id = row.GetGuid(0); + string value = row.IsDBNull(1) ? null : row.GetString(1); - paramList.Add(item.Item1); - paramList.Add(item.Item2); + var valuesArray = string.IsNullOrWhiteSpace(value) ? new string[] { } : value.Split(new[] { '|' }, StringSplitOptions.RemoveEmptyEntries); - statement.Execute(paramList.ToArray()); + newValues.Add(new Tuple(id, valuesArray)); } - } + + Logger.Debug("UpdateInheritedTags - {0} rows", newValues.Count); + if (newValues.Count == 0) + { + return; + } + + using (var insertStatement = PrepareStatement(connection, "insert into ItemValues (ItemId, Type, Value, CleanValue) values (@ItemId, 6, @Value, @CleanValue)")) + { + using (var deleteStatement = PrepareStatement(connection, "delete from ItemValues where ItemId=@ItemId and Type=6")) + { + foreach (var item in newValues) + { + var guidBlob = item.Item1.ToGuidBlob(); + + deleteStatement.Reset(); + deleteStatement.TryBind("@ItemId", guidBlob); + deleteStatement.MoveNext(); + + foreach (var itemValue in item.Item2) + { + insertStatement.Reset(); + + insertStatement.TryBind("@ItemId", guidBlob); + insertStatement.TryBind("@Value", itemValue); + + insertStatement.TryBind("@CleanValue", GetCleanValue(itemValue)); + + insertStatement.MoveNext(); + } + } + } + } + + }, TransactionMode); } } } @@ -5458,8 +5482,10 @@ namespace Emby.Server.Implementations.Data CheckDisposed(); + var guidBlob = itemId.ToGuidBlob(); + // First delete - db.Execute("delete from ItemValues where ItemId=@Id", itemId.ToGuidBlob()); + db.Execute("delete from ItemValues where ItemId=@Id", guidBlob); using (var statement = PrepareStatement(db, "insert into ItemValues (ItemId, Type, Value, CleanValue) values (@ItemId, @Type, @Value, @CleanValue)")) { @@ -5475,7 +5501,7 @@ namespace Emby.Server.Implementations.Data statement.Reset(); - statement.TryBind("@ItemId", itemId.ToGuidBlob()); + statement.TryBind("@ItemId", guidBlob); statement.TryBind("@Type", pair.Item1); statement.TryBind("@Value", itemValue); diff --git a/Emby.Server.Implementations/Dto/DtoService.cs b/Emby.Server.Implementations/Dto/DtoService.cs index 1fab23b328..2d717dc2ce 100644 --- a/Emby.Server.Implementations/Dto/DtoService.cs +++ b/Emby.Server.Implementations/Dto/DtoService.cs @@ -1119,8 +1119,7 @@ namespace Emby.Server.Implementations.Dto // Include artists that are not in the database yet, e.g., just added via metadata editor //var foundArtists = artistItems.Items.Select(i => i.Item1.Name).ToList(); - dto.ArtistItems = new List(); - dto.ArtistItems.AddRange(hasArtist.Artists + dto.ArtistItems = hasArtist.Artists //.Except(foundArtists, new DistinctNameComparer()) .Select(i => { @@ -1145,7 +1144,7 @@ namespace Emby.Server.Implementations.Dto return null; - }).Where(i => i != null)); + }).Where(i => i != null).ToArray(); } var hasAlbumArtist = item as IHasAlbumArtist; @@ -1332,8 +1331,7 @@ namespace Emby.Server.Implementations.Dto var series = item as Series; if (series != null) { - dto.AirDays = series.AirDays.ToArray(); - dto.AirTime = series.AirTime; + dto.AirDays = new DayOfWeek[] {}; dto.Status = series.Status.HasValue ? series.Status.Value.ToString() : null; } diff --git a/Emby.Server.Implementations/Emby.Server.Implementations.csproj b/Emby.Server.Implementations/Emby.Server.Implementations.csproj index d4976196cb..38f51919a8 100644 --- a/Emby.Server.Implementations/Emby.Server.Implementations.csproj +++ b/Emby.Server.Implementations/Emby.Server.Implementations.csproj @@ -249,7 +249,6 @@ - diff --git a/Emby.Server.Implementations/Library/LibraryManager.cs b/Emby.Server.Implementations/Library/LibraryManager.cs index 271dac1538..b4ba58cfdb 100644 --- a/Emby.Server.Implementations/Library/LibraryManager.cs +++ b/Emby.Server.Implementations/Library/LibraryManager.cs @@ -1172,6 +1172,8 @@ namespace Emby.Server.Implementations.Library progress.Report(percent * 100); } + await ItemRepository.UpdateInheritedValues(cancellationToken).ConfigureAwait(false); + progress.Report(100); } diff --git a/Emby.Server.Implementations/Sorting/AirTimeComparer.cs b/Emby.Server.Implementations/Sorting/AirTimeComparer.cs deleted file mode 100644 index bc05e9af3f..0000000000 --- a/Emby.Server.Implementations/Sorting/AirTimeComparer.cs +++ /dev/null @@ -1,71 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.Sorting; -using MediaBrowser.Model.Querying; -using System; - -namespace Emby.Server.Implementations.Sorting -{ - public class AirTimeComparer : IBaseItemComparer - { - /// - /// Compares the specified x. - /// - /// The x. - /// The y. - /// System.Int32. - public int Compare(BaseItem x, BaseItem y) - { - return DateTime.Compare(GetValue(x), GetValue(y)); - } - - /// - /// Gets the value. - /// - /// The x. - /// System.String. - private DateTime GetValue(BaseItem x) - { - var series = x as Series; - - if (series == null) - { - var season = x as Season; - - if (season != null) - { - series = season.Series; - } - else - { - var episode = x as Episode; - - if (episode != null) - { - series = episode.Series; - } - } - } - - if (series != null) - { - DateTime result; - if (DateTime.TryParse(series.AirTime, out result)) - { - return result; - } - } - - return DateTime.MinValue; - } - - /// - /// Gets the name. - /// - /// The name. - public string Name - { - get { return ItemSortBy.AirTime; } - } - } -} diff --git a/MediaBrowser.Api/ItemUpdateService.cs b/MediaBrowser.Api/ItemUpdateService.cs index 4b4520e8dc..13b5b64d97 100644 --- a/MediaBrowser.Api/ItemUpdateService.cs +++ b/MediaBrowser.Api/ItemUpdateService.cs @@ -372,8 +372,6 @@ namespace MediaBrowser.Api if (series != null) { series.Status = GetSeriesStatus(request); - series.AirDays = request.AirDays; - series.AirTime = request.AirTime; } } diff --git a/MediaBrowser.Api/StartupWizardService.cs b/MediaBrowser.Api/StartupWizardService.cs index cd56b69bd0..7d612a796c 100644 --- a/MediaBrowser.Api/StartupWizardService.cs +++ b/MediaBrowser.Api/StartupWizardService.cs @@ -95,7 +95,6 @@ namespace MediaBrowser.Api config.EnableStandaloneMusicKeys = true; config.EnableCaseSensitiveItemIds = true; config.SkipDeserializationForBasicTypes = true; - config.SkipDeserializationForAudio = true; config.EnableLocalizedGuids = true; config.EnableSimpleArtistDetection = true; config.EnableNormalizedItemByNameIds = true; diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 5520737b4b..f88522f78a 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -23,18 +23,6 @@ namespace MediaBrowser.Controller.Entities PhysicalLocationsList = new List(); } - /// - /// We don't support manual shortcuts - /// - [IgnoreDataMember] - protected override bool SupportsShortcutChildren - { - get - { - return false; - } - } - [IgnoreDataMember] public override bool IsPhysicalRoot { diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index f314d82c13..d02e469d46 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -31,15 +31,6 @@ namespace MediaBrowser.Controller.Entities PhysicalFolderIds = new List(); } - [IgnoreDataMember] - protected override bool SupportsShortcutChildren - { - get - { - return true; - } - } - [IgnoreDataMember] public override bool SupportsPlayedStatus { diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index f9133ccb01..7d1c7314d0 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -22,8 +22,6 @@ namespace MediaBrowser.Controller.Entities.TV { public Series() { - AirDays = new List(); - RemoteTrailers = EmptyMediaUrlArray; LocalTrailerIds = EmptyGuidArray; RemoteTrailerIds = EmptyGuidArray; @@ -77,16 +75,6 @@ namespace MediaBrowser.Controller.Entities.TV /// /// The status. public SeriesStatus? Status { get; set; } - /// - /// Gets or sets the air days. - /// - /// The air days. - public List AirDays { get; set; } - /// - /// Gets or sets the air time. - /// - /// The air time. - public string AirTime { get; set; } /// /// Gets or sets the date last episode added. diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index b7cf50ee32..f0d4d544e5 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1674,15 +1674,6 @@ namespace MediaBrowser.Controller.Entities } } - if (query.AirDays.Length > 0) - { - var ok = new[] { item }.OfType().Any(p => p.AirDays != null && query.AirDays.Any(d => p.AirDays.Contains(d))); - if (!ok) - { - return false; - } - } - if (query.SeriesStatuses.Length > 0) { var ok = new[] { item }.OfType().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.Status.Value)); diff --git a/MediaBrowser.Model/Configuration/ServerConfiguration.cs b/MediaBrowser.Model/Configuration/ServerConfiguration.cs index 5bbd7c4da3..db66837e45 100644 --- a/MediaBrowser.Model/Configuration/ServerConfiguration.cs +++ b/MediaBrowser.Model/Configuration/ServerConfiguration.cs @@ -162,7 +162,6 @@ namespace MediaBrowser.Model.Configuration public bool EnableAutomaticRestart { get; set; } public bool SkipDeserializationForBasicTypes { get; set; } - public bool SkipDeserializationForAudio { get; set; } public string ServerName { get; set; } public string WanDdns { get; set; } diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 0fbb0a45e7..2df69a58ff 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -444,7 +444,7 @@ namespace MediaBrowser.Model.Dto /// Gets or sets the artist items. /// /// The artist items. - public List ArtistItems { get; set; } + public NameIdPair[] ArtistItems { get; set; } /// /// Gets or sets the album. diff --git a/MediaBrowser.Providers/TV/SeriesMetadataService.cs b/MediaBrowser.Providers/TV/SeriesMetadataService.cs index cfea0c3157..5ca36b4481 100644 --- a/MediaBrowser.Providers/TV/SeriesMetadataService.cs +++ b/MediaBrowser.Providers/TV/SeriesMetadataService.cs @@ -64,20 +64,10 @@ namespace MediaBrowser.Providers.TV var sourceItem = source.Item; var targetItem = target.Item; - if (replaceData || string.IsNullOrEmpty(targetItem.AirTime)) - { - targetItem.AirTime = sourceItem.AirTime; - } - if (replaceData || !targetItem.Status.HasValue) { targetItem.Status = sourceItem.Status; } - - if (replaceData || targetItem.AirDays == null || targetItem.AirDays.Count == 0) - { - targetItem.AirDays = sourceItem.AirDays; - } } } } diff --git a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs index 78556c5a45..4a062f97ee 100644 --- a/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs +++ b/MediaBrowser.Providers/TV/TheTVDB/TvdbSeriesProvider.cs @@ -1090,28 +1090,6 @@ namespace MediaBrowser.Providers.TV break; } - case "Airs_DayOfWeek": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - item.AirDays = TVUtils.GetAirDays(val); - } - break; - } - - case "Airs_Time": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - item.AirTime = val; - } - break; - } - case "ContentRating": { var val = reader.ReadElementContentAsString(); diff --git a/MediaBrowser.Providers/TV/TvExternalIds.cs b/MediaBrowser.Providers/TV/TvExternalIds.cs index d2860a6225..104bcb5ae0 100644 --- a/MediaBrowser.Providers/TV/TvExternalIds.cs +++ b/MediaBrowser.Providers/TV/TvExternalIds.cs @@ -96,27 +96,4 @@ namespace MediaBrowser.Providers.TV return item is Episode; } } - - public class TvComSeriesExternalId : IExternalId - { - public string Name - { - get { return "TV.com"; } - } - - public string Key - { - get { return MetadataProviders.Tvcom.ToString(); } - } - - public string UrlFormatString - { - get { return null; } - } - - public bool Supports(IHasProviderIds item) - { - return item is Series; - } - } } diff --git a/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs b/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs index b0db4e6f38..795540e261 100644 --- a/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs +++ b/MediaBrowser.XbmcMetadata/Parsers/SeriesNfoParser.cs @@ -61,22 +61,6 @@ namespace MediaBrowser.XbmcMetadata.Parsers } break; } - case "airs_dayofweek": - { - item.AirDays = TVUtils.GetAirDays(reader.ReadElementContentAsString()); - break; - } - - case "airs_time": - { - var val = reader.ReadElementContentAsString(); - - if (!string.IsNullOrWhiteSpace(val)) - { - item.AirTime = val; - } - break; - } case "status": { diff --git a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs index 5f14137bda..41c376ddf0 100644 --- a/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/BaseNfoSaver.cs @@ -611,13 +611,6 @@ namespace MediaBrowser.XbmcMetadata.Savers writtenProviderIds.Add(MetadataProviders.Tmdb.ToString()); } - var tvcom = item.GetProviderId(MetadataProviders.Tvcom); - if (!string.IsNullOrEmpty(tvcom)) - { - writer.WriteElementString("tvcomid", tvcom); - writtenProviderIds.Add(MetadataProviders.Tvcom.ToString()); - } - if (!string.IsNullOrEmpty(item.PreferredMetadataLanguage)) { writer.WriteElementString("language", item.PreferredMetadataLanguage); diff --git a/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs b/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs index e9b2b786ac..a2f07d9520 100644 --- a/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs +++ b/MediaBrowser.XbmcMetadata/Savers/SeriesNfoSaver.cs @@ -69,20 +69,6 @@ namespace MediaBrowser.XbmcMetadata.Savers { writer.WriteElementString("status", series.Status.Value.ToString()); } - - if (!string.IsNullOrEmpty(series.AirTime)) - { - writer.WriteElementString("airs_time", series.AirTime); - } - - if (series.AirDays.Count == 7) - { - writer.WriteElementString("airs_dayofweek", "Daily"); - } - else if (series.AirDays.Count > 0) - { - writer.WriteElementString("airs_dayofweek", series.AirDays[0].ToString()); - } } protected override List GetTagsUsed(IHasMetadata item) @@ -94,9 +80,7 @@ namespace MediaBrowser.XbmcMetadata.Savers "episodeguide", "season", "episode", - "status", - "airs_time", - "airs_dayofweek" + "status" }); return list; } diff --git a/Nuget/MediaBrowser.Common.nuspec b/Nuget/MediaBrowser.Common.nuspec index 890ecaccdd..d822428265 100644 --- a/Nuget/MediaBrowser.Common.nuspec +++ b/Nuget/MediaBrowser.Common.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Common - 3.0.717 + 3.0.720 Emby.Common Emby Team ebr,Luke,scottisafool diff --git a/Nuget/MediaBrowser.Server.Core.nuspec b/Nuget/MediaBrowser.Server.Core.nuspec index 6b7a8729b2..8c3f90e4f9 100644 --- a/Nuget/MediaBrowser.Server.Core.nuspec +++ b/Nuget/MediaBrowser.Server.Core.nuspec @@ -2,7 +2,7 @@ MediaBrowser.Server.Core - 3.0.717 + 3.0.720 Emby.Server.Core Emby Team ebr,Luke,scottisafool @@ -12,7 +12,7 @@ Contains core components required to build plugins for Emby Server. Copyright © Emby 2013 - + diff --git a/SharedVersion.cs b/SharedVersion.cs index b201954e64..719ace03f8 100644 --- a/SharedVersion.cs +++ b/SharedVersion.cs @@ -1,3 +1,3 @@ using System.Reflection; -[assembly: AssemblyVersion("3.2.26.20")] +[assembly: AssemblyVersion("3.2.26.21")]