diff options
Diffstat (limited to 'MediaBrowser.Controller')
10 files changed, 103 insertions, 48 deletions
diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index cbbb9a89a3..984374a499 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -281,6 +281,20 @@ namespace MediaBrowser.Controller.Entities } } + public Task UpdateIsOffline(bool newValue) + { + var item = this; + + if (item.IsOffline != newValue) + { + item.IsOffline = newValue; + // this is creating too many repeated db updates + //return item.UpdateToRepository(ItemUpdateType.None, CancellationToken.None); + } + + return Task.FromResult(true); + } + /// <summary> /// Gets or sets the type of the location. /// </summary> @@ -290,10 +304,10 @@ namespace MediaBrowser.Controller.Entities { get { - if (IsOffline) - { - return LocationType.Offline; - } + //if (IsOffline) + //{ + // return LocationType.Offline; + //} if (string.IsNullOrWhiteSpace(Path)) { diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index e120f2e23d..597ecf973a 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -106,6 +106,7 @@ namespace MediaBrowser.Controller.Entities { LibraryOptions[path] = options; + options.SchemaVersion = 1; XmlSerializer.SerializeToFile(options, GetLibraryOptionsPath(path)); } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index b5c76c0ebc..bf47ada0dc 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -375,7 +375,7 @@ namespace MediaBrowser.Controller.Entities if (currentChildren.TryGetValue(child.Id, out currentChild) && IsValidFromResolver(currentChild, child)) { - await UpdateIsOffline(currentChild, false).ConfigureAwait(false); + await currentChild.UpdateIsOffline(false).ConfigureAwait(false); validChildren.Add(currentChild); continue; @@ -404,7 +404,7 @@ namespace MediaBrowser.Controller.Entities else if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path)) { - await UpdateIsOffline(item, true).ConfigureAwait(false); + await item.UpdateIsOffline(true).ConfigureAwait(false); } else { @@ -461,17 +461,6 @@ namespace MediaBrowser.Controller.Entities progress.Report(100); } - private Task UpdateIsOffline(BaseItem item, bool newValue) - { - if (item.IsOffline != newValue) - { - item.IsOffline = newValue; - return item.UpdateToRepository(ItemUpdateType.None, CancellationToken.None); - } - - return Task.FromResult(true); - } - private async Task RefreshMetadataRecursive(MetadataRefreshOptions refreshOptions, bool recursive, IProgress<double> progress, CancellationToken cancellationToken) { var children = ActualChildren.ToList(); @@ -902,16 +891,16 @@ namespace MediaBrowser.Controller.Entities { if (query.ItemIds.Length > 0) { - var specificItems = query.ItemIds.Select(LibraryManager.GetItemById).Where(i => i != null).ToList(); + var result = LibraryManager.GetItemsResult(query); if (query.SortBy.Length == 0) { var ids = query.ItemIds.ToList(); // Try to preserve order - specificItems = specificItems.OrderBy(i => ids.IndexOf(i.Id.ToString("N"))).ToList(); + result.Items = result.Items.OrderBy(i => ids.IndexOf(i.Id.ToString("N"))).ToArray(); } - return Task.FromResult(PostFilterAndSort(specificItems, query, true, true)); + return Task.FromResult(result); } return GetItemsInternal(query); diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 726390f65e..1a02043d6f 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -135,7 +135,11 @@ namespace MediaBrowser.Controller.Entities.TV [IgnoreDataMember] public Series Series { - get { return FindParent<Series>(); } + get + { + var seriesId = SeriesId ?? FindSeriesId();
+ return seriesId.HasValue ? (LibraryManager.GetItemById(seriesId.Value) as Series) : null; + } } [IgnoreDataMember] @@ -143,24 +147,8 @@ namespace MediaBrowser.Controller.Entities.TV { get { - var season = FindParent<Season>(); - - // Episodes directly in series folder - if (season == null) - { - var series = Series; - - if (series != null && ParentIndexNumber.HasValue) - { - var findNumber = ParentIndexNumber.Value; - - season = series.Children - .OfType<Season>() - .FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == findNumber); - } - } - - return season; + var seasonId = SeasonId ?? FindSeasonId();
+ return seasonId.HasValue ? (LibraryManager.GetItemById(seasonId.Value) as Season) : null; } } @@ -193,7 +181,23 @@ namespace MediaBrowser.Controller.Entities.TV public Guid? FindSeasonId()
{
- var season = Season;
+ var season = FindParent<Season>();
+
+ // Episodes directly in series folder
+ if (season == null)
+ {
+ var series = Series;
+
+ if (series != null && ParentIndexNumber.HasValue)
+ {
+ var findNumber = ParentIndexNumber.Value;
+
+ season = series.Children
+ .OfType<Season>()
+ .FirstOrDefault(i => i.IndexNumber.HasValue && i.IndexNumber.Value == findNumber);
+ }
+ }
+
return season == null ? (Guid?)null : season.Id;
} @@ -263,7 +267,7 @@ namespace MediaBrowser.Controller.Entities.TV public Guid? FindSeriesId()
{
- var series = Series;
+ var series = FindParent<Series>(); return series == null ? (Guid?)null : series.Id;
} diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index 842b2fd602..65b7c9955b 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -99,7 +99,11 @@ namespace MediaBrowser.Controller.Entities.TV [IgnoreDataMember] public Series Series { - get { return FindParent<Series>(); } + get + { + var seriesId = SeriesId ?? FindSeriesId(); + return seriesId.HasValue ? (LibraryManager.GetItemById(seriesId.Value) as Series) : null; + } } [IgnoreDataMember] @@ -241,7 +245,7 @@ namespace MediaBrowser.Controller.Entities.TV public Guid? FindSeriesId() { - var series = Series; + var series = FindParent<Series>(); return series == null ? (Guid?)null : series.Id; } diff --git a/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs b/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs index daa670d836..9a5b96a241 100644 --- a/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs +++ b/MediaBrowser.Controller/FileOrganization/IFileOrganizationService.cs @@ -1,5 +1,7 @@ -using MediaBrowser.Model.FileOrganization; +using MediaBrowser.Model.Events; +using MediaBrowser.Model.FileOrganization; using MediaBrowser.Model.Querying; +using System; using System.Threading; using System.Threading.Tasks; @@ -7,6 +9,11 @@ namespace MediaBrowser.Controller.FileOrganization { public interface IFileOrganizationService { + event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemAdded; + event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemUpdated; + event EventHandler<GenericEventArgs<FileOrganizationResult>> ItemRemoved; + event EventHandler LogReset; + /// <summary> /// Processes the new files. /// </summary> @@ -81,5 +88,20 @@ namespace MediaBrowser.Controller.FileOrganization /// <param name="ItemName">Item name.</param> /// <param name="matchString">The match string to delete.</param> void DeleteSmartMatchEntry(string ItemName, string matchString); + + /// <summary> + /// Attempts to add a an item to the list of currently processed items. + /// </summary> + /// <param name="result">The result item.</param> + /// <param name="fullClientRefresh">Passing true will notify the client to reload all items, otherwise only a single item will be refreshed.</param> + /// <returns>True if the item was added, False if the item is already contained in the list.</returns> + bool AddToInProgressList(FileOrganizationResult result, bool fullClientRefresh); + + /// <summary> + /// Removes an item from the list of currently processed items. + /// </summary> + /// <param name="result">The result item.</param> + /// <returns>True if the item was removed, False if the item was not contained in the list.</returns> + bool RemoveFromInprogressList(FileOrganizationResult result); } } diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 1fef8bead7..7fdbf020ce 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -134,5 +134,6 @@ namespace MediaBrowser.Controller.MediaEncoding Task UpdateEncoderPath(string path, string pathType); bool SupportsEncoder(string encoder); + bool IsDefaultEncoderPath { get; } } } diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs index 66a9fa60b8..96a3753e19 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs @@ -36,8 +36,13 @@ namespace MediaBrowser.Controller.MediaEncoding return new[] {videoPath}; } - public static List<string> GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, IEnumerable<string> filenames) + private static List<string> GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, List<string> filenames) { + if (filenames.Count == 0) + { + return new List<string>(); + } + var allFiles = fileSystem .GetFilePaths(rootPath, true) .ToList(); diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index a783910e34..c0912708c3 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -724,6 +724,15 @@ namespace MediaBrowser.Controller.Providers } break; } + case "TvMazeId": + { + var id = reader.ReadElementContentAsString(); + if (!string.IsNullOrWhiteSpace(id)) + { + item.SetProviderId(MetadataProviders.TvMaze, id); + } + break; + } case "AudioDbArtistId": { var id = reader.ReadElementContentAsString(); diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 6659d15530..3871952450 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -172,15 +172,21 @@ namespace MediaBrowser.Controller.Session Task SendPlaystateCommand(string controllingSessionId, string sessionId, PlaystateRequest command, CancellationToken cancellationToken); /// <summary> - /// Sends the message to user sessions. + /// Sends the message to admin sessions. /// </summary> /// <typeparam name="T"></typeparam> - /// <param name="userId">The user identifier.</param> /// <param name="name">The name.</param> /// <param name="data">The data.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SendMessageToUserSessions<T>(string userId, string name, T data, CancellationToken cancellationToken); + Task SendMessageToAdminSessions<T>(string name, T data, CancellationToken cancellationToken); + + /// <summary> + /// Sends the message to user sessions. + /// </summary> + /// <typeparam name="T"></typeparam> + /// <returns>Task.</returns> + Task SendMessageToUserSessions<T>(List<string> userIds, string name, T data, CancellationToken cancellationToken); /// <summary> /// Sends the message to user device sessions. |
