From 219cba75069cd2560e9571eee0c7f4a419256dab Mon Sep 17 00:00:00 2001 From: Sven Van den brande Date: Fri, 29 Jul 2016 21:18:03 +0200 Subject: Removed redundant Collection Initializers Removed Using directives that are not required --- MediaBrowser.Server.Implementations/Dto/DtoService.cs | 5 ++--- 1 file changed, 2 insertions(+), 3 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 616625bc9c..f17f5e5a2f 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -11,7 +11,6 @@ using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Library; using MediaBrowser.Controller.LiveTv; using MediaBrowser.Controller.Persistence; -using MediaBrowser.Controller.Playlists; using MediaBrowser.Controller.Providers; using MediaBrowser.Controller.Sync; using MediaBrowser.Model.Drawing; @@ -102,8 +101,8 @@ namespace MediaBrowser.Server.Implementations.Dto var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems); var list = new List(); - var programTuples = new List> { }; - var channelTuples = new List> { }; + var programTuples = new List>(); + var channelTuples = new List>(); foreach (var item in items) { -- cgit v1.2.3 From a308ab8912dc91d1bba61afa15f859eba0b2df2c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 2 Aug 2016 01:55:52 -0400 Subject: update components --- MediaBrowser.Model/Querying/ItemFields.cs | 1 + .../Dto/DtoService.cs | 46 ++++++---------------- .../LiveTv/LiveTvManager.cs | 1 + .../Sync/SyncManager.cs | 1 + 4 files changed, 16 insertions(+), 33 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Model/Querying/ItemFields.cs b/MediaBrowser.Model/Querying/ItemFields.cs index 21f87247ab..0400e374af 100644 --- a/MediaBrowser.Model/Querying/ItemFields.cs +++ b/MediaBrowser.Model/Querying/ItemFields.cs @@ -219,6 +219,7 @@ /// Studios, + BasicSyncInfo, /// /// The synchronize information /// diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index f17f5e5a2f..90111ad8ea 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -133,7 +133,7 @@ namespace MediaBrowser.Server.Implementations.Dto } } - FillSyncInfo(dto, item, syncJobItems, options, user); + FillSyncInfo(dto, item, options, user, syncJobItems); list.Add(dto); } @@ -253,39 +253,16 @@ namespace MediaBrowser.Server.Implementations.Dto { var item = tuple.Item1; - FillSyncInfo(tuple.Item2, item, syncProgress, options, user); + FillSyncInfo(tuple.Item2, item, options, user, syncProgress); } } } private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, DtoOptions options, User user, SyncedItemProgress[] syncProgress) { - if (options.Fields.Contains(ItemFields.SyncInfo)) - { - var userCanSync = user != null && user.Policy.EnableSync; - dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item); - } - - if (dto.SupportsSync ?? false) - { - dto.HasSyncJob = syncProgress.Any(i => i.Status != SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)); - dto.IsSynced = syncProgress.Any(i => i.Status == SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)); - - if (dto.IsSynced.Value) - { - dto.SyncStatus = SyncJobItemStatus.Synced; - } + var hasFullSyncInfo = options.Fields.Contains(ItemFields.SyncInfo); - else if (dto.HasSyncJob.Value) - { - dto.SyncStatus = syncProgress.Where(i => string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)).Select(i => i.Status).Max(); - } - } - } - - private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, SyncedItemProgress[] syncProgress, DtoOptions options, User user) - { - if (options.Fields.Contains(ItemFields.SyncInfo)) + if (hasFullSyncInfo || options.Fields.Contains(ItemFields.BasicSyncInfo)) { var userCanSync = user != null && user.Policy.EnableSync; dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item); @@ -296,14 +273,17 @@ namespace MediaBrowser.Server.Implementations.Dto dto.HasSyncJob = syncProgress.Any(i => i.Status != SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)); dto.IsSynced = syncProgress.Any(i => i.Status == SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)); - if (dto.IsSynced.Value) + if (hasFullSyncInfo) { - dto.SyncStatus = SyncJobItemStatus.Synced; - } + if (dto.IsSynced.Value) + { + dto.SyncStatus = SyncJobItemStatus.Synced; + } - else if (dto.HasSyncJob.Value) - { - dto.SyncStatus = syncProgress.Where(i => string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)).Select(i => i.Status).Max(); + else if (dto.HasSyncJob.Value) + { + dto.SyncStatus = syncProgress.Where(i => string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)).Select(i => i.Status).Max(); + } } } } diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 64af35a9aa..26ec599fa4 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -1187,6 +1187,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv // Load these now which will prefetch metadata var dtoOptions = new DtoOptions(); dtoOptions.Fields.Remove(ItemFields.SyncInfo); + dtoOptions.Fields.Remove(ItemFields.BasicSyncInfo); await GetRecordings(new RecordingQuery(), dtoOptions, cancellationToken).ConfigureAwait(false); progress.Report(100); diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index 92221ffbad..15855f5538 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -646,6 +646,7 @@ namespace MediaBrowser.Server.Implementations.Sync dtoOptions.Fields.Remove(ItemFields.SeriesGenres); dtoOptions.Fields.Remove(ItemFields.Settings); dtoOptions.Fields.Remove(ItemFields.SyncInfo); + dtoOptions.Fields.Remove(ItemFields.BasicSyncInfo); syncedItem.Item = _dtoService().GetBaseItemDto(libraryItem, dtoOptions); -- cgit v1.2.3 From 04d480297dc9b4f9a1a9e35fe33f424ecc7662e1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 3 Aug 2016 02:38:19 -0400 Subject: reduce sync db access --- .../UserLibrary/BaseItemsByNameService.cs | 6 +- MediaBrowser.Controller/Dto/IDtoService.cs | 11 +- MediaBrowser.Controller/Sync/ISyncManager.cs | 2 +- MediaBrowser.Controller/Sync/ISyncRepository.cs | 5 +- MediaBrowser.Controller/Sync/SyncedItemProgress.cs | 2 +- MediaBrowser.Model/Dto/IHasSyncInfo.cs | 1 + .../Dto/DtoService.cs | 113 +++++++++------------ .../Sync/SyncManager.cs | 2 +- .../Sync/SyncRepository.cs | 99 ++++++++++++++---- 9 files changed, 145 insertions(+), 96 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 9465d1fdc5..852a3d59ee 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -180,9 +180,10 @@ namespace MediaBrowser.Api.UserLibrary var result = GetItems(request, query); + var syncProgess = DtoService.GetSyncedItemProgress(dtoOptions); var dtos = result.Items.Select(i => { - var dto = DtoService.GetItemByNameDto(i.Item1, dtoOptions, null, user); + var dto = DtoService.GetItemByNameDto(i.Item1, dtoOptions, null, syncProgess, user); if (!string.IsNullOrWhiteSpace(request.IncludeItemTypes)) { @@ -325,7 +326,8 @@ namespace MediaBrowser.Api.UserLibrary tuples = ibnItems.Select(i => new Tuple>(i, new List())); } - var dtos = tuples.Select(i => DtoService.GetItemByNameDto(i.Item1, dtoOptions, i.Item2, user)); + var syncProgess = DtoService.GetSyncedItemProgress(dtoOptions); + var dtos = tuples.Select(i => DtoService.GetItemByNameDto(i.Item1, dtoOptions, i.Item2, syncProgess, user)); result.Items = dtos.Where(i => i != null).ToArray(); diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index e4aa466dfd..a8e93fb2b8 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -4,6 +4,8 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using System.Collections.Generic; using System.Threading.Tasks; +using MediaBrowser.Controller.Sync; +using MediaBrowser.Model.Sync; namespace MediaBrowser.Controller.Dto { @@ -89,11 +91,8 @@ namespace MediaBrowser.Controller.Dto /// /// Gets the item by name dto. /// - /// The item. - /// The options. - /// The tagged items. - /// The user. - /// BaseItemDto. - BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List taggedItems, User user = null); + BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List taggedItems, Dictionary syncProgress, User user = null); + + Dictionary GetSyncedItemProgress(DtoOptions options); } } diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index 8eb934eaa8..fbcb549ad8 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Controller.Sync /// /// The query. /// QueryResult<System.String>. - QueryResult GetSyncedItemProgresses(SyncJobItemQuery query); + Dictionary GetSyncedItemProgresses(SyncJobItemQuery query); /// /// Reports the synchronize job item transfer beginning. diff --git a/MediaBrowser.Controller/Sync/ISyncRepository.cs b/MediaBrowser.Controller/Sync/ISyncRepository.cs index 2af09dbaad..8e9b2bf774 100644 --- a/MediaBrowser.Controller/Sync/ISyncRepository.cs +++ b/MediaBrowser.Controller/Sync/ISyncRepository.cs @@ -1,4 +1,5 @@ -using MediaBrowser.Model.Querying; +using System.Collections.Generic; +using MediaBrowser.Model.Querying; using MediaBrowser.Model.Sync; using System.Threading.Tasks; @@ -74,6 +75,6 @@ namespace MediaBrowser.Controller.Sync /// /// The query. /// QueryResult<System.String>. - QueryResult GetSyncedItemProgresses(SyncJobItemQuery query); + Dictionary GetSyncedItemProgresses(SyncJobItemQuery query); } } diff --git a/MediaBrowser.Controller/Sync/SyncedItemProgress.cs b/MediaBrowser.Controller/Sync/SyncedItemProgress.cs index edb42eb0f1..0fd929eb18 100644 --- a/MediaBrowser.Controller/Sync/SyncedItemProgress.cs +++ b/MediaBrowser.Controller/Sync/SyncedItemProgress.cs @@ -4,7 +4,7 @@ namespace MediaBrowser.Controller.Sync { public class SyncedItemProgress { - public string ItemId { get; set; } + public double Progress { get; set; } public SyncJobItemStatus Status { get; set; } } } diff --git a/MediaBrowser.Model/Dto/IHasSyncInfo.cs b/MediaBrowser.Model/Dto/IHasSyncInfo.cs index d2cf1f8cfe..7471dacdd7 100644 --- a/MediaBrowser.Model/Dto/IHasSyncInfo.cs +++ b/MediaBrowser.Model/Dto/IHasSyncInfo.cs @@ -7,6 +7,7 @@ namespace MediaBrowser.Model.Dto string Id { get; } bool? SupportsSync { get; set; } bool? HasSyncJob { get; set; } + double? SyncPercent { get; set; } bool? IsSynced { get; set; } SyncJobItemStatus? SyncStatus { get; set; } } diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 90111ad8ea..779afdcf27 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -97,8 +97,7 @@ namespace MediaBrowser.Server.Implementations.Dto throw new ArgumentNullException("options"); } - var syncJobItems = GetSyncedItemProgress(options); - var syncDictionary = GetSyncedItemProgressDictionary(syncJobItems); + var syncDictionary = GetSyncedItemProgress(options); var list = new List(); var programTuples = new List>(); @@ -106,7 +105,7 @@ namespace MediaBrowser.Server.Implementations.Dto foreach (var item in items) { - var dto = await GetBaseItemDtoInternal(item, options, syncDictionary, user, owner).ConfigureAwait(false); + var dto = await GetBaseItemDtoInternal(item, options, user, owner).ConfigureAwait(false); var tvChannel = item as LiveTvChannel; if (tvChannel != null) @@ -133,7 +132,7 @@ namespace MediaBrowser.Server.Implementations.Dto } } - FillSyncInfo(dto, item, options, user, syncJobItems); + FillSyncInfo(dto, item, options, user, syncDictionary); list.Add(dto); } @@ -151,23 +150,11 @@ namespace MediaBrowser.Server.Implementations.Dto return list; } - private Dictionary GetSyncedItemProgressDictionary(IEnumerable items) - { - var dict = new Dictionary(); - - foreach (var item in items) - { - dict[item.ItemId] = item; - } - - return dict; - } - public BaseItemDto GetBaseItemDto(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null) { - var syncProgress = GetSyncedItemProgress(options); + var syncDictionary = GetSyncedItemProgress(options); - var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user, owner).Result; + var dto = GetBaseItemDtoInternal(item, options, user, owner).Result; var tvChannel = item as LiveTvChannel; if (tvChannel != null) { @@ -190,11 +177,11 @@ namespace MediaBrowser.Server.Implementations.Dto SetItemByNameInfo(item, dto, GetTaggedItems(byName, user), user); } - FillSyncInfo(dto, item, options, user, syncProgress); + FillSyncInfo(dto, item, options, user, syncDictionary); return dto; } - FillSyncInfo(dto, item, options, user, syncProgress); + FillSyncInfo(dto, item, options, user, syncDictionary); return dto; } @@ -210,23 +197,24 @@ namespace MediaBrowser.Server.Implementations.Dto return items; } - private SyncedItemProgress[] GetSyncedItemProgress(DtoOptions options) + public Dictionary GetSyncedItemProgress(DtoOptions options) { - if (!options.Fields.Contains(ItemFields.SyncInfo)) + if (!options.Fields.Contains(ItemFields.BasicSyncInfo) && + !options.Fields.Contains(ItemFields.SyncInfo)) { - return new SyncedItemProgress[] { }; + return new Dictionary(); } var deviceId = options.DeviceId; if (string.IsNullOrWhiteSpace(deviceId)) { - return new SyncedItemProgress[] { }; + return new Dictionary(); } var caps = _deviceManager().GetCapabilities(deviceId); if (caps == null || !caps.SupportsSync) { - return new SyncedItemProgress[] { }; + return new Dictionary(); } return _syncManager.GetSyncedItemProgresses(new SyncJobItemQuery @@ -240,12 +228,13 @@ namespace MediaBrowser.Server.Implementations.Dto SyncJobItemStatus.ReadyToTransfer, SyncJobItemStatus.Synced } - }).Items; + }); } public void FillSyncInfo(IEnumerable> tuples, DtoOptions options, User user) { - if (options.Fields.Contains(ItemFields.SyncInfo)) + if (options.Fields.Contains(ItemFields.BasicSyncInfo) || + options.Fields.Contains(ItemFields.SyncInfo)) { var syncProgress = GetSyncedItemProgress(options); @@ -258,37 +247,40 @@ namespace MediaBrowser.Server.Implementations.Dto } } - private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, DtoOptions options, User user, SyncedItemProgress[] syncProgress) + private void FillSyncInfo(IHasSyncInfo dto, BaseItem item, DtoOptions options, User user, Dictionary syncProgress) { var hasFullSyncInfo = options.Fields.Contains(ItemFields.SyncInfo); - if (hasFullSyncInfo || options.Fields.Contains(ItemFields.BasicSyncInfo)) + if (!options.Fields.Contains(ItemFields.BasicSyncInfo) && + !hasFullSyncInfo) { - var userCanSync = user != null && user.Policy.EnableSync; - dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item); + return; } if (dto.SupportsSync ?? false) { - dto.HasSyncJob = syncProgress.Any(i => i.Status != SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)); - dto.IsSynced = syncProgress.Any(i => i.Status == SyncJobItemStatus.Synced && string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)); - - if (hasFullSyncInfo) + SyncedItemProgress syncStatus; + if (syncProgress.TryGetValue(dto.Id, out syncStatus)) { - if (dto.IsSynced.Value) + if (syncStatus.Status == SyncJobItemStatus.Synced) { - dto.SyncStatus = SyncJobItemStatus.Synced; + dto.SyncPercent = 100; + } + else + { + dto.SyncPercent = syncStatus.Progress; } - else if (dto.HasSyncJob.Value) + if (hasFullSyncInfo) { - dto.SyncStatus = syncProgress.Where(i => string.Equals(i.ItemId, dto.Id, StringComparison.OrdinalIgnoreCase)).Select(i => i.Status).Max(); + dto.HasSyncJob = true; + dto.SyncStatus = syncStatus.Status; } } } } - private async Task GetBaseItemDtoInternal(BaseItem item, DtoOptions options, Dictionary syncProgress, User user = null, BaseItem owner = null) + private async Task GetBaseItemDtoInternal(BaseItem item, DtoOptions options, User user = null, BaseItem owner = null) { var fields = options.Fields; @@ -337,7 +329,7 @@ namespace MediaBrowser.Server.Implementations.Dto if (user != null) { - await AttachUserSpecificInfo(dto, item, user, fields, syncProgress).ConfigureAwait(false); + await AttachUserSpecificInfo(dto, item, user, fields).ConfigureAwait(false); } var hasMediaSources = item as IHasMediaSources; @@ -400,11 +392,9 @@ namespace MediaBrowser.Server.Implementations.Dto return dto; } - public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List taggedItems, User user = null) + public BaseItemDto GetItemByNameDto(BaseItem item, DtoOptions options, List taggedItems, Dictionary syncProgress, User user = null) { - var syncProgress = GetSyncedItemProgress(options); - - var dto = GetBaseItemDtoInternal(item, options, GetSyncedItemProgressDictionary(syncProgress), user).Result; + var dto = GetBaseItemDtoInternal(item, options, user).Result; if (taggedItems != null && options.Fields.Contains(ItemFields.ItemCounts)) { @@ -452,28 +442,13 @@ namespace MediaBrowser.Server.Implementations.Dto /// The item. /// The user. /// The fields. - /// The synchronize progress. - private async Task AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, List fields, Dictionary syncProgress) + private async Task AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, List fields) { if (item.IsFolder) { var folder = (Folder)item; - if (item.SourceType == SourceType.Library && folder.SupportsUserDataFromChildren && fields.Contains(ItemFields.SyncInfo)) - { - // Skip the user data manager because we've already looped through the recursive tree and don't want to do it twice - // TODO: Improve in future - dto.UserData = GetUserItemDataDto(_userDataRepository.GetUserData(user, item)); - - await SetSpecialCounts(folder, user, dto, fields, syncProgress).ConfigureAwait(false); - - dto.UserData.Played = dto.UserData.PlayedPercentage.HasValue && - dto.UserData.PlayedPercentage.Value >= 100; - } - else - { - dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user).ConfigureAwait(false); - } + dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user).ConfigureAwait(false); if (item.SourceType == SourceType.Library) { @@ -498,6 +473,12 @@ namespace MediaBrowser.Server.Implementations.Dto dto.PlayAccess = item.GetPlayAccess(user); + if (fields.Contains(ItemFields.BasicSyncInfo) || fields.Contains(ItemFields.SyncInfo)) + { + var userCanSync = user != null && user.Policy.EnableSync; + dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item); + } + if (fields.Contains(ItemFields.SeasonUserData)) { var episode = item as Episode; @@ -1424,7 +1405,7 @@ namespace MediaBrowser.Server.Implementations.Dto BaseItem parent = null; var isFirst = true; - while (((!dto.HasLogo && logoLimit > 0) || (!dto.HasArtImage && artLimit > 0) || (!dto.HasThumb && thumbLimit > 0) || parent is Series) && + while (((!dto.HasLogo && logoLimit > 0) || (!dto.HasArtImage && artLimit > 0) || (!dto.HasThumb && thumbLimit > 0) || parent is Series) && (parent = parent ?? (isFirst ? item.GetParent() ?? owner : parent)) != null) { if (parent == null) @@ -1531,7 +1512,7 @@ namespace MediaBrowser.Server.Implementations.Dto /// The fields. /// The synchronize progress. /// Task. - private async Task SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List fields, Dictionary syncProgress) + private async Task SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List fields, Dictionary syncProgress) { var recursiveItemCount = 0; var unplayed = 0; @@ -1580,10 +1561,10 @@ namespace MediaBrowser.Server.Implementations.Dto } double percent = 0; - SyncedItemProgress syncItemProgress; + SyncJobItemStatus syncItemProgress; if (syncProgress.TryGetValue(child.Id.ToString("N"), out syncItemProgress)) { - switch (syncItemProgress.Status) + switch (syncItemProgress) { case SyncJobItemStatus.Synced: percent = 100; diff --git a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs index 15855f5538..ffba60af84 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncManager.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncManager.cs @@ -1124,7 +1124,7 @@ namespace MediaBrowser.Server.Implementations.Sync await processor.UpdateJobStatus(jobItem.JobId).ConfigureAwait(false); } - public QueryResult GetSyncedItemProgresses(SyncJobItemQuery query) + public Dictionary GetSyncedItemProgresses(SyncJobItemQuery query) { return _repo.GetSyncedItemProgresses(query); } diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index a1ed66a995..df4149fa72 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -29,6 +29,17 @@ namespace MediaBrowser.Server.Implementations.Sync DbFilePath = Path.Combine(appPaths.DataPath, "sync14.db"); } + private class SyncSummary + { + public Dictionary Items { get; set; } + + public SyncSummary() + { + Items = new Dictionary(); + } + } + + public async Task Initialize() { using (var connection = await CreateConnection().ConfigureAwait(false)) @@ -41,7 +52,10 @@ namespace MediaBrowser.Server.Implementations.Sync "create table if not exists SyncJobItems (Id GUID PRIMARY KEY, ItemId TEXT, ItemName TEXT, MediaSourceId TEXT, JobId TEXT, TemporaryPath TEXT, OutputPath TEXT, Status TEXT, TargetId TEXT, DateCreated DateTime, Progress FLOAT, AdditionalFiles TEXT, MediaSource TEXT, IsMarkedForRemoval BIT, JobItemIndex INT, ItemDateModifiedTicks BIGINT)", "create index if not exists idx_SyncJobItems1 on SyncJobItems(Id)", - "create index if not exists idx_SyncJobItems2 on SyncJobItems(TargetId)", + + "drop index if exists idx_SyncJobItems2", + "drop index if exists idx_SyncJobItems3", + "create index if not exists idx_SyncJobItems4 on SyncJobItems(TargetId,ItemId,Status,Progress,DateCreated)", "pragma shrink_memory" }; @@ -583,9 +597,74 @@ namespace MediaBrowser.Server.Implementations.Sync } } - public QueryResult GetSyncedItemProgresses(SyncJobItemQuery query) + public Dictionary GetSyncedItemProgresses(SyncJobItemQuery query) { - return GetJobItemReader(query, "select ItemId,Status from SyncJobItems", GetSyncedItemProgress); + var result = new Dictionary(); + + using (var connection = CreateConnection(true).Result) + { + using (var cmd = connection.CreateCommand()) + { + cmd.CommandText = "select ItemId,Progress,Status from SyncJobItems"; + + var whereClauses = new List(); + + if (!string.IsNullOrWhiteSpace(query.TargetId)) + { + whereClauses.Add("TargetId=@TargetId"); + cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId; + } + + if (query.Statuses.Length > 0) + { + var statuses = string.Join(",", query.Statuses.Select(i => "'" + i.ToString() + "'").ToArray()); + + whereClauses.Add(string.Format("Status in ({0})", statuses)); + } + + if (whereClauses.Count > 0) + { + cmd.CommandText += " where " + string.Join(" AND ", whereClauses.ToArray()); + } + + using (var reader = cmd.ExecuteReader(CommandBehavior.SequentialAccess | CommandBehavior.SingleResult)) + { + while (reader.Read()) + { + var itemId = reader.GetString(0); + + if (!reader.IsDBNull(1)) + { + var status = (SyncJobItemStatus)Enum.Parse(typeof(SyncJobItemStatus), reader.GetString(1), true); + + if (status == SyncJobItemStatus.Synced) + { + result[itemId] = new SyncedItemProgress + { + Status = SyncJobItemStatus.Synced + }; + } + else + { + SyncedItemProgress currentStatus; + double progress = reader.IsDBNull(2) ? 0.0 : reader.GetDouble(2); + + if (!result.TryGetValue(itemId, out currentStatus) || (currentStatus.Status != SyncJobItemStatus.Synced && progress >= currentStatus.Progress)) + { + result[itemId] = new SyncedItemProgress + { + Status = status, + Progress = progress + }; + } + } + } + } + } + } + } + + return result; } public QueryResult GetJobItems(SyncJobItemQuery query) @@ -795,19 +874,5 @@ namespace MediaBrowser.Server.Implementations.Sync return info; } - - private SyncedItemProgress GetSyncedItemProgress(IDataReader reader) - { - var item = new SyncedItemProgress(); - - item.ItemId = reader.GetString(0); - - if (!reader.IsDBNull(1)) - { - item.Status = (SyncJobItemStatus)Enum.Parse(typeof(SyncJobItemStatus), reader.GetString(1), true); - } - - return item; - } } } -- cgit v1.2.3 From 23da61281ee108954de9799761fa9c78dc4547ce Mon Sep 17 00:00:00 2001 From: softworkz Date: Fri, 5 Aug 2016 23:15:48 +0200 Subject: Reduced compiler warnings. No functional changes (except MediaEncoder.cs and AutomaticRestartEntryPoint.cs) --- MediaBrowser.Api/ApiEntryPoint.cs | 4 ++-- MediaBrowser.Api/Playback/BaseStreamingService.cs | 2 +- MediaBrowser.Api/PluginService.cs | 2 +- MediaBrowser.Common/Plugins/BasePlugin.cs | 2 +- MediaBrowser.LocalMetadata/BaseXmlProvider.cs | 2 +- MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs | 2 +- MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs | 2 +- MediaBrowser.Server.Implementations/Connect/ConnectManager.cs | 2 +- MediaBrowser.Server.Implementations/Dto/DtoService.cs | 2 +- .../EntryPoints/ActivityLogEntryPoint.cs | 2 +- .../EntryPoints/ExternalPortForwarding.cs | 2 +- .../EntryPoints/UserDataChangeNotifier.cs | 2 +- MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs | 2 +- .../HttpServer/RangeRequestWriter.cs | 2 +- MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs | 4 ++-- .../LiveTv/EmbyTV/ItemDataProvider.cs | 2 +- .../LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs | 2 +- .../LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs | 2 +- .../Notifications/SqliteNotificationsRepository.cs | 2 +- MediaBrowser.Server.Startup.Common/ApplicationHost.cs | 6 +++--- 20 files changed, 24 insertions(+), 24 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Api/ApiEntryPoint.cs b/MediaBrowser.Api/ApiEntryPoint.cs index 87fa3d46ca..dbc1179e22 100644 --- a/MediaBrowser.Api/ApiEntryPoint.cs +++ b/MediaBrowser.Api/ApiEntryPoint.cs @@ -559,13 +559,13 @@ namespace MediaBrowser.Api { } - catch (IOException ex) + catch (IOException) { //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); DeletePartialStreamFiles(path, jobType, retryCount + 1, 500); } - catch (Exception ex) + catch { //Logger.ErrorException("Error deleting partial stream file(s) {0}", ex, path); } diff --git a/MediaBrowser.Api/Playback/BaseStreamingService.cs b/MediaBrowser.Api/Playback/BaseStreamingService.cs index ab73aabe43..a5f78420c7 100644 --- a/MediaBrowser.Api/Playback/BaseStreamingService.cs +++ b/MediaBrowser.Api/Playback/BaseStreamingService.cs @@ -1080,7 +1080,7 @@ namespace MediaBrowser.Api.Playback //process.BeginOutputReadLine(); // Important - don't await the log task or we won't be able to kill ffmpeg when the user stops playback - Task.Run(() => StartStreamingLog(transcodingJob, state, process.StandardError.BaseStream, state.LogFileStream)); + var task = Task.Run(() => StartStreamingLog(transcodingJob, state, process.StandardError.BaseStream, state.LogFileStream)); // Wait for the file to exist before proceeeding while (!FileSystem.FileExists(state.WaitForPath ?? outputPath) && !transcodingJob.HasExited) diff --git a/MediaBrowser.Api/PluginService.cs b/MediaBrowser.Api/PluginService.cs index 3bf70715fb..7ad69fd041 100644 --- a/MediaBrowser.Api/PluginService.cs +++ b/MediaBrowser.Api/PluginService.cs @@ -227,7 +227,7 @@ namespace MediaBrowser.Api .ToList(); } } - catch (Exception ex) + catch { //Logger.ErrorException("Error getting plugin list", ex); // Play it safe here diff --git a/MediaBrowser.Common/Plugins/BasePlugin.cs b/MediaBrowser.Common/Plugins/BasePlugin.cs index a0716137b9..b75accf9b0 100644 --- a/MediaBrowser.Common/Plugins/BasePlugin.cs +++ b/MediaBrowser.Common/Plugins/BasePlugin.cs @@ -211,7 +211,7 @@ namespace MediaBrowser.Common.Plugins { return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType)); } - catch (Exception ex) + catch { return (TConfigurationType)Activator.CreateInstance(typeof(TConfigurationType)); } diff --git a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs index 0289ffb083..f23559e4be 100644 --- a/MediaBrowser.LocalMetadata/BaseXmlProvider.cs +++ b/MediaBrowser.LocalMetadata/BaseXmlProvider.cs @@ -75,7 +75,7 @@ namespace MediaBrowser.LocalMetadata } } - public int Order + public virtual int Order { get { diff --git a/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs b/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs index 8f9d21eae8..0893f192fa 100644 --- a/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs +++ b/MediaBrowser.LocalMetadata/Providers/SeriesXmlProvider.cs @@ -31,7 +31,7 @@ namespace MediaBrowser.LocalMetadata.Providers return directoryService.GetFile(Path.Combine(info.Path, "series.xml")); } - public int Order + public override int Order { get { diff --git a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs index d7ef493c2c..71306e0ec0 100644 --- a/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs +++ b/MediaBrowser.MediaEncoding/Encoder/FontConfigLoader.cs @@ -58,7 +58,7 @@ namespace MediaBrowser.MediaEncoding.Encoder else { // Kick this off, but no need to wait on it - Task.Run(async () => + var task = Task.Run(async () => { await DownloadFontFile(fontsDirectory, fontFilename, new Progress()).ConfigureAwait(false); diff --git a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs index 24750de94c..4e913cf994 100644 --- a/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs +++ b/MediaBrowser.Server.Implementations/Connect/ConnectManager.cs @@ -151,7 +151,7 @@ namespace MediaBrowser.Server.Implementations.Connect { DiscoveredWanIpAddress = address; - UpdateConnectInfo(); + var task = UpdateConnectInfo(); } private async Task UpdateConnectInfo() diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 779afdcf27..cc165da6a7 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -1620,7 +1620,7 @@ namespace MediaBrowser.Server.Implementations.Dto { size = _imageProcessor.GetImageSize(imageInfo); } - catch (Exception ex) + catch { //_logger.ErrorException("Failed to determine primary image aspect ratio for {0}", ex, path); return null; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs index 46ddf3dd8c..a36583a412 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ActivityLogEntryPoint.cs @@ -29,7 +29,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints private readonly IInstallationManager _installationManager; //private readonly ILogManager _logManager; - private readonly ILogger _logger; + //private readonly ILogger _logger; private readonly ISessionManager _sessionManager; private readonly ITaskManager _taskManager; private readonly IActivityManager _activityManager; diff --git a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs index 64e3c56a63..280bec65ba 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/ExternalPortForwarding.cs @@ -165,7 +165,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints CreateRules(device); } - catch (Exception ex) + catch { // I think it could be a good idea to log the exception because // you are using permanent portmapping here (never expire) and that means that next time diff --git a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs index b616b7761a..2bb0101330 100644 --- a/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs +++ b/MediaBrowser.Server.Implementations/EntryPoints/UserDataChangeNotifier.cs @@ -92,7 +92,7 @@ namespace MediaBrowser.Server.Implementations.EntryPoints var changes = _changedItems.ToList(); _changedItems.Clear(); - SendNotifications(changes, CancellationToken.None); + var task = SendNotifications(changes, CancellationToken.None); if (UpdateTimer != null) { diff --git a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs index 4121c5e5e6..5cf0a246fe 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/HttpListenerHost.cs @@ -251,7 +251,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer httpRes.Close(); } - catch (Exception errorEx) + catch { //_logger.ErrorException("Error this.ProcessRequest(context)(Exception while writing error to the response)", errorEx); } diff --git a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs index 71cd20743a..488c630fe4 100644 --- a/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs +++ b/MediaBrowser.Server.Implementations/HttpServer/RangeRequestWriter.cs @@ -191,7 +191,7 @@ namespace MediaBrowser.Server.Implementations.HttpServer } } } - catch (IOException ex) + catch (IOException) { throw; } diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index a36eae8d22..ee8ab7c254 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -55,8 +55,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV public static EmbyTV Current; - public event EventHandler DataSourceChanged; - public event EventHandler RecordingStatusChanged; + public event EventHandler DataSourceChanged { add { } remove { } } + public event EventHandler RecordingStatusChanged { add { } remove { } } private readonly ConcurrentDictionary _activeRecordings = new ConcurrentDictionary(StringComparer.OrdinalIgnoreCase); diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs index 79b26468e6..7fe271bea4 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/ItemDataProvider.cs @@ -52,7 +52,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV catch (FileNotFoundException) { } - catch (DirectoryNotFoundException ex) + catch (DirectoryNotFoundException) { } catch (IOException ex) diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs index 69b6fb5a94..fd4775938a 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/HdHomerun/HdHomerunHost.cs @@ -431,7 +431,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.HdHomerun list.Add(await GetMediaSource(info, hdhrId, "mobile").ConfigureAwait(false)); } } - catch (Exception ex) + catch { } diff --git a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs index 71b3f8a184..0f8682b7cc 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/TunerHosts/SatIp/Rtsp/RtspSession.cs @@ -649,7 +649,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv.TunerHosts.SatIp.Rtsp #region Public Events - public event PropertyChangedEventHandler PropertyChanged; + ////public event PropertyChangedEventHandler PropertyChanged; #endregion diff --git a/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs b/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs index be8c6d48d6..f30ba3e542 100644 --- a/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs +++ b/MediaBrowser.Server.Implementations/Notifications/SqliteNotificationsRepository.cs @@ -22,7 +22,7 @@ namespace MediaBrowser.Server.Implementations.Notifications public event EventHandler NotificationAdded; public event EventHandler NotificationsMarkedRead; - public event EventHandler NotificationUpdated; + ////public event EventHandler NotificationUpdated; public async Task Initialize() { diff --git a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs index 3f1f98cd00..ce99f0a240 100644 --- a/MediaBrowser.Server.Startup.Common/ApplicationHost.cs +++ b/MediaBrowser.Server.Startup.Common/ApplicationHost.cs @@ -606,7 +606,7 @@ namespace MediaBrowser.Server.Startup.Common { return new ImageMagickEncoder(LogManager.GetLogger("ImageMagick"), ApplicationPaths, HttpClient, FileSystemManager, ServerConfigurationManager); } - catch (Exception ex) + catch { Logger.Error("Error loading ImageMagick. Will revert to GDI."); } @@ -616,7 +616,7 @@ namespace MediaBrowser.Server.Startup.Common { return new GDIImageEncoder(FileSystemManager, LogManager.GetLogger("GDI")); } - catch (Exception ex) + catch { Logger.Error("Error loading GDI. Will revert to NullImageEncoder."); } @@ -1412,7 +1412,7 @@ namespace MediaBrowser.Server.Startup.Common { return new Uri(externalDns).Host; } - catch (Exception e) + catch { return externalDns; } -- cgit v1.2.3 From 8508e07bb9d1af326ef4c1c1b891e0d49288167b Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 13 Aug 2016 16:54:29 -0400 Subject: improve genre displays --- .../Library/LibraryStructureService.cs | 1 + .../UserLibrary/BaseItemsByNameService.cs | 1 + .../Configuration/LibraryOptions.cs | 14 ----------- .../Entities/CollectionFolder.cs | 1 + MediaBrowser.Controller/Entities/UserRootFolder.cs | 29 ++++++++++++++++++++++ MediaBrowser.Controller/Library/ILibraryManager.cs | 1 + MediaBrowser.Controller/Library/ItemResolveArgs.cs | 1 + .../MediaBrowser.Controller.csproj | 1 - .../MediaBrowser.Model.Portable.csproj | 3 +++ .../MediaBrowser.Model.net35.csproj | 3 +++ MediaBrowser.Model/Configuration/LibraryOptions.cs | 7 ++++++ MediaBrowser.Model/Dto/BaseItemDto.cs | 1 + MediaBrowser.Model/Dto/ItemCounts.cs | 1 + MediaBrowser.Model/Entities/VirtualFolderInfo.cs | 3 +++ MediaBrowser.Model/MediaBrowser.Model.csproj | 1 + .../Dto/DtoService.cs | 10 +++++++- .../Library/LibraryManager.cs | 14 ++++++++--- .../Library/Resolvers/Audio/MusicAlbumResolver.cs | 1 + .../Library/Resolvers/PhotoResolver.cs | 1 + .../Library/Resolvers/TV/SeriesResolver.cs | 1 + .../LiveTv/EmbyTV/EmbyTV.cs | 1 + .../Persistence/SqliteItemRepository.cs | 7 +++++- 22 files changed, 82 insertions(+), 21 deletions(-) delete mode 100644 MediaBrowser.Controller/Configuration/LibraryOptions.cs create mode 100644 MediaBrowser.Model/Configuration/LibraryOptions.cs (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Api/Library/LibraryStructureService.cs b/MediaBrowser.Api/Library/LibraryStructureService.cs index 3af2134937..dd3c7211a4 100644 --- a/MediaBrowser.Api/Library/LibraryStructureService.cs +++ b/MediaBrowser.Api/Library/LibraryStructureService.cs @@ -11,6 +11,7 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Api.Library { diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs index 852a3d59ee..94a6a7ef13 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsByNameService.cs @@ -214,6 +214,7 @@ namespace MediaBrowser.Api.UserLibrary dto.AlbumCount = counts.AlbumCount; dto.SongCount = counts.SongCount; dto.GameCount = counts.GameCount; + dto.ArtistCount = counts.ArtistCount; } /// diff --git a/MediaBrowser.Controller/Configuration/LibraryOptions.cs b/MediaBrowser.Controller/Configuration/LibraryOptions.cs deleted file mode 100644 index 1a824c08bf..0000000000 --- a/MediaBrowser.Controller/Configuration/LibraryOptions.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Linq; -using System.Text; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.Configuration -{ - public class LibraryOptions - { - public bool EnableAudioArchiveFiles { get; set; } - public bool EnableVideoArchiveFiles { get; set; } - } -} diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 289cb7a2e8..b81f021da9 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -10,6 +10,7 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Serialization; using MoreLinq; diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index 4549d0d1df..a62c67c4fe 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -16,6 +16,31 @@ namespace MediaBrowser.Controller.Entities /// public class UserRootFolder : Folder { + private List _childrenIds = null; + private readonly object _childIdsLock = new object(); + //protected override IEnumerable LoadChildren() + //{ + // lock (_childIdsLock) + // { + // if (_childrenIds == null) + // { + // var list = base.LoadChildren().ToList(); + // _childrenIds = list.Select(i => i.Id).ToList(); + // return list; + // } + + // return _childrenIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList(); + // } + //} + + private void ResetCachedChildren() + { + lock (_childIdsLock) + { + _childrenIds = null; + } + } + protected override async Task> GetItemsInternal(InternalItemsQuery query) { if (query.Recursive) @@ -69,6 +94,8 @@ namespace MediaBrowser.Controller.Entities public override bool BeforeMetadataRefresh() { + ResetCachedChildren(); + var hasChanges = base.BeforeMetadataRefresh(); if (string.Equals("default", Name, StringComparison.OrdinalIgnoreCase)) @@ -82,6 +109,8 @@ namespace MediaBrowser.Controller.Entities protected override async Task ValidateChildrenInternal(IProgress progress, CancellationToken cancellationToken, bool recursive, bool refreshChildMetadata, MetadataRefreshOptions refreshOptions, IDirectoryService directoryService) { + ResetCachedChildren(); + await base.ValidateChildrenInternal(progress, cancellationToken, recursive, refreshChildMetadata, refreshOptions, directoryService) .ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index edbacb5e70..0862e3eaf9 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -12,6 +12,7 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dto; namespace MediaBrowser.Controller.Library diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 56ec0a2138..ec0ac325bc 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -6,6 +6,7 @@ using System.IO; using System.Linq; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Controller.Library { diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index e621eafded..0462117cb5 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -98,7 +98,6 @@ - diff --git a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj index 7a9589c982..351740e6ec 100644 --- a/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj +++ b/MediaBrowser.Model.Portable/MediaBrowser.Model.Portable.csproj @@ -205,6 +205,9 @@ Configuration\ImageSavingConvention.cs + + Configuration\LibraryOptions.cs + Configuration\MetadataConfiguration.cs diff --git a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj index 420b536ae4..7df8f31261 100644 --- a/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj +++ b/MediaBrowser.Model.net35/MediaBrowser.Model.net35.csproj @@ -177,6 +177,9 @@ Configuration\ImageSavingConvention.cs + + Configuration\LibraryOptions.cs + Configuration\MetadataConfiguration.cs diff --git a/MediaBrowser.Model/Configuration/LibraryOptions.cs b/MediaBrowser.Model/Configuration/LibraryOptions.cs new file mode 100644 index 0000000000..c6f7bbb9da --- /dev/null +++ b/MediaBrowser.Model/Configuration/LibraryOptions.cs @@ -0,0 +1,7 @@ +namespace MediaBrowser.Model.Configuration +{ + public class LibraryOptions + { + public bool EnableArchiveMediaFiles { get; set; } + } +} diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 6edf743fbb..7d69359d1a 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -837,6 +837,7 @@ namespace MediaBrowser.Model.Dto /// /// The album count. public int? AlbumCount { get; set; } + public int? ArtistCount { get; set; } /// /// Gets or sets the music video count. /// diff --git a/MediaBrowser.Model/Dto/ItemCounts.cs b/MediaBrowser.Model/Dto/ItemCounts.cs index 07ddfa1ac6..66c3dfebc7 100644 --- a/MediaBrowser.Model/Dto/ItemCounts.cs +++ b/MediaBrowser.Model/Dto/ItemCounts.cs @@ -25,6 +25,7 @@ /// /// The game count. public int GameCount { get; set; } + public int ArtistCount { get; set; } /// /// Gets or sets the game system count. /// diff --git a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs index 1161ab005f..d8ec04ff64 100644 --- a/MediaBrowser.Model/Entities/VirtualFolderInfo.cs +++ b/MediaBrowser.Model/Entities/VirtualFolderInfo.cs @@ -1,4 +1,5 @@ using System.Collections.Generic; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Model.Entities { @@ -25,6 +26,8 @@ namespace MediaBrowser.Model.Entities /// The type of the collection. public string CollectionType { get; set; } + public LibraryOptions LibraryOptions { get; set; } + /// /// Initializes a new instance of the class. /// diff --git a/MediaBrowser.Model/MediaBrowser.Model.csproj b/MediaBrowser.Model/MediaBrowser.Model.csproj index e3c1e52a53..db70b86063 100644 --- a/MediaBrowser.Model/MediaBrowser.Model.csproj +++ b/MediaBrowser.Model/MediaBrowser.Model.csproj @@ -95,6 +95,7 @@ + diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index cc165da6a7..4f903a2c28 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -408,12 +408,19 @@ namespace MediaBrowser.Server.Implementations.Dto private void SetItemByNameInfo(BaseItem item, BaseItemDto dto, List taggedItems, User user = null) { - if (item is MusicArtist || item is MusicGenre) + if (item is MusicArtist) { dto.AlbumCount = taggedItems.Count(i => i is MusicAlbum); dto.MusicVideoCount = taggedItems.Count(i => i is MusicVideo); dto.SongCount = taggedItems.Count(i => i is Audio); } + else if (item is MusicGenre) + { + dto.ArtistCount = taggedItems.Count(i => i is MusicArtist); + dto.AlbumCount = taggedItems.Count(i => i is MusicAlbum); + dto.MusicVideoCount = taggedItems.Count(i => i is MusicVideo); + dto.SongCount = taggedItems.Count(i => i is Audio); + } else if (item is GameGenre) { dto.GameCount = taggedItems.Count(i => i is Game); @@ -422,6 +429,7 @@ namespace MediaBrowser.Server.Implementations.Dto { // This populates them all and covers Genre, Person, Studio, Year + dto.ArtistCount = taggedItems.Count(i => i is MusicArtist); dto.AlbumCount = taggedItems.Count(i => i is MusicAlbum); dto.EpisodeCount = taggedItems.Count(i => i is Episode); dto.GameCount = taggedItems.Count(i => i is Game); diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index b00303f295..52961668d0 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -1223,7 +1223,7 @@ namespace MediaBrowser.Server.Implementations.Library .Select(dir => GetVirtualFolderInfo(dir, topLibraryFolders)); } - private VirtualFolderInfo GetVirtualFolderInfo(string dir, List collectionFolders) + private VirtualFolderInfo GetVirtualFolderInfo(string dir, List allCollectionFolders) { var info = new VirtualFolderInfo { @@ -1237,7 +1237,7 @@ namespace MediaBrowser.Server.Implementations.Library CollectionType = GetCollectionType(dir) }; - var libraryFolder = collectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase)); + var libraryFolder = allCollectionFolders.FirstOrDefault(i => string.Equals(i.Path, dir, StringComparison.OrdinalIgnoreCase)); if (libraryFolder != null && libraryFolder.HasImage(ImageType.Primary)) { @@ -1249,6 +1249,12 @@ namespace MediaBrowser.Server.Implementations.Library info.ItemId = libraryFolder.Id.ToString("N"); } + var collectionFolder = libraryFolder as CollectionFolder; + if (collectionFolder != null) + { + info.LibraryOptions = collectionFolder.GetLibraryOptions(); + } + return info; } @@ -2426,13 +2432,13 @@ namespace MediaBrowser.Server.Implementations.Library options.AudioFileExtensions.Remove(".m3u"); options.AudioFileExtensions.Remove(".wpl"); - if (!libraryOptions.EnableAudioArchiveFiles) + if (!libraryOptions.EnableArchiveMediaFiles) { options.AudioFileExtensions.Remove(".rar"); options.AudioFileExtensions.Remove(".zip"); } - if (!libraryOptions.EnableVideoArchiveFiles) + if (!libraryOptions.EnableArchiveMediaFiles) { options.VideoFileExtensions.Remove(".rar"); options.VideoFileExtensions.Remove(".zip"); diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs index 546f64d3c3..1a8295800f 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/Audio/MusicAlbumResolver.cs @@ -11,6 +11,7 @@ using System.Collections.Generic; using System.IO; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Server.Implementations.Library.Resolvers.Audio { diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs index 09a9a3b4e9..78df465b13 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/PhotoResolver.cs @@ -7,6 +7,7 @@ using System.IO; using System.Linq; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Server.Implementations.Library.Resolvers { diff --git a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs index f1bbc1f327..aefb29f1a6 100644 --- a/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs +++ b/MediaBrowser.Server.Implementations/Library/Resolvers/TV/SeriesResolver.cs @@ -13,6 +13,7 @@ using System.IO; using System.Linq; using CommonIO; using MediaBrowser.Controller.Configuration; +using MediaBrowser.Model.Configuration; namespace MediaBrowser.Server.Implementations.Library.Resolvers.TV { diff --git a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs index 4c9b2a4d97..3d8e7a3d6d 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/EmbyTV/EmbyTV.cs @@ -28,6 +28,7 @@ using CommonIO; using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Controller.Power; +using MediaBrowser.Model.Configuration; using Microsoft.Win32; namespace MediaBrowser.Server.Implementations.LiveTv.EmbyTV diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index bbb36b46e1..0e36ede7ac 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -3975,7 +3975,8 @@ namespace MediaBrowser.Server.Implementations.Persistence AlbumArtistStartsWithOrGreater = query.AlbumArtistStartsWithOrGreater, Tags = query.Tags, OfficialRatings = query.OfficialRatings, - Genres = query.GenreIds, + GenreIds = query.GenreIds, + Genres = query.Genres, Years = query.Years }; @@ -4128,6 +4129,10 @@ namespace MediaBrowser.Server.Implementations.Persistence { counts.AlbumCount = value; } + else if (string.Equals(typeName, typeof(MusicArtist).FullName, StringComparison.OrdinalIgnoreCase)) + { + counts.ArtistCount = value; + } else if (string.Equals(typeName, typeof(Audio).FullName, StringComparison.OrdinalIgnoreCase)) { counts.SongCount = value; -- cgit v1.2.3 From 8a7b24000da7a9e917ea041095b55fc95e98a17c Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 16 Aug 2016 13:08:37 -0400 Subject: update season queries --- MediaBrowser.Api/TvShowsService.cs | 2 +- MediaBrowser.Controller/Entities/Folder.cs | 11 +++++++++- MediaBrowser.Controller/Entities/TV/Season.cs | 8 ++++++-- MediaBrowser.Controller/Entities/TV/Series.cs | 24 +++++++++++++--------- .../Dto/DtoService.cs | 2 +- .../IO/LibraryMonitor.cs | 14 +++++++++++-- 6 files changed, 44 insertions(+), 17 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 3f248ea8f0..92189c2458 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -490,7 +490,7 @@ namespace MediaBrowser.Api } else { - episodes = series.GetEpisodes(user, season); + episodes = series.GetSeasonEpisodes(user, season); } } else diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 23055690ca..f8eb414b60 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -13,6 +13,7 @@ using System.Threading; using System.Threading.Tasks; using CommonIO; using MediaBrowser.Controller.Channels; +using MediaBrowser.Controller.Entities.Audio; using MediaBrowser.Controller.Entities.TV; using MediaBrowser.Model.Channels; @@ -1427,7 +1428,7 @@ namespace MediaBrowser.Controller.Entities itemDto.RecursiveItemCount = allItemsQueryResult.TotalRecordCount; } - double recursiveItemCount = allItemsQueryResult.TotalRecordCount; + var recursiveItemCount = allItemsQueryResult.TotalRecordCount; double unplayedCount = unplayedQueryResult.TotalRecordCount; if (recursiveItemCount > 0) @@ -1437,6 +1438,14 @@ namespace MediaBrowser.Controller.Entities dto.Played = dto.PlayedPercentage.Value >= 100; dto.UnplayedItemCount = unplayedQueryResult.TotalRecordCount; } + + if (itemDto != null) + { + if (this is Season || this is MusicAlbum) + { + itemDto.ChildCount = recursiveItemCount; + } + } } } } \ No newline at end of file diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index c64de399f2..66fe1cc756 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -85,7 +85,11 @@ namespace MediaBrowser.Controller.Entities.TV public override int GetChildCount(User user) { - return GetChildren(user, true).Count(); + Logger.Debug("Season {0} getting child cound", (Path ?? Name)); + var result = GetChildren(user, true).Count(); + Logger.Debug("Season {0} child cound: ", result); + + return result; } /// @@ -192,7 +196,7 @@ namespace MediaBrowser.Controller.Entities.TV public IEnumerable GetEpisodes(Series series, User user, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable allSeriesEpisodes) { - return series.GetEpisodes(user, this, includeMissingEpisodes, includeVirtualUnairedEpisodes, allSeriesEpisodes); + return series.GetSeasonEpisodes(user, this, includeMissingEpisodes, includeVirtualUnairedEpisodes, allSeriesEpisodes); } public IEnumerable GetEpisodes() diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 38ddb89ca7..02ac42b2af 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -254,19 +254,16 @@ namespace MediaBrowser.Controller.Entities.TV }).Cast().ToList(); - Logger.Debug("GetSeasons returned {0} items from database", seasons.Count); if (!includeMissingSeasons) { seasons = seasons.Where(i => !(i.IsMissingSeason)).ToList(); } - Logger.Debug("GetSeasons has {0} items after includeMissingSeasons filter", seasons.Count); if (!includeVirtualUnaired) { seasons = seasons.Where(i => !i.IsVirtualUnaired).ToList(); } - Logger.Debug("GetSeasons has {0} items after includeVirtualUnaired filter", seasons.Count); return seasons; } @@ -280,14 +277,19 @@ namespace MediaBrowser.Controller.Entities.TV public IEnumerable GetEpisodes(User user, bool includeMissing, bool includeVirtualUnaired) { + var seriesKey = GetUniqueSeriesKey(this); + Logger.Debug("GetEpisodes seriesKey: {0}", seriesKey); + var allItems = LibraryManager.GetItemList(new InternalItemsQuery(user) { - AncestorWithPresentationUniqueKey = GetUniqueSeriesKey(this), + AncestorWithPresentationUniqueKey = seriesKey, IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name }, SortBy = new[] { ItemSortBy.SortName } }).ToList(); + Logger.Debug("GetEpisodes return {0} items from database", allItems.Count); + var allSeriesEpisodes = allItems.OfType().ToList(); var allEpisodes = allItems.OfType() @@ -368,11 +370,11 @@ namespace MediaBrowser.Controller.Entities.TV progress.Report(100); } - public IEnumerable GetEpisodes(User user, Season season) + public IEnumerable GetSeasonEpisodes(User user, Season season) { var config = user.Configuration; - return GetEpisodes(user, season, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); + return GetSeasonEpisodes(user, season, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); } private IEnumerable GetAllEpisodes(User user) @@ -386,20 +388,22 @@ namespace MediaBrowser.Controller.Entities.TV }).Cast(); } - public IEnumerable GetEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes) + public IEnumerable GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes) { IEnumerable episodes = GetAllEpisodes(user); - return GetEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes); + return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes); } - public IEnumerable GetEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable allSeriesEpisodes) + public IEnumerable GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable allSeriesEpisodes) { if (allSeriesEpisodes == null) { - return GetEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes); + Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null"); + return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes); } + Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason"); var episodes = FilterEpisodesBySeason(allSeriesEpisodes, parentSeason, ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons); if (!includeMissingEpisodes) diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 4f903a2c28..b646605ed4 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -458,7 +458,7 @@ namespace MediaBrowser.Server.Implementations.Dto dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user).ConfigureAwait(false); - if (item.SourceType == SourceType.Library) + if (!dto.ChildCount.HasValue && item.SourceType == SourceType.Library) { dto.ChildCount = GetChildCount(folder, user); } diff --git a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs index 8c2b927e3a..dea0a978bf 100644 --- a/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs +++ b/MediaBrowser.Server.Implementations/IO/LibraryMonitor.cs @@ -38,7 +38,6 @@ namespace MediaBrowser.Server.Implementations.IO /// private readonly IReadOnlyList _alwaysIgnoreFiles = new List { - "thumbs.db", "small.jpg", "albumart.jpg", @@ -47,6 +46,15 @@ namespace MediaBrowser.Server.Implementations.IO "TempSBE" }; + private readonly IReadOnlyList _alwaysIgnoreExtensions = new List + { + // thumbs.db + ".db", + + // bts sync files + ".bts" + }; + /// /// Add the path to our temporary ignore list. Use when writing to a path within our listening scope. /// @@ -411,7 +419,9 @@ namespace MediaBrowser.Server.Implementations.IO var filename = Path.GetFileName(path); - var monitorPath = !(!string.IsNullOrEmpty(filename) && _alwaysIgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase)); + var monitorPath = !string.IsNullOrEmpty(filename) && + !_alwaysIgnoreFiles.Contains(filename, StringComparer.OrdinalIgnoreCase) && + !_alwaysIgnoreExtensions.Contains(Path.GetExtension(path) ?? string.Empty, StringComparer.OrdinalIgnoreCase); // Ignore certain files var tempIgnorePaths = _tempIgnoredPaths.Keys.ToList(); -- cgit v1.2.3 From fd6aa72dac2fe4a118603eebab192b46b8f7401e Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Wed, 17 Aug 2016 15:28:43 -0400 Subject: add guide optimizations --- MediaBrowser.Api/BaseApiService.cs | 4 +++ MediaBrowser.Api/IHasDtoOptions.cs | 1 + MediaBrowser.Api/LiveTv/LiveTvService.cs | 27 +++++++++++++++- MediaBrowser.Api/PlaylistService.cs | 14 ++++++++- MediaBrowser.Api/SimilarItemsHelper.cs | 14 ++++++++- MediaBrowser.Api/Sync/SyncHelper.cs | 4 +-- MediaBrowser.Api/TvShowsService.cs | 14 +++++++++ MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs | 3 ++ MediaBrowser.Api/UserLibrary/UserLibraryService.cs | 3 ++ MediaBrowser.Controller/Dto/DtoOptions.cs | 4 +++ MediaBrowser.Model/Dto/BaseItemDto.cs | 13 ++++++-- MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs | 6 ++++ MediaBrowser.Model/LiveTv/ProgramQuery.cs | 2 ++ MediaBrowser.Model/Sync/SyncJobQuery.cs | 1 + .../Dto/DtoService.cs | 36 ++++++++++++++++------ .../LiveTv/LiveTvManager.cs | 36 +++++++++++++++++----- .../Sync/SyncRepository.cs | 14 +++++++++ 17 files changed, 172 insertions(+), 24 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Api/BaseApiService.cs b/MediaBrowser.Api/BaseApiService.cs index 44a367be09..3ff432d741 100644 --- a/MediaBrowser.Api/BaseApiService.cs +++ b/MediaBrowser.Api/BaseApiService.cs @@ -139,6 +139,10 @@ namespace MediaBrowser.Api { options.ImageTypeLimit = hasDtoOptions.ImageTypeLimit.Value; } + if (hasDtoOptions.EnableUserData.HasValue) + { + options.EnableUserData = hasDtoOptions.EnableUserData.Value; + } if (!string.IsNullOrWhiteSpace(hasDtoOptions.EnableImageTypes)) { diff --git a/MediaBrowser.Api/IHasDtoOptions.cs b/MediaBrowser.Api/IHasDtoOptions.cs index dac366113c..6ed1670c21 100644 --- a/MediaBrowser.Api/IHasDtoOptions.cs +++ b/MediaBrowser.Api/IHasDtoOptions.cs @@ -4,6 +4,7 @@ namespace MediaBrowser.Api public interface IHasDtoOptions : IHasItemFields { bool? EnableImages { get; set; } + bool? EnableUserData { get; set; } int? ImageTypeLimit { get; set; } diff --git a/MediaBrowser.Api/LiveTv/LiveTvService.cs b/MediaBrowser.Api/LiveTv/LiveTvService.cs index 91157cd11f..545ac162ff 100644 --- a/MediaBrowser.Api/LiveTv/LiveTvService.cs +++ b/MediaBrowser.Api/LiveTv/LiveTvService.cs @@ -82,6 +82,9 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "AddCurrentProgram", Description = "Optional. Adds current program info to each channel", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public bool AddCurrentProgram { get; set; } + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + public GetChannels() { AddCurrentProgram = true; @@ -149,6 +152,9 @@ namespace MediaBrowser.Api.LiveTv public bool EnableTotalRecordCount { get; set; } + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + public GetRecordings() { EnableTotalRecordCount = true; @@ -271,6 +277,9 @@ namespace MediaBrowser.Api.LiveTv [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string EnableImageTypes { get; set; } + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + /// /// Fields to return within the items, in addition to basic information /// @@ -331,6 +340,9 @@ namespace MediaBrowser.Api.LiveTv /// The fields. [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } + + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } } [Route("/LiveTv/Programs/{Id}", "GET", Summary = "Gets a live tv program")] @@ -726,7 +738,12 @@ namespace MediaBrowser.Api.LiveTv var user = string.IsNullOrEmpty(request.UserId) ? null : _userManager.GetUserById(request.UserId); - var returnArray = (await _dtoService.GetBaseItemDtos(channelResult.Items, GetDtoOptions(Request), user).ConfigureAwait(false)).ToArray(); + var options = GetDtoOptions(request); + RemoveFields(options); + + options.AddCurrentProgram = request.AddCurrentProgram; + + var returnArray = (await _dtoService.GetBaseItemDtos(channelResult.Items, options, user).ConfigureAwait(false)).ToArray(); var result = new QueryResult { @@ -737,6 +754,14 @@ namespace MediaBrowser.Api.LiveTv return ToOptimizedSerializedResultUsingCache(result); } + private void RemoveFields(DtoOptions options) + { + options.Fields.Remove(ItemFields.CanDelete); + options.Fields.Remove(ItemFields.CanDownload); + options.Fields.Remove(ItemFields.DisplayPreferencesId); + options.Fields.Remove(ItemFields.Etag); + } + public object Get(GetChannel request) { var user = string.IsNullOrWhiteSpace(request.UserId) ? null : _userManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Api/PlaylistService.cs b/MediaBrowser.Api/PlaylistService.cs index 604227a150..9693992882 100644 --- a/MediaBrowser.Api/PlaylistService.cs +++ b/MediaBrowser.Api/PlaylistService.cs @@ -72,7 +72,7 @@ namespace MediaBrowser.Api } [Route("/Playlists/{Id}/Items", "GET", Summary = "Gets the original items of a playlist")] - public class GetPlaylistItems : IReturn>, IHasItemFields + public class GetPlaylistItems : IReturn>, IHasDtoOptions { [ApiMember(Name = "Id", IsRequired = true, DataType = "string", ParameterType = "path", Verb = "DELETE")] public string Id { get; set; } @@ -104,6 +104,18 @@ namespace MediaBrowser.Api /// The fields. [ApiMember(Name = "Fields", Description = "Optional. Specify additional fields of information to return in the output. This allows multiple, comma delimeted. Options: Budget, Chapters, CriticRatingSummary, DateCreated, Genres, HomePageUrl, IndexOptions, MediaStreams, Overview, ParentId, Path, People, ProviderIds, PrimaryImageAspectRatio, Revenue, SortName, Studios, Taglines", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET", AllowMultiple = true)] public string Fields { get; set; } + + [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableImages { get; set; } + + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + + [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? ImageTypeLimit { get; set; } + + [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string EnableImageTypes { get; set; } } [Authenticated] diff --git a/MediaBrowser.Api/SimilarItemsHelper.cs b/MediaBrowser.Api/SimilarItemsHelper.cs index a1e47bd8fd..1621c80567 100644 --- a/MediaBrowser.Api/SimilarItemsHelper.cs +++ b/MediaBrowser.Api/SimilarItemsHelper.cs @@ -29,8 +29,20 @@ namespace MediaBrowser.Api public string ExcludeArtistIds { get; set; } } - public class BaseGetSimilarItems : IReturn, IHasItemFields + public class BaseGetSimilarItems : IReturn, IHasDtoOptions { + [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableImages { get; set; } + + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + + [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] + public int? ImageTypeLimit { get; set; } + + [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] + public string EnableImageTypes { get; set; } + /// /// Gets or sets the user id. /// diff --git a/MediaBrowser.Api/Sync/SyncHelper.cs b/MediaBrowser.Api/Sync/SyncHelper.cs index 0d3e8707db..2f857000c0 100644 --- a/MediaBrowser.Api/Sync/SyncHelper.cs +++ b/MediaBrowser.Api/Sync/SyncHelper.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Api.Sync } break; } - if (item.IsFolder && !item.IsMusicGenre && !item.IsArtist && !item.IsType("musicalbum") && !item.IsGameGenre) + if (item.IsFolderItem && !item.IsMusicGenre && !item.IsArtist && !item.IsType("musicalbum") && !item.IsGameGenre) { options.Add(SyncJobOption.Quality); options.Add(SyncJobOption.Profile); @@ -44,7 +44,7 @@ namespace MediaBrowser.Api.Sync { if (item.SupportsSync ?? false) { - if (item.IsFolder || item.IsGameGenre || item.IsMusicGenre || item.IsGenre || item.IsArtist || item.IsStudio || item.IsPerson) + if (item.IsFolderItem || item.IsGameGenre || item.IsMusicGenre || item.IsGenre || item.IsArtist || item.IsStudio || item.IsPerson) { options.Add(SyncJobOption.SyncNewContent); options.Add(SyncJobOption.ItemLimit); diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index 92189c2458..e295f3b3a6 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -69,6 +69,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string EnableImageTypes { get; set; } + + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } } [Route("/Shows/Upcoming", "GET", Summary = "Gets a list of upcoming episodes")] @@ -117,6 +120,9 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string EnableImageTypes { get; set; } + + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } } [Route("/Shows/{Id}/Similar", "GET", Summary = "Finds tv shows similar to a given one.")] @@ -184,6 +190,10 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string EnableImageTypes { get; set; } + + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + } [Route("/Shows/{Id}/Seasons", "GET", Summary = "Gets seasons for a tv series")] @@ -226,6 +236,10 @@ namespace MediaBrowser.Api [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string EnableImageTypes { get; set; } + + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + } /// diff --git a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs index 3e9a541c0c..96acb1f607 100644 --- a/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs +++ b/MediaBrowser.Api/UserLibrary/BaseItemsRequest.cs @@ -226,6 +226,9 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "EnableImages", Description = "Optional, include image information in output", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] public bool? EnableImages { get; set; } + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + [ApiMember(Name = "ImageTypeLimit", Description = "Optional, the max number of images to return, per image type", IsRequired = false, DataType = "int", ParameterType = "query", Verb = "GET")] public int? ImageTypeLimit { get; set; } diff --git a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs index bbccef6dea..c392ef4634 100644 --- a/MediaBrowser.Api/UserLibrary/UserLibraryService.cs +++ b/MediaBrowser.Api/UserLibrary/UserLibraryService.cs @@ -246,6 +246,9 @@ namespace MediaBrowser.Api.UserLibrary [ApiMember(Name = "EnableImageTypes", Description = "Optional. The image types to include in the output.", IsRequired = false, DataType = "string", ParameterType = "query", Verb = "GET")] public string EnableImageTypes { get; set; } + [ApiMember(Name = "EnableUserData", Description = "Optional, include user data", IsRequired = false, DataType = "boolean", ParameterType = "query", Verb = "GET")] + public bool? EnableUserData { get; set; } + public GetLatestMedia() { Limit = 20; diff --git a/MediaBrowser.Controller/Dto/DtoOptions.cs b/MediaBrowser.Controller/Dto/DtoOptions.cs index d627cc67ae..e69b649488 100644 --- a/MediaBrowser.Controller/Dto/DtoOptions.cs +++ b/MediaBrowser.Controller/Dto/DtoOptions.cs @@ -19,12 +19,16 @@ namespace MediaBrowser.Controller.Dto public bool EnableImages { get; set; } public bool AddProgramRecordingInfo { get; set; } public string DeviceId { get; set; } + public bool EnableUserData { get; set; } + public bool AddCurrentProgram { get; set; } public DtoOptions() { Fields = new List(); ImageTypeLimit = int.MaxValue; EnableImages = true; + EnableUserData = true; + AddCurrentProgram = true; Fields = Enum.GetNames(typeof (ItemFields)) .Select(i => (ItemFields) Enum.Parse(typeof (ItemFields), i, true)) diff --git a/MediaBrowser.Model/Dto/BaseItemDto.cs b/MediaBrowser.Model/Dto/BaseItemDto.cs index 7d69359d1a..348a781ae1 100644 --- a/MediaBrowser.Model/Dto/BaseItemDto.cs +++ b/MediaBrowser.Model/Dto/BaseItemDto.cs @@ -346,7 +346,16 @@ namespace MediaBrowser.Model.Dto /// Gets or sets a value indicating whether this instance is folder. /// /// true if this instance is folder; otherwise, false. - public bool IsFolder { get; set; } + public bool? IsFolder { get; set; } + + [IgnoreDataMember] + public bool IsFolderItem + { + get + { + return IsFolder ?? false; + } + } /// /// Gets or sets the parent id. @@ -656,7 +665,7 @@ namespace MediaBrowser.Model.Dto { get { - return RunTimeTicks.HasValue || IsFolder || IsGenre || IsMusicGenre || IsArtist; + return RunTimeTicks.HasValue || IsFolderItem || IsGenre || IsMusicGenre || IsArtist; } } diff --git a/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs b/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs index 3a6ad04448..0ece1e4a00 100644 --- a/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs +++ b/MediaBrowser.Model/LiveTv/LiveTvChannelQuery.cs @@ -59,5 +59,11 @@ namespace MediaBrowser.Model.LiveTv /// /// true if [add current program]; otherwise, false. public bool AddCurrentProgram { get; set; } + public bool EnableUserData { get; set; } + + public LiveTvChannelQuery() + { + EnableUserData = true; + } } } diff --git a/MediaBrowser.Model/LiveTv/ProgramQuery.cs b/MediaBrowser.Model/LiveTv/ProgramQuery.cs index 0141191c18..bf459237a0 100644 --- a/MediaBrowser.Model/LiveTv/ProgramQuery.cs +++ b/MediaBrowser.Model/LiveTv/ProgramQuery.cs @@ -15,9 +15,11 @@ namespace MediaBrowser.Model.LiveTv SortBy = new string[] { }; Genres = new string[] { }; EnableTotalRecordCount = true; + EnableUserData = true; } public bool EnableTotalRecordCount { get; set; } + public bool EnableUserData { get; set; } /// /// Fields to return within the items, in addition to basic information diff --git a/MediaBrowser.Model/Sync/SyncJobQuery.cs b/MediaBrowser.Model/Sync/SyncJobQuery.cs index e86ec929f2..bb99b5d5f3 100644 --- a/MediaBrowser.Model/Sync/SyncJobQuery.cs +++ b/MediaBrowser.Model/Sync/SyncJobQuery.cs @@ -23,6 +23,7 @@ namespace MediaBrowser.Model.Sync /// /// The user identifier. public string UserId { get; set; } + public string ExcludeTargetIds { get; set; } /// /// Gets or sets the status. /// diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index b646605ed4..3d257d1947 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -329,7 +329,7 @@ namespace MediaBrowser.Server.Implementations.Dto if (user != null) { - await AttachUserSpecificInfo(dto, item, user, fields).ConfigureAwait(false); + await AttachUserSpecificInfo(dto, item, user, options).ConfigureAwait(false); } var hasMediaSources = item as IHasMediaSources; @@ -446,17 +446,18 @@ namespace MediaBrowser.Server.Implementations.Dto /// /// Attaches the user specific info. /// - /// The dto. - /// The item. - /// The user. - /// The fields. - private async Task AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, List fields) + private async Task AttachUserSpecificInfo(BaseItemDto dto, BaseItem item, User user, DtoOptions dtoOptions) { + var fields = dtoOptions.Fields; + if (item.IsFolder) { var folder = (Folder)item; - dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user).ConfigureAwait(false); + if (dtoOptions.EnableUserData) + { + dto.UserData = await _userDataRepository.GetUserDataDto(item, dto, user).ConfigureAwait(false); + } if (!dto.ChildCount.HasValue && item.SourceType == SourceType.Library) { @@ -476,7 +477,10 @@ namespace MediaBrowser.Server.Implementations.Dto else { - dto.UserData = _userDataRepository.GetUserDataDto(item, user).Result; + if (dtoOptions.EnableUserData) + { + dto.UserData = _userDataRepository.GetUserDataDto(item, user).Result; + } } dto.PlayAccess = item.GetPlayAccess(user); @@ -484,7 +488,10 @@ namespace MediaBrowser.Server.Implementations.Dto if (fields.Contains(ItemFields.BasicSyncInfo) || fields.Contains(ItemFields.SyncInfo)) { var userCanSync = user != null && user.Policy.EnableSync; - dto.SupportsSync = userCanSync && _syncManager.SupportsSync(item); + if (userCanSync && _syncManager.SupportsSync(item)) + { + dto.SupportsSync = true; + } } if (fields.Contains(ItemFields.SeasonUserData)) @@ -969,7 +976,16 @@ namespace MediaBrowser.Server.Implementations.Dto dto.Id = GetDtoId(item); dto.IndexNumber = item.IndexNumber; dto.ParentIndexNumber = item.ParentIndexNumber; - dto.IsFolder = item.IsFolder; + + if (item.IsFolder) + { + dto.IsFolder = true; + } + else if (item is IHasMediaSources) + { + dto.IsFolder = false; + } + dto.MediaType = item.MediaType; dto.LocationType = item.LocationType; if (item.IsHD.HasValue && item.IsHD.Value) diff --git a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs index 09d156661d..ccbcb910d3 100644 --- a/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs +++ b/MediaBrowser.Server.Implementations/LiveTv/LiveTvManager.cs @@ -951,6 +951,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv var queryResult = _libraryManager.QueryItems(internalQuery); + RemoveFields(options); + var returnArray = (await _dtoService.GetBaseItemDtos(queryResult.Items, options, user).ConfigureAwait(false)).ToArray(); var result = new QueryResult @@ -1031,6 +1033,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv var user = _userManager.GetUserById(query.UserId); + RemoveFields(options); + var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ConfigureAwait(false)).ToArray(); var result = new QueryResult @@ -1662,6 +1666,8 @@ namespace MediaBrowser.Server.Implementations.LiveTv var internalResult = await GetInternalRecordings(query, cancellationToken).ConfigureAwait(false); + RemoveFields(options); + var returnArray = (await _dtoService.GetBaseItemDtos(internalResult.Items, options, user).ConfigureAwait(false)).ToArray(); return new QueryResult @@ -1922,7 +1928,7 @@ namespace MediaBrowser.Server.Implementations.LiveTv var channelIds = tuples.Select(i => i.Item2.Id.ToString("N")).Distinct().ToArray(); - var programs = _libraryManager.GetItemList(new InternalItemsQuery(user) + var programs = options.AddCurrentProgram ? _libraryManager.GetItemList(new InternalItemsQuery(user) { IncludeItemTypes = new[] { typeof(LiveTvProgram).Name }, ChannelIds = channelIds, @@ -1932,7 +1938,9 @@ namespace MediaBrowser.Server.Implementations.LiveTv SortBy = new[] { "StartDate" }, TopParentIds = new[] { GetInternalLiveTvFolder(CancellationToken.None).Result.Id.ToString("N") } - }).ToList(); + }).ToList() : new List(); + + RemoveFields(options); foreach (var tuple in tuples) { @@ -1944,14 +1952,20 @@ namespace MediaBrowser.Server.Implementations.LiveTv dto.ChannelType = channel.ChannelType; dto.ServiceName = GetService(channel).Name; - dto.MediaSources = channel.GetMediaSources(true).ToList(); + if (options.Fields.Contains(ItemFields.MediaSources)) + { + dto.MediaSources = channel.GetMediaSources(true).ToList(); + } var channelIdString = channel.Id.ToString("N"); - var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString)); - - if (currentProgram != null) + if (options.AddCurrentProgram) { - dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user); + var currentProgram = programs.FirstOrDefault(i => string.Equals(i.ChannelId, channelIdString)); + + if (currentProgram != null) + { + dto.CurrentProgram = _dtoService.GetBaseItemDto(currentProgram, options, user); + } } } } @@ -2447,6 +2461,14 @@ namespace MediaBrowser.Server.Implementations.LiveTv return _dtoService.GetBaseItemDto(folder, new DtoOptions(), user); } + private void RemoveFields(DtoOptions options) + { + options.Fields.Remove(ItemFields.CanDelete); + options.Fields.Remove(ItemFields.CanDownload); + options.Fields.Remove(ItemFields.DisplayPreferencesId); + options.Fields.Remove(ItemFields.Etag); + } + public async Task GetInternalLiveTvFolder(CancellationToken cancellationToken) { var name = _localization.GetLocalizedString("ViewTypeLiveTV"); diff --git a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs index d7c77e655b..6b7bcfa010 100644 --- a/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs +++ b/MediaBrowser.Server.Implementations/Sync/SyncRepository.cs @@ -414,6 +414,20 @@ namespace MediaBrowser.Server.Implementations.Sync whereClauses.Add("TargetId=@TargetId"); cmd.Parameters.Add(cmd, "@TargetId", DbType.String).Value = query.TargetId; } + if (!string.IsNullOrWhiteSpace(query.ExcludeTargetIds)) + { + var excludeIds = (query.ExcludeTargetIds ?? string.Empty).Split(new[] { ',' }, StringSplitOptions.RemoveEmptyEntries); + if (excludeIds.Length == 1) + { + whereClauses.Add("TargetId<>@ExcludeTargetId"); + cmd.Parameters.Add(cmd, "@ExcludeTargetId", DbType.String).Value = excludeIds[0]; + } + else if (excludeIds.Length > 1) + { + whereClauses.Add("TargetId<>@ExcludeTargetId"); + cmd.Parameters.Add(cmd, "@ExcludeTargetId", DbType.String).Value = excludeIds[0]; + } + } if (!string.IsNullOrWhiteSpace(query.UserId)) { whereClauses.Add("UserId=@UserId"); -- cgit v1.2.3 From cc62faa1c2c212d07c556e5368888ecc3ee537eb Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Thu, 18 Aug 2016 01:56:10 -0400 Subject: update season queries --- MediaBrowser.Api/TvShowsService.cs | 38 +---- .../Entities/Audio/MusicArtist.cs | 49 ++++++ .../Entities/Audio/MusicGenre.cs | 43 +++++ MediaBrowser.Controller/Entities/GameGenre.cs | 43 +++++ MediaBrowser.Controller/Entities/Genre.cs | 43 +++++ .../Entities/InternalItemsQuery.cs | 2 + MediaBrowser.Controller/Entities/Person.cs | 58 +++++++ MediaBrowser.Controller/Entities/Studio.cs | 43 +++++ MediaBrowser.Controller/Entities/TV/Season.cs | 30 +--- MediaBrowser.Controller/Entities/TV/Series.cs | 175 +++++++++++---------- .../Entities/UserViewBuilder.cs | 53 ------- MediaBrowser.Controller/Entities/Year.cs | 43 +++++ MediaBrowser.Controller/IServerApplicationPaths.cs | 2 + MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs | 8 +- MediaBrowser.Providers/Manager/MetadataService.cs | 11 +- .../Dto/DtoService.cs | 116 ++------------ .../Library/LibraryManager.cs | 72 +-------- .../Library/SearchEngine.cs | 20 +-- .../Persistence/SqliteItemRepository.cs | 11 ++ .../ServerApplicationPaths.cs | 8 + .../Session/SessionManager.cs | 3 +- 21 files changed, 488 insertions(+), 383 deletions(-) (limited to 'MediaBrowser.Server.Implementations/Dto') diff --git a/MediaBrowser.Api/TvShowsService.cs b/MediaBrowser.Api/TvShowsService.cs index e295f3b3a6..daaa6343d1 100644 --- a/MediaBrowser.Api/TvShowsService.cs +++ b/MediaBrowser.Api/TvShowsService.cs @@ -423,23 +423,14 @@ namespace MediaBrowser.Api throw new ResourceNotFoundException("No series exists with Id " + request.Id); } - var seasons = series.GetSeasons(user); - - if (request.IsSpecialSeason.HasValue) + var seasons = (await series.GetItems(new InternalItemsQuery(user) { - var val = request.IsSpecialSeason.Value; - - seasons = seasons.Where(i => i.IsSpecialSeason == val); - } + IsMissing = request.IsMissing, + IsVirtualUnaired = request.IsVirtualUnaired, + IsSpecialSeason = request.IsSpecialSeason, + AdjacentTo = request.AdjacentTo - seasons = FilterVirtualSeasons(request, seasons); - - // This must be the last filter - if (!string.IsNullOrEmpty(request.AdjacentTo)) - { - seasons = UserViewBuilder.FilterForAdjacency(seasons, request.AdjacentTo) - .Cast(); - } + }).ConfigureAwait(false)).Items.OfType(); var dtoOptions = GetDtoOptions(request); @@ -453,23 +444,6 @@ namespace MediaBrowser.Api }; } - private IEnumerable FilterVirtualSeasons(GetSeasons request, IEnumerable items) - { - if (request.IsMissing.HasValue) - { - var val = request.IsMissing.Value; - items = items.Where(i => (i.IsMissingSeason) == val); - } - - if (request.IsVirtualUnaired.HasValue) - { - var val = request.IsVirtualUnaired.Value; - items = items.Where(i => i.IsVirtualUnaired == val); - } - - return items; - } - public async Task Get(GetEpisodes request) { var user = _userManager.GetUserById(request.UserId); diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 56f9a5b888..81d1deaa23 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -270,5 +270,54 @@ namespace MediaBrowser.Controller.Entities.Audio return false; } } + + public static string GetPath(string name, bool normalizeName = true) + { + // Trim the period at the end because windows will have a hard time with that + var validName = normalizeName ? + FileSystem.GetValidFilename(name).Trim().TrimEnd('.') : + name; + + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.ArtistsPath, validName); + } + + private string GetRebasedPath() + { + return GetPath(System.IO.Path.GetFileName(Path), false); + } + + public override bool RequiresRefresh() + { + if (IsAccessedByName) + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath); + return true; + } + } + return base.RequiresRefresh(); + } + + /// + /// This is called before any metadata refresh and returns true or false indicating if changes were made + /// + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + if (IsAccessedByName) + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Path = newPath; + hasChanges = true; + } + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index 9aa5625fac..bd991d9f47 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -92,5 +92,48 @@ namespace MediaBrowser.Controller.Entities.Audio return LibraryManager.GetItemList(query); } + + public static string GetPath(string name, bool normalizeName = true) + { + // Trim the period at the end because windows will have a hard time with that + var validName = normalizeName ? + FileSystem.GetValidFilename(name).Trim().TrimEnd('.') : + name; + + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.MusicGenrePath, validName); + } + + private string GetRebasedPath() + { + return GetPath(System.IO.Path.GetFileName(Path), false); + } + + public override bool RequiresRefresh() + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath); + return true; + } + return base.RequiresRefresh(); + } + + /// + /// This is called before any metadata refresh and returns true or false indicating if changes were made + /// + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Path = newPath; + hasChanges = true; + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 5d66bf3abc..6448828fb3 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -84,5 +84,48 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public static string GetPath(string name, bool normalizeName = true) + { + // Trim the period at the end because windows will have a hard time with that + var validName = normalizeName ? + FileSystem.GetValidFilename(name).Trim().TrimEnd('.') : + name; + + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.GameGenrePath, validName); + } + + private string GetRebasedPath() + { + return GetPath(System.IO.Path.GetFileName(Path), false); + } + + public override bool RequiresRefresh() + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath); + return true; + } + return base.RequiresRefresh(); + } + + /// + /// This is called before any metadata refresh and returns true or false indicating if changes were made + /// + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Path = newPath; + hasChanges = true; + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index c7fe25a962..1736ba8c76 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -87,5 +87,48 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public static string GetPath(string name, bool normalizeName = true) + { + // Trim the period at the end because windows will have a hard time with that + var validName = normalizeName ? + FileSystem.GetValidFilename(name).Trim().TrimEnd('.') : + name; + + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.GenrePath, validName); + } + + private string GetRebasedPath() + { + return GetPath(System.IO.Path.GetFileName(Path), false); + } + + public override bool RequiresRefresh() + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath); + return true; + } + return base.RequiresRefresh(); + } + + /// + /// This is called before any metadata refresh and returns true or false indicating if changes were made + /// + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Path = newPath; + hasChanges = true; + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 69cab5ec53..deea631127 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -37,6 +37,7 @@ namespace MediaBrowser.Controller.Entities public string[] Genres { get; set; } public string[] Keywords { get; set; } + public bool? IsSpecialSeason { get; set; } public bool? IsMissing { get; set; } public bool? IsUnaired { get; set; } public bool? IsVirtualUnaired { get; set; } @@ -50,6 +51,7 @@ namespace MediaBrowser.Controller.Entities public string PresentationUniqueKey { get; set; } public string Path { get; set; } + public string PathNotStartsWith { get; set; } public string Name { get; set; } public string SlugName { get; set; } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 4ee140b2b1..f21bc0a71e 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -122,6 +122,64 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public static string GetPath(string name, bool normalizeName = true) + { + // Trim the period at the end because windows will have a hard time with that + var validFilename = normalizeName ? + FileSystem.GetValidFilename(name).Trim().TrimEnd('.') : + name; + + string subFolderPrefix = null; + + foreach (char c in validFilename) + { + if (char.IsLetterOrDigit(c)) + { + subFolderPrefix = c.ToString(); + break; + } + } + + var path = ConfigurationManager.ApplicationPaths.PeoplePath; + + return string.IsNullOrEmpty(subFolderPrefix) ? + System.IO.Path.Combine(path, validFilename) : + System.IO.Path.Combine(path, subFolderPrefix, validFilename); + } + + private string GetRebasedPath() + { + return GetPath(System.IO.Path.GetFileName(Path), false); + } + + public override bool RequiresRefresh() + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath); + return true; + } + return base.RequiresRefresh(); + } + + /// + /// This is called before any metadata refresh and returns true or false indicating if changes were made + /// + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Path = newPath; + hasChanges = true; + } + + return hasChanges; + } } /// diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 7e3d6fe8e1..04b09b7442 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -85,5 +85,48 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public static string GetPath(string name, bool normalizeName = true) + { + // Trim the period at the end because windows will have a hard time with that + var validName = normalizeName ? + FileSystem.GetValidFilename(name).Trim().TrimEnd('.') : + name; + + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.StudioPath, validName); + } + + private string GetRebasedPath() + { + return GetPath(System.IO.Path.GetFileName(Path), false); + } + + public override bool RequiresRefresh() + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath); + return true; + } + return base.RequiresRefresh(); + } + + /// + /// This is called before any metadata refresh and returns true or false indicating if changes were made + /// + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Path = newPath; + hasChanges = true; + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 628e27c02e..842b2fd602 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -141,24 +141,6 @@ namespace MediaBrowser.Controller.Entities.TV return IndexNumber != null ? IndexNumber.Value.ToString("0000") : Name; } - [IgnoreDataMember] - public bool IsMissingSeason - { - get { return (IsVirtualItem) && !IsUnaired; } - } - - [IgnoreDataMember] - public bool IsVirtualUnaired - { - get { return (IsVirtualItem) && IsUnaired; } - } - - [IgnoreDataMember] - public bool IsSpecialSeason - { - get { return (IndexNumber ?? -1) == 0; } - } - protected override Task> GetItemsInternal(InternalItemsQuery query) { if (query.User == null) @@ -189,19 +171,17 @@ namespace MediaBrowser.Controller.Entities.TV /// IEnumerable{Episode}. public IEnumerable GetEpisodes(User user) { - var config = user.Configuration; - - return GetEpisodes(Series, user, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); + return GetEpisodes(Series, user); } - public IEnumerable GetEpisodes(Series series, User user, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes) + public IEnumerable GetEpisodes(Series series, User user) { - return GetEpisodes(series, user, includeMissingEpisodes, includeVirtualUnairedEpisodes, null); + return GetEpisodes(series, user, null); } - public IEnumerable GetEpisodes(Series series, User user, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable allSeriesEpisodes) + public IEnumerable GetEpisodes(Series series, User user, IEnumerable allSeriesEpisodes) { - return series.GetSeasonEpisodes(user, this, includeMissingEpisodes, includeVirtualUnairedEpisodes, allSeriesEpisodes); + return series.GetSeasonEpisodes(user, this, allSeriesEpisodes); } public IEnumerable GetEpisodes() diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index e48c32a25e..4915cfedc7 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -207,7 +207,30 @@ namespace MediaBrowser.Controller.Entities.TV { var config = user.Configuration; - return GetSeasons(user, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); + var seriesKey = GetUniqueSeriesKey(this); + + Logger.Debug("GetSeasons SeriesKey: {0}", seriesKey); + var query = new InternalItemsQuery(user) + { + AncestorWithPresentationUniqueKey = seriesKey, + IncludeItemTypes = new[] {typeof (Season).Name}, + SortBy = new[] {ItemSortBy.SortName} + }; + + if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes) + { + query.IsVirtualItem = false; + } + else if (!config.DisplayMissingEpisodes) + { + query.IsMissing = false; + } + else if (!config.DisplayUnairedEpisodes) + { + query.IsVirtualUnaired = false; + } + + return LibraryManager.GetItemList(query).Cast(); } protected override Task> GetItemsInternal(InternalItemsQuery query) @@ -241,59 +264,39 @@ namespace MediaBrowser.Controller.Entities.TV return Task.FromResult(result); } - public IEnumerable GetSeasons(User user, bool includeMissingSeasons, bool includeVirtualUnaired) + public IEnumerable GetEpisodes(User user) { var seriesKey = GetUniqueSeriesKey(this); + Logger.Debug("GetEpisodes seriesKey: {0}", seriesKey); - Logger.Debug("GetSeasons SeriesKey: {0}", seriesKey); - var seasons = LibraryManager.GetItemList(new InternalItemsQuery(user) + var query = new InternalItemsQuery(user) { AncestorWithPresentationUniqueKey = seriesKey, - IncludeItemTypes = new[] { typeof(Season).Name }, - SortBy = new[] { ItemSortBy.SortName } - - }).Cast().ToList(); - - - if (!includeMissingSeasons) + IncludeItemTypes = new[] {typeof (Episode).Name, typeof (Season).Name}, + SortBy = new[] {ItemSortBy.SortName} + }; + var config = user.Configuration; + if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes) { - seasons = seasons.Where(i => !(i.IsMissingSeason)).ToList(); + query.IsVirtualItem = false; } - - if (!includeVirtualUnaired) + else if (!config.DisplayMissingEpisodes) { - seasons = seasons.Where(i => !i.IsVirtualUnaired).ToList(); + query.IsMissing = false; } - - return seasons; - } - - public IEnumerable GetEpisodes(User user) - { - var config = user.Configuration; - - return GetEpisodes(user, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); - } - - public IEnumerable GetEpisodes(User user, bool includeMissing, bool includeVirtualUnaired) - { - var seriesKey = GetUniqueSeriesKey(this); - Logger.Debug("GetEpisodes seriesKey: {0}", seriesKey); - - var allItems = LibraryManager.GetItemList(new InternalItemsQuery(user) + else if (!config.DisplayUnairedEpisodes) { - AncestorWithPresentationUniqueKey = seriesKey, - IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name }, - SortBy = new[] { ItemSortBy.SortName } + query.IsVirtualUnaired = false; + } - }).ToList(); + var allItems = LibraryManager.GetItemList(query).ToList(); Logger.Debug("GetEpisodes return {0} items from database", allItems.Count); var allSeriesEpisodes = allItems.OfType().ToList(); var allEpisodes = allItems.OfType() - .SelectMany(i => i.GetEpisodes(this, user, includeMissing, includeVirtualUnaired, allSeriesEpisodes)) + .SelectMany(i => i.GetEpisodes(this, user, allSeriesEpisodes)) .Reverse() .ToList(); @@ -370,13 +373,6 @@ namespace MediaBrowser.Controller.Entities.TV progress.Report(100); } - public IEnumerable GetSeasonEpisodes(User user, Season season) - { - var config = user.Configuration; - - return GetSeasonEpisodes(user, season, config.DisplayMissingEpisodes, config.DisplayUnairedEpisodes); - } - private IEnumerable GetAllEpisodes(User user) { Logger.Debug("Series.GetAllEpisodes entering GetItemList"); @@ -394,62 +390,51 @@ namespace MediaBrowser.Controller.Entities.TV return result; } - public IEnumerable GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes) + public IEnumerable GetSeasonEpisodes(User user, Season parentSeason) { - IEnumerable episodes = GetAllEpisodes(user); - - return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes, episodes); - } + var seriesKey = GetUniqueSeriesKey(this); + Logger.Debug("GetSeasonEpisodes seriesKey: {0}", seriesKey); - public IEnumerable GetSeasonEpisodes(User user, Season parentSeason, bool includeMissingEpisodes, bool includeVirtualUnairedEpisodes, IEnumerable allSeriesEpisodes) - { - if (allSeriesEpisodes == null) + var query = new InternalItemsQuery(user) { - Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null"); - return GetSeasonEpisodes(user, parentSeason, includeMissingEpisodes, includeVirtualUnairedEpisodes); + AncestorWithPresentationUniqueKey = seriesKey, + IncludeItemTypes = new[] { typeof(Episode).Name }, + SortBy = new[] { ItemSortBy.SortName } + }; + var config = user.Configuration; + if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes) + { + query.IsVirtualItem = false; } - - Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason"); - var episodes = FilterEpisodesBySeason(allSeriesEpisodes, parentSeason, ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons); - - if (!includeMissingEpisodes) + else if (!config.DisplayMissingEpisodes) { - episodes = episodes.Where(i => !i.IsMissingEpisode); + query.IsMissing = false; } - if (!includeVirtualUnairedEpisodes) + else if (!config.DisplayUnairedEpisodes) { - episodes = episodes.Where(i => !i.IsVirtualUnaired); + query.IsVirtualUnaired = false; } - var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder; + var allItems = LibraryManager.GetItemList(query).OfType(); - return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending) - .Cast(); + return GetSeasonEpisodes(user, parentSeason, allItems); } - /// - /// Filters the episodes by season. - /// - public static IEnumerable FilterEpisodesBySeason(IEnumerable episodes, int seasonNumber, bool includeSpecials) + public IEnumerable GetSeasonEpisodes(User user, Season parentSeason, IEnumerable allSeriesEpisodes) { - if (!includeSpecials || seasonNumber < 1) + if (allSeriesEpisodes == null) { - return episodes.Where(i => (i.ParentIndexNumber ?? -1) == seasonNumber); + Logger.Debug("GetSeasonEpisodes allSeriesEpisodes is null"); + return GetSeasonEpisodes(user, parentSeason); } - return episodes.Where(i => - { - var episode = i; - - if (episode != null) - { - var currentSeasonNumber = episode.AiredSeasonNumber; + Logger.Debug("GetSeasonEpisodes FilterEpisodesBySeason"); + var episodes = FilterEpisodesBySeason(allSeriesEpisodes, parentSeason, ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons); - return currentSeasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber; - } + var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder; - return false; - }); + return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending) + .Cast(); } /// @@ -480,6 +465,32 @@ namespace MediaBrowser.Controller.Entities.TV }); } + /// + /// Filters the episodes by season. + /// + public static IEnumerable FilterEpisodesBySeason(IEnumerable episodes, int seasonNumber, bool includeSpecials) + { + if (!includeSpecials || seasonNumber < 1) + { + return episodes.Where(i => (i.ParentIndexNumber ?? -1) == seasonNumber); + } + + return episodes.Where(i => + { + var episode = i; + + if (episode != null) + { + var currentSeasonNumber = episode.AiredSeasonNumber; + + return currentSeasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber; + } + + return false; + }); + } + + protected override bool GetBlockUnratedValue(UserPolicy config) { return config.BlockUnratedItems.Contains(UnratedItem.Series); diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 6128192ea2..9f3acc3fc3 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -1100,8 +1100,6 @@ namespace MediaBrowser.Controller.Entities bool? isVirtualUnaired, bool? isUnaired) { - items = FilterVirtualSeasons(items, isMissing, isVirtualUnaired, isUnaired); - if (isMissing.HasValue) { var val = isMissing.Value; @@ -1147,57 +1145,6 @@ namespace MediaBrowser.Controller.Entities return items; } - private static IEnumerable FilterVirtualSeasons( - IEnumerable items, - bool? isMissing, - bool? isVirtualUnaired, - bool? isUnaired) - { - if (isMissing.HasValue) - { - var val = isMissing.Value; - items = items.Where(i => - { - var e = i as Season; - if (e != null) - { - return (e.IsMissingSeason) == val; - } - return true; - }); - } - - if (isUnaired.HasValue) - { - var val = isUnaired.Value; - items = items.Where(i => - { - var e = i as Season; - if (e != null) - { - return e.IsUnaired == val; - } - return true; - }); - } - - if (isVirtualUnaired.HasValue) - { - var val = isVirtualUnaired.Value; - items = items.Where(i => - { - var e = i as Season; - if (e != null) - { - return e.IsVirtualUnaired == val; - } - return true; - }); - } - - return items; - } - public static QueryResult SortAndPage(IEnumerable items, int? totalRecordLimit, InternalItemsQuery query, diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index db896f1fc7..4197ea93e5 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -112,5 +112,48 @@ namespace MediaBrowser.Controller.Entities return false; } } + + public static string GetPath(string name, bool normalizeName = true) + { + // Trim the period at the end because windows will have a hard time with that + var validName = normalizeName ? + FileSystem.GetValidFilename(name).Trim().TrimEnd('.') : + name; + + return System.IO.Path.Combine(ConfigurationManager.ApplicationPaths.YearPath, validName); + } + + private string GetRebasedPath() + { + return GetPath(System.IO.Path.GetFileName(Path), false); + } + + public override bool RequiresRefresh() + { + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Logger.Debug("{0} path has changed from {1} to {2}", GetType().Name, Path, newPath); + return true; + } + return base.RequiresRefresh(); + } + + /// + /// This is called before any metadata refresh and returns true or false indicating if changes were made + /// + public override bool BeforeMetadataRefresh() + { + var hasChanges = base.BeforeMetadataRefresh(); + + var newPath = GetRebasedPath(); + if (!string.Equals(Path, newPath, StringComparison.Ordinal)) + { + Path = newPath; + hasChanges = true; + } + + return hasChanges; + } } } diff --git a/MediaBrowser.Controller/IServerApplicationPaths.cs b/MediaBrowser.Controller/IServerApplicationPaths.cs index c07934d0b1..c89a60a6f8 100644 --- a/MediaBrowser.Controller/IServerApplicationPaths.cs +++ b/MediaBrowser.Controller/IServerApplicationPaths.cs @@ -106,5 +106,7 @@ namespace MediaBrowser.Controller /// /// The internal metadata path. string InternalMetadataPath { get; } + + string ArtistsPath { get; } } } \ No newline at end of file diff --git a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs index c8a28e832a..e90f6bdc36 100644 --- a/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs +++ b/MediaBrowser.MediaEncoding/Encoder/MediaEncoder.cs @@ -343,14 +343,16 @@ namespace MediaBrowser.MediaEncoding.Encoder // If that doesn't pan out, then do a recursive search var files = Directory.GetFiles(path); - var ffmpegPath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffmpeg", StringComparison.OrdinalIgnoreCase)); - var ffprobePath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffprobe", StringComparison.OrdinalIgnoreCase)); + var excludeExtensions = new[] { ".c" }; + + var ffmpegPath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffmpeg", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); + var ffprobePath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffprobe", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); if (string.IsNullOrWhiteSpace(ffmpegPath) || !File.Exists(ffmpegPath)) { files = Directory.GetFiles(path, "*", SearchOption.AllDirectories); - ffmpegPath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffmpeg", StringComparison.OrdinalIgnoreCase)); + ffmpegPath = files.FirstOrDefault(i => string.Equals(Path.GetFileNameWithoutExtension(i), "ffmpeg", StringComparison.OrdinalIgnoreCase) && !excludeExtensions.Contains(Path.GetExtension(i) ?? string.Empty)); if (!string.IsNullOrWhiteSpace(ffmpegPath)) { diff --git a/MediaBrowser.Providers/Manager/MetadataService.cs b/MediaBrowser.Providers/Manager/MetadataService.cs index 04437cff79..2a69948b1a 100644 --- a/MediaBrowser.Providers/Manager/MetadataService.cs +++ b/MediaBrowser.Providers/Manager/MetadataService.cs @@ -42,6 +42,13 @@ namespace MediaBrowser.Providers.Manager var config = ProviderManager.GetMetadataOptions(item); var updateType = ItemUpdateType.None; + var requiresRefresh = false; + + if (refreshOptions.MetadataRefreshMode != MetadataRefreshMode.None) + { + // TODO: If this returns true, should we instead just change metadata refresh mode to Full? + requiresRefresh = item.RequiresRefresh(); + } var itemImageProvider = new ItemImageProvider(Logger, ProviderManager, ServerConfigurationManager, FileSystem); var localImagesFailed = false; @@ -70,14 +77,10 @@ namespace MediaBrowser.Providers.Manager bool hasRefreshedMetadata = true; bool hasRefreshedImages = true; - var requiresRefresh = false; // Next run metadata providers if (refreshOptions.MetadataRefreshMode != MetadataRefreshMode.None) { - // TODO: If this returns true, should we instead just change metadata refresh mode to Full? - requiresRefresh = item.RequiresRefresh(); - var providers = GetProviders(item, refreshOptions, requiresRefresh) .ToList(); diff --git a/MediaBrowser.Server.Implementations/Dto/DtoService.cs b/MediaBrowser.Server.Implementations/Dto/DtoService.cs index 3d257d1947..be68162caf 100644 --- a/MediaBrowser.Server.Implementations/Dto/DtoService.cs +++ b/MediaBrowser.Server.Implementations/Dto/DtoService.cs @@ -955,20 +955,23 @@ namespace MediaBrowser.Server.Implementations.Dto dto.Genres = item.Genres; } - dto.ImageTags = new Dictionary(); - - // Prevent implicitly captured closure - var currentItem = item; - foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type)) - .ToList()) + if (options.EnableImages) { - if (options.GetImageLimit(image.Type) > 0) - { - var tag = GetImageCacheTag(item, image); + dto.ImageTags = new Dictionary(); - if (tag != null) + // Prevent implicitly captured closure + var currentItem = item; + foreach (var image in currentItem.ImageInfos.Where(i => !currentItem.AllowsMultipleImages(i.Type)) + .ToList()) + { + if (options.GetImageLimit(image.Type) > 0) { - dto.ImageTags[image.Type] = tag; + var tag = GetImageCacheTag(item, image); + + if (tag != null) + { + dto.ImageTags[image.Type] = tag; + } } } } @@ -1527,97 +1530,6 @@ namespace MediaBrowser.Server.Implementations.Dto } } - /// - /// Since it can be slow to make all of these calculations independently, this method will provide a way to do them all at once - /// - /// The folder. - /// The user. - /// The dto. - /// The fields. - /// The synchronize progress. - /// Task. - private async Task SetSpecialCounts(Folder folder, User user, BaseItemDto dto, List fields, Dictionary syncProgress) - { - var recursiveItemCount = 0; - var unplayed = 0; - - double totalPercentPlayed = 0; - double totalSyncPercent = 0; - - var children = await folder.GetItems(new InternalItemsQuery - { - IsFolder = false, - Recursive = true, - ExcludeLocationTypes = new[] { LocationType.Virtual }, - User = user - - }).ConfigureAwait(false); - - // Loop through each recursive child - foreach (var child in children.Items) - { - var userdata = _userDataRepository.GetUserData(user, child); - - recursiveItemCount++; - - var isUnplayed = true; - - // Incrememt totalPercentPlayed - if (userdata != null) - { - if (userdata.Played) - { - totalPercentPlayed += 100; - - isUnplayed = false; - } - else if (userdata.PlaybackPositionTicks > 0 && child.RunTimeTicks.HasValue && child.RunTimeTicks.Value > 0) - { - double itemPercent = userdata.PlaybackPositionTicks; - itemPercent /= child.RunTimeTicks.Value; - totalPercentPlayed += itemPercent; - } - } - - if (isUnplayed) - { - unplayed++; - } - - double percent = 0; - SyncJobItemStatus syncItemProgress; - if (syncProgress.TryGetValue(child.Id.ToString("N"), out syncItemProgress)) - { - switch (syncItemProgress) - { - case SyncJobItemStatus.Synced: - percent = 100; - break; - case SyncJobItemStatus.Converting: - case SyncJobItemStatus.ReadyToTransfer: - case SyncJobItemStatus.Transferring: - percent = 50; - break; - } - } - totalSyncPercent += percent; - } - - dto.RecursiveItemCount = recursiveItemCount; - dto.UserData.UnplayedItemCount = unplayed; - - if (recursiveItemCount > 0) - { - dto.UserData.PlayedPercentage = totalPercentPlayed / recursiveItemCount; - - var pct = totalSyncPercent / recursiveItemCount; - if (pct > 0) - { - dto.SyncPercent = pct; - } - } - } - /// /// Attaches the primary image aspect ratio. /// diff --git a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs index a19f70e68c..a5e6c1b92d 100644 --- a/MediaBrowser.Server.Implementations/Library/LibraryManager.cs +++ b/MediaBrowser.Server.Implementations/Library/LibraryManager.cs @@ -829,7 +829,7 @@ namespace MediaBrowser.Server.Implementations.Library /// Task{Person}. public Person GetPerson(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.PeoplePath, name); + return CreateItemByName(Person.GetPath(name), name); } /// @@ -839,7 +839,7 @@ namespace MediaBrowser.Server.Implementations.Library /// Task{Studio}. public Studio GetStudio(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.StudioPath, name); + return CreateItemByName(Studio.GetPath(name), name); } /// @@ -849,7 +849,7 @@ namespace MediaBrowser.Server.Implementations.Library /// Task{Genre}. public Genre GetGenre(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.GenrePath, name); + return CreateItemByName(Genre.GetPath(name), name); } /// @@ -859,7 +859,7 @@ namespace MediaBrowser.Server.Implementations.Library /// Task{MusicGenre}. public MusicGenre GetMusicGenre(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.MusicGenrePath, name); + return CreateItemByName(MusicGenre.GetPath(name), name); } /// @@ -869,14 +869,9 @@ namespace MediaBrowser.Server.Implementations.Library /// Task{GameGenre}. public GameGenre GetGameGenre(string name) { - return GetItemByName(ConfigurationManager.ApplicationPaths.GameGenrePath, name); + return CreateItemByName(GameGenre.GetPath(name), name); } - /// - /// The us culture - /// - private static readonly CultureInfo UsCulture = new CultureInfo("en-US"); - /// /// Gets a Year /// @@ -890,19 +885,9 @@ namespace MediaBrowser.Server.Implementations.Library throw new ArgumentOutOfRangeException("Years less than or equal to 0 are invalid."); } - return GetItemByName(ConfigurationManager.ApplicationPaths.YearPath, value.ToString(UsCulture)); - } + var name = value.ToString(CultureInfo.InvariantCulture); - /// - /// Gets the artists path. - /// - /// The artists path. - public string ArtistsPath - { - get - { - return Path.Combine(ConfigurationManager.ApplicationPaths.ItemsByNamePath, "artists"); - } + return CreateItemByName(Year.GetPath(name), name); } /// @@ -912,48 +897,7 @@ namespace MediaBrowser.Server.Implementations.Library /// Task{Genre}. public MusicArtist GetArtist(string name) { - return GetItemByName(ArtistsPath, name); - } - - private T GetItemByName(string path, string name) - where T : BaseItem, new() - { - if (string.IsNullOrWhiteSpace(path)) - { - throw new ArgumentNullException("path"); - } - - if (string.IsNullOrWhiteSpace(name)) - { - throw new ArgumentNullException("name"); - } - - // Trim the period at the end because windows will have a hard time with that - var validFilename = _fileSystem.GetValidFilename(name) - .Trim() - .TrimEnd('.'); - - string subFolderPrefix = null; - - var type = typeof(T); - - if (type == typeof(Person)) - { - foreach (char c in validFilename) - { - if (char.IsLetterOrDigit(c)) - { - subFolderPrefix = c.ToString(); - break; - } - } - } - - var fullPath = string.IsNullOrEmpty(subFolderPrefix) ? - Path.Combine(path, validFilename) : - Path.Combine(path, subFolderPrefix, validFilename); - - return CreateItemByName(fullPath, name); + return CreateItemByName(MusicArtist.GetPath(name), name); } private T CreateItemByName(string path, string name) diff --git a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs index cf6f070d03..a6d6b5cb8b 100644 --- a/MediaBrowser.Server.Implementations/Library/SearchEngine.cs +++ b/MediaBrowser.Server.Implementations/Library/SearchEngine.cs @@ -166,12 +166,12 @@ namespace MediaBrowser.Server.Implementations.Library ExcludeItemTypes = excludeItemTypes.ToArray(), IncludeItemTypes = includeItemTypes.ToArray(), Limit = query.Limit, - IncludeItemsByName = true - + IncludeItemsByName = true, + IsVirtualItem = false }); // Add search hints based on item name - hints.AddRange(mediaItems.Where(IncludeInSearch).Select(item => + hints.AddRange(mediaItems.Select(item => { var index = GetIndex(item.Name, searchTerm, terms); @@ -187,20 +187,6 @@ namespace MediaBrowser.Server.Implementations.Library return Task.FromResult(returnValue); } - private bool IncludeInSearch(BaseItem item) - { - var episode = item as Episode; - - if (episode != null) - { - if (episode.IsMissingEpisode) - { - return false; - } - } - return true; - } - /// /// Gets the index. /// diff --git a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs index cf8e2fe36c..8006e2b08d 100644 --- a/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs +++ b/MediaBrowser.Server.Implementations/Persistence/SqliteItemRepository.cs @@ -3095,6 +3095,17 @@ namespace MediaBrowser.Server.Implementations.Persistence whereClauses.Add("LocationType<>'Virtual'"); } } + if (query.IsSpecialSeason.HasValue) + { + if (query.IsSpecialSeason.Value) + { + whereClauses.Add("IndexNumber = 0"); + } + else + { + whereClauses.Add("IndexNumber <> 0"); + } + } if (query.IsUnaired.HasValue) { if (query.IsUnaired.Value) diff --git a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs index 8a04f29a2c..237d49fdae 100644 --- a/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs +++ b/MediaBrowser.Server.Implementations/ServerApplicationPaths.cs @@ -88,6 +88,14 @@ namespace MediaBrowser.Server.Implementations } } + public string ArtistsPath + { + get + { + return Path.Combine(ItemsByNamePath, "artists"); + } + } + /// /// Gets the path to the Genre directory /// diff --git a/MediaBrowser.Server.Implementations/Session/SessionManager.cs b/MediaBrowser.Server.Implementations/Session/SessionManager.cs index 84aab5e1f8..f495e557a3 100644 --- a/MediaBrowser.Server.Implementations/Session/SessionManager.cs +++ b/MediaBrowser.Server.Implementations/Session/SessionManager.cs @@ -1001,7 +1001,8 @@ namespace MediaBrowser.Server.Implementations.Session var series = episode.Series; if (series != null) { - var episodes = series.GetEpisodes(user, false, false) + var episodes = series.GetEpisodes(user) + .Where(i => !i.IsVirtualItem) .SkipWhile(i => i.Id != episode.Id) .ToList(); -- cgit v1.2.3