diff options
Diffstat (limited to 'MediaBrowser.Controller')
120 files changed, 1394 insertions, 1804 deletions
diff --git a/MediaBrowser.Controller/Channels/Channel.cs b/MediaBrowser.Controller/Channels/Channel.cs index c6e750a0c..54faa1443 100644 --- a/MediaBrowser.Controller/Channels/Channel.cs +++ b/MediaBrowser.Controller/Channels/Channel.cs @@ -58,8 +58,7 @@ namespace MediaBrowser.Controller.Channels Limit = query.Limit, StartIndex = query.StartIndex, UserId = query.User.Id.ToString("N"), - SortBy = query.SortBy, - SortOrder = query.SortOrder + OrderBy = query.OrderBy }, new SimpleProgress<double>(), CancellationToken.None).Result; } diff --git a/MediaBrowser.Controller/Channels/IChannelManager.cs b/MediaBrowser.Controller/Channels/IChannelManager.cs index 824bdf8ff..46e55a21c 100644 --- a/MediaBrowser.Controller/Channels/IChannelManager.cs +++ b/MediaBrowser.Controller/Channels/IChannelManager.cs @@ -30,7 +30,7 @@ namespace MediaBrowser.Controller.Channels /// Gets all channel features. /// </summary> /// <returns>IEnumerable{ChannelFeatures}.</returns> - IEnumerable<ChannelFeatures> GetAllChannelFeatures(); + ChannelFeatures[] GetAllChannelFeatures(); /// <summary> /// Gets the channel. diff --git a/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs b/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs index 7d80d7e12..976808aad 100644 --- a/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs +++ b/MediaBrowser.Controller/Channels/InternalChannelFeatures.cs @@ -58,13 +58,4 @@ namespace MediaBrowser.Controller.Channels DefaultSortFields = new List<ChannelItemSortField>(); } } - - public class ChannelDownloadException : Exception - { - public ChannelDownloadException(string message) - : base(message) - { - - } - } } diff --git a/MediaBrowser.Controller/Chapters/IChapterManager.cs b/MediaBrowser.Controller/Chapters/IChapterManager.cs index 05517ebcd..d1c190ab5 100644 --- a/MediaBrowser.Controller/Chapters/IChapterManager.cs +++ b/MediaBrowser.Controller/Chapters/IChapterManager.cs @@ -1,7 +1,5 @@ using System.Collections.Generic; -using System.Threading; using System.Threading.Tasks; -using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Chapters @@ -16,15 +14,11 @@ namespace MediaBrowser.Controller.Chapters /// </summary> /// <param name="itemId">The item identifier.</param> /// <returns>List{ChapterInfo}.</returns> - IEnumerable<ChapterInfo> GetChapters(string itemId); + List<ChapterInfo> GetChapters(string itemId); /// <summary> /// Saves the chapters. /// </summary> - /// <param name="itemId">The item identifier.</param> - /// <param name="chapters">The chapters.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task SaveChapters(string itemId, List<ChapterInfo> chapters, CancellationToken cancellationToken); + void SaveChapters(string itemId, List<ChapterInfo> chapters); } } diff --git a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs index 4a2d39066..7a387e319 100644 --- a/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs +++ b/MediaBrowser.Controller/Collections/CollectionCreationOptions.cs @@ -14,14 +14,14 @@ namespace MediaBrowser.Controller.Collections public Dictionary<string, string> ProviderIds { get; set; } - public List<Guid> ItemIdList { get; set; } - public List<Guid> UserIds { get; set; } + public string[] ItemIdList { get; set; } + public string[] UserIds { get; set; } public CollectionCreationOptions() { ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - ItemIdList = new List<Guid>(); - UserIds = new List<Guid>(); + ItemIdList = new string[] { }; + UserIds = new string[] { }; } } } diff --git a/MediaBrowser.Controller/Collections/ICollectionManager.cs b/MediaBrowser.Controller/Collections/ICollectionManager.cs index 89e505579..d89843cc0 100644 --- a/MediaBrowser.Controller/Collections/ICollectionManager.cs +++ b/MediaBrowser.Controller/Collections/ICollectionManager.cs @@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Collections /// <param name="collectionId">The collection identifier.</param> /// <param name="itemIds">The item ids.</param> /// <returns>Task.</returns> - Task AddToCollection(Guid collectionId, IEnumerable<Guid> itemIds); + Task AddToCollection(Guid collectionId, IEnumerable<string> itemIds); /// <summary> /// Removes from collection. @@ -44,6 +44,9 @@ namespace MediaBrowser.Controller.Collections /// <param name="collectionId">The collection identifier.</param> /// <param name="itemIds">The item ids.</param> /// <returns>Task.</returns> + Task RemoveFromCollection(Guid collectionId, IEnumerable<string> itemIds); + + Task AddToCollection(Guid collectionId, IEnumerable<Guid> itemIds); Task RemoveFromCollection(Guid collectionId, IEnumerable<Guid> itemIds); /// <summary> diff --git a/MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs b/MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs index 160a788f1..38d2611f0 100644 --- a/MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs +++ b/MediaBrowser.Controller/Collections/ManualCollectionsFolder.cs @@ -8,7 +8,6 @@ namespace MediaBrowser.Controller.Collections public ManualCollectionsFolder() { Name = "Collections"; - DisplayMediaType = "CollectionFolder"; } public override bool IsHidden diff --git a/MediaBrowser.Controller/Drawing/IImageEncoder.cs b/MediaBrowser.Controller/Drawing/IImageEncoder.cs index 131d0bd9e..757448eb2 100644 --- a/MediaBrowser.Controller/Drawing/IImageEncoder.cs +++ b/MediaBrowser.Controller/Drawing/IImageEncoder.cs @@ -3,7 +3,7 @@ using MediaBrowser.Model.Drawing; namespace MediaBrowser.Controller.Drawing { - public interface IImageEncoder : IDisposable + public interface IImageEncoder { /// <summary> /// Gets the supported input formats. diff --git a/MediaBrowser.Controller/Drawing/IImageProcessor.cs b/MediaBrowser.Controller/Drawing/IImageProcessor.cs index 2832462a8..113f823f5 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Drawing /// Gets the image enhancers. /// </summary> /// <value>The image enhancers.</value> - IEnumerable<IImageEnhancer> ImageEnhancers { get; } + IImageEnhancer[] ImageEnhancers { get; } /// <summary> /// Gets the size of the image. @@ -54,7 +54,7 @@ namespace MediaBrowser.Controller.Drawing /// <param name="item">The item.</param> /// <param name="imageType">Type of the image.</param> /// <returns>IEnumerable{IImageEnhancer}.</returns> - IEnumerable<IImageEnhancer> GetSupportedEnhancers(IHasImages item, ImageType imageType); + List<IImageEnhancer> GetSupportedEnhancers(IHasMetadata item, ImageType imageType); /// <summary> /// Gets the image cache tag. @@ -62,7 +62,7 @@ namespace MediaBrowser.Controller.Drawing /// <param name="item">The item.</param> /// <param name="image">The image.</param> /// <returns>Guid.</returns> - string GetImageCacheTag(IHasImages item, ItemImageInfo image); + string GetImageCacheTag(IHasMetadata item, ItemImageInfo image); /// <summary> /// Gets the image cache tag. @@ -71,7 +71,7 @@ namespace MediaBrowser.Controller.Drawing /// <param name="image">The image.</param> /// <param name="imageEnhancers">The image enhancers.</param> /// <returns>Guid.</returns> - string GetImageCacheTag(IHasImages item, ItemImageInfo image, List<IImageEnhancer> imageEnhancers); + string GetImageCacheTag(IHasMetadata item, ItemImageInfo image, List<IImageEnhancer> imageEnhancers); /// <summary> /// Processes the image. @@ -95,7 +95,7 @@ namespace MediaBrowser.Controller.Drawing /// <param name="imageType">Type of the image.</param> /// <param name="imageIndex">Index of the image.</param> /// <returns>Task{System.String}.</returns> - Task<string> GetEnhancedImage(IHasImages item, ImageType imageType, int imageIndex); + Task<string> GetEnhancedImage(IHasMetadata item, ImageType imageType, int imageIndex); /// <summary> /// Gets the supported image output formats. diff --git a/MediaBrowser.Controller/Drawing/ImageHelper.cs b/MediaBrowser.Controller/Drawing/ImageHelper.cs index 54f2ff987..9452446a1 100644 --- a/MediaBrowser.Controller/Drawing/ImageHelper.cs +++ b/MediaBrowser.Controller/Drawing/ImageHelper.cs @@ -48,7 +48,7 @@ namespace MediaBrowser.Controller.Drawing return new ImageSize(widthValue, height); } - private static double GetEstimatedAspectRatio(ImageType type, IHasImages item) + private static double GetEstimatedAspectRatio(ImageType type, IHasMetadata item) { switch (type) { diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs index cfb3a97ee..fac21c744 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs @@ -12,7 +12,7 @@ namespace MediaBrowser.Controller.Drawing { public string ItemId { get; set; } public string ItemType { get; set; } - public IHasImages Item { get; set; } + public IHasMetadata Item { get; set; } public ItemImageInfo Image { get; set; } diff --git a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs index c5601c49f..5dfa94e1e 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessorExtensions.cs @@ -5,12 +5,12 @@ namespace MediaBrowser.Controller.Drawing { public static class ImageProcessorExtensions { - public static string GetImageCacheTag(this IImageProcessor processor, IHasImages item, ImageType imageType) + public static string GetImageCacheTag(this IImageProcessor processor, IHasMetadata item, ImageType imageType) { return processor.GetImageCacheTag(item, imageType, 0); } - public static string GetImageCacheTag(this IImageProcessor processor, IHasImages item, ImageType imageType, int imageIndex) + public static string GetImageCacheTag(this IImageProcessor processor, IHasMetadata item, ImageType imageType, int imageIndex) { var imageInfo = item.GetImageInfo(imageType, imageIndex); diff --git a/MediaBrowser.Controller/Drawing/ImageStream.cs b/MediaBrowser.Controller/Drawing/ImageStream.cs index 353abaca3..b5e14eb6c 100644 --- a/MediaBrowser.Controller/Drawing/ImageStream.cs +++ b/MediaBrowser.Controller/Drawing/ImageStream.cs @@ -23,6 +23,7 @@ namespace MediaBrowser.Controller.Drawing { Stream.Dispose(); } + GC.SuppressFinalize(this); } } } diff --git a/MediaBrowser.Controller/Dto/DtoOptions.cs b/MediaBrowser.Controller/Dto/DtoOptions.cs index 098ba558f..f05ae4e71 100644 --- a/MediaBrowser.Controller/Dto/DtoOptions.cs +++ b/MediaBrowser.Controller/Dto/DtoOptions.cs @@ -14,8 +14,8 @@ namespace MediaBrowser.Controller.Dto ItemFields.RefreshState }; - public List<ItemFields> Fields { get; set; } - public List<ImageType> ImageTypes { get; set; } + public ItemFields[] Fields { get; set; } + public ImageType[] ImageTypes { get; set; } public int ImageTypeLimit { get; set; } public bool EnableImages { get; set; } public bool AddProgramRecordingInfo { get; set; } @@ -28,6 +28,15 @@ namespace MediaBrowser.Controller.Dto { } + private static readonly ImageType[] AllImageTypes = Enum.GetNames(typeof(ImageType)) + .Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true)) + .ToArray(); + + private static readonly ItemFields[] AllItemFields = Enum.GetNames(typeof(ItemFields)) + .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) + .Except(DefaultExcludedFields) + .ToArray(); + public DtoOptions(bool allFields) { ImageTypeLimit = int.MaxValue; @@ -37,19 +46,14 @@ namespace MediaBrowser.Controller.Dto if (allFields) { - Fields = Enum.GetNames(typeof(ItemFields)) - .Select(i => (ItemFields)Enum.Parse(typeof(ItemFields), i, true)) - .Except(DefaultExcludedFields) - .ToList(); + Fields = AllItemFields; } else { - Fields = new List<ItemFields>(); + Fields = new ItemFields[] { }; } - ImageTypes = Enum.GetNames(typeof(ImageType)) - .Select(i => (ImageType)Enum.Parse(typeof(ImageType), i, true)) - .ToList(); + ImageTypes = AllImageTypes; } public int GetImageLimit(ImageType type) diff --git a/MediaBrowser.Controller/Dto/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index a6f807ce9..c0217330d 100644 --- a/MediaBrowser.Controller/Dto/IDtoService.cs +++ b/MediaBrowser.Controller/Dto/IDtoService.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; using System.Collections.Generic; -using System.Threading.Tasks; using MediaBrowser.Controller.Sync; namespace MediaBrowser.Controller.Dto @@ -24,14 +23,14 @@ namespace MediaBrowser.Controller.Dto /// </summary> /// <param name="dto">The dto.</param> /// <param name="item">The item.</param> - void AttachPrimaryImageAspectRatio(IItemDto dto, IHasImages item); + void AttachPrimaryImageAspectRatio(IItemDto dto, IHasMetadata item); /// <summary> /// Gets the primary image aspect ratio. /// </summary> /// <param name="item">The item.</param> /// <returns>System.Nullable<System.Double>.</returns> - double? GetPrimaryImageAspectRatio(IHasImages item); + double? GetPrimaryImageAspectRatio(IHasMetadata item); /// <summary> /// Gets the base item dto. @@ -40,8 +39,7 @@ namespace MediaBrowser.Controller.Dto /// <param name="fields">The fields.</param> /// <param name="user">The user.</param> /// <param name="owner">The owner.</param> - /// <returns>Task{BaseItemDto}.</returns> - BaseItemDto GetBaseItemDto(BaseItem item, List<ItemFields> fields, User user = null, BaseItem owner = null); + BaseItemDto GetBaseItemDto(BaseItem item, ItemFields[] fields, User user = null, BaseItem owner = null); /// <summary> /// Gets the base item dto. @@ -60,10 +58,10 @@ namespace MediaBrowser.Controller.Dto /// <param name="options">The options.</param> /// <param name="user">The user.</param> /// <param name="owner">The owner.</param> - /// <returns>IEnumerable<BaseItemDto>.</returns> - Task<List<BaseItemDto>> GetBaseItemDtos(IEnumerable<BaseItem> items, DtoOptions options, User user = null, - BaseItem owner = null); - + BaseItemDto[] GetBaseItemDtos(BaseItem[] items, DtoOptions options, User user = null, BaseItem owner = null); + + BaseItemDto[] GetBaseItemDtos(List<BaseItem> items, DtoOptions options, User user = null, BaseItem owner = null); + /// <summary> /// Gets the chapter information dto. /// </summary> diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index e8ebbdb70..2105ef907 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -20,19 +20,7 @@ namespace MediaBrowser.Controller.Entities { public AggregateFolder() { - PhysicalLocationsList = new List<string>(); - } - - /// <summary> - /// We don't support manual shortcuts - /// </summary> - [IgnoreDataMember] - protected override bool SupportsShortcutChildren - { - get - { - return false; - } + PhysicalLocationsList = EmptyStringArray; } [IgnoreDataMember] @@ -70,7 +58,7 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public override IEnumerable<string> PhysicalLocations + public override string[] PhysicalLocations { get { @@ -78,23 +66,23 @@ namespace MediaBrowser.Controller.Entities } } - public List<string> PhysicalLocationsList { get; set; } + public string[] PhysicalLocationsList { get; set; } - protected override IEnumerable<FileSystemMetadata> GetFileSystemChildren(IDirectoryService directoryService) + protected override FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService) { return CreateResolveArgs(directoryService, true).FileSystemChildren; } - private List<Guid> _childrenIds = null; + private Guid[] _childrenIds = null; private readonly object _childIdsLock = new object(); protected override List<BaseItem> LoadChildren() { lock (_childIdsLock) { - if (_childrenIds == null || _childrenIds.Count == 0) + if (_childrenIds == null || _childrenIds.Length == 0) { - var list = base.LoadChildren().ToList(); - _childrenIds = list.Select(i => i.Id).ToList(); + var list = base.LoadChildren(); + _childrenIds = list.Select(i => i.Id).ToArray(); return list; } @@ -117,9 +105,9 @@ namespace MediaBrowser.Controller.Entities if (!changed) { - var locations = PhysicalLocations.ToList(); + var locations = PhysicalLocations; - var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations.ToList(); + var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations; if (!locations.SequenceEqual(newLocations)) { @@ -160,24 +148,22 @@ namespace MediaBrowser.Controller.Entities // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = LibraryManager.NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = LibraryManager.NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); if (setPhysicalLocations) { - PhysicalLocationsList = args.PhysicalLocations.ToList(); + PhysicalLocationsList = args.PhysicalLocations; } return args; @@ -226,7 +212,14 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("id"); } - return _virtualChildren.FirstOrDefault(i => i.Id == id); + foreach (var child in _virtualChildren) + { + if (child.Id == id) + { + return child; + } + } + return null; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 873ac3104..3ebf4da00 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -9,6 +9,7 @@ using System.Globalization; using System.Linq; using System.Threading; using MediaBrowser.Common.Extensions; +using MediaBrowser.Controller.Persistence; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities.Audio @@ -27,9 +28,11 @@ namespace MediaBrowser.Controller.Entities.Audio /// Gets or sets the artist. /// </summary> /// <value>The artist.</value> - public List<string> Artists { get; set; } + [IgnoreDataMember] + public string[] Artists { get; set; } - public List<string> AlbumArtists { get; set; } + [IgnoreDataMember] + public string[] AlbumArtists { get; set; } [IgnoreDataMember] public override bool EnableRefreshOnDateModifiedChange @@ -39,8 +42,8 @@ namespace MediaBrowser.Controller.Entities.Audio public Audio() { - Artists = new List<string>(); - AlbumArtists = new List<string>(); + Artists = EmptyStringArray; + AlbumArtists = EmptyStringArray; } public override double? GetDefaultPrimaryImageAspectRatio() @@ -95,13 +98,23 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - public List<string> AllArtists + public string[] AllArtists { get { - var list = AlbumArtists.ToList(); + var list = new string[AlbumArtists.Length + Artists.Length]; - list.AddRange(Artists); + var index = 0; + foreach (var artist in AlbumArtists) + { + list[index] = artist; + index++; + } + foreach (var artist in Artists) + { + list[index] = artist; + index++; + } return list; @@ -157,7 +170,7 @@ namespace MediaBrowser.Controller.Entities.Audio songKey = Album + "-" + songKey; } - var albumArtist = AlbumArtists.FirstOrDefault(); + var albumArtist = AlbumArtists.Length == 0 ? null : AlbumArtists[0]; if (!string.IsNullOrWhiteSpace(albumArtist)) { songKey = albumArtist + "-" + songKey; @@ -193,6 +206,23 @@ namespace MediaBrowser.Controller.Entities.Audio return base.GetBlockUnratedType(); } + public List<MediaStream> GetMediaStreams() + { + return MediaSourceManager.GetMediaStreams(new MediaStreamQuery + { + ItemId = Id + }); + } + + public List<MediaStream> GetMediaStreams(MediaStreamType type) + { + return MediaSourceManager.GetMediaStreams(new MediaStreamQuery + { + ItemId = Id, + Type = type + }); + } + public SongInfo GetLookupInfo() { var info = GetItemLookupInfo<SongInfo>(); @@ -204,7 +234,7 @@ namespace MediaBrowser.Controller.Entities.Audio return info; } - public virtual IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public virtual List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { if (SourceType == SourceType.Channel) { @@ -248,7 +278,7 @@ namespace MediaBrowser.Controller.Entities.Audio { Id = i.Id.ToString("N"), Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, - MediaStreams = MediaSourceManager.GetMediaStreams(i.Id).ToList(), + MediaStreams = MediaSourceManager.GetMediaStreams(i.Id), Name = i.Name, Path = enablePathSubstituion ? GetMappedPath(i, i.Path, locationType) : i.Path, RunTimeTicks = i.RunTimeTicks, diff --git a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs index a7c914664..b2dedada4 100644 --- a/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/IHasAlbumArtist.cs @@ -1,25 +1,15 @@ -using MediaBrowser.Controller.Library; -using System.Collections.Generic; - + namespace MediaBrowser.Controller.Entities.Audio { public interface IHasAlbumArtist { - List<string> AlbumArtists { get; set; } + string[] AlbumArtists { get; set; } } public interface IHasArtist { - List<string> AllArtists { get; } - - List<string> Artists { get; set; } - } + string[] AllArtists { get; } - public static class HasArtistExtensions - { - public static bool HasAnyArtist(this IHasArtist hasArtist, string artist) - { - return NameExtensions.EqualsAny(hasArtist.AllArtists, artist); - } + string[] Artists { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 516ab5053..7af8161ca 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -10,7 +10,6 @@ using System.Threading; using System.Threading.Tasks; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Library; -using MediaBrowser.Model.Dto; namespace MediaBrowser.Controller.Entities.Audio { @@ -19,13 +18,13 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> public class MusicAlbum : Folder, IHasAlbumArtist, IHasArtist, IHasMusicGenres, IHasLookupInfo<AlbumInfo>, IMetadataContainer { - public List<string> AlbumArtists { get; set; } - public List<string> Artists { get; set; } + public string[] AlbumArtists { get; set; } + public string[] Artists { get; set; } public MusicAlbum() { - Artists = new List<string>(); - AlbumArtists = new List<string>(); + Artists = EmptyStringArray; + AlbumArtists = EmptyStringArray; } [IgnoreDataMember] @@ -48,17 +47,22 @@ namespace MediaBrowser.Controller.Entities.Audio public MusicArtist GetMusicArtist(DtoOptions options) { - var artist = GetParents().OfType<MusicArtist>().FirstOrDefault(); - - if (artist == null) + var parents = GetParents(); + foreach (var parent in parents) { - var name = AlbumArtist; - if (!string.IsNullOrWhiteSpace(name)) + var artist = parent as MusicArtist; + if (artist != null) { - artist = LibraryManager.GetArtist(name, options); + return artist; } } - return artist; + + var name = AlbumArtist; + if (!string.IsNullOrWhiteSpace(name)) + { + return LibraryManager.GetArtist(name, options); + } + return null; } [IgnoreDataMember] @@ -80,23 +84,32 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] - public List<string> AllArtists + public string[] AllArtists { get { - var list = AlbumArtists.ToList(); + var list = new string[AlbumArtists.Length + Artists.Length]; - list.AddRange(Artists); + var index = 0; + foreach (var artist in AlbumArtists) + { + list[index] = artist; + index++; + } + foreach (var artist in Artists) + { + list[index] = artist; + index++; + } return list; - } } [IgnoreDataMember] public string AlbumArtist { - get { return AlbumArtists.FirstOrDefault(); } + get { return AlbumArtists.Length == 0 ? null : AlbumArtists[0]; } } [IgnoreDataMember] @@ -110,11 +123,11 @@ namespace MediaBrowser.Controller.Entities.Audio /// </summary> /// <value>The tracks.</value> [IgnoreDataMember] - public IEnumerable<Audio> Tracks + public IEnumerable<BaseItem> Tracks { get { - return GetRecursiveChildren(i => i is Audio).Cast<Audio>(); + return GetRecursiveChildren(i => i is Audio); } } @@ -200,7 +213,7 @@ namespace MediaBrowser.Controller.Entities.Audio public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress<double> progress, CancellationToken cancellationToken) { - var items = GetRecursiveChildren().ToList(); + var items = GetRecursiveChildren(); var totalItems = items.Count; var numComplete = 0; @@ -239,27 +252,22 @@ namespace MediaBrowser.Controller.Entities.Audio private async Task RefreshArtists(MetadataRefreshOptions refreshOptions, CancellationToken cancellationToken) { - var artists = AllArtists.Select(i => + var all = AllArtists; + foreach (var i in all) { // This should not be necessary but we're seeing some cases of it if (string.IsNullOrWhiteSpace(i)) { - return null; + continue; } var artist = LibraryManager.GetArtist(i); if (!artist.IsAccessedByName) { - return null; + continue; } - return artist; - - }).Where(i => i != null).ToList(); - - foreach (var artist in artists) - { await artist.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); } } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 7a37b2e02..19fe68e25 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -212,20 +212,21 @@ namespace MediaBrowser.Controller.Entities.Audio public async Task RefreshAllMetadata(MetadataRefreshOptions refreshOptions, IProgress<double> progress, CancellationToken cancellationToken) { - var items = GetRecursiveChildren().ToList(); + var items = GetRecursiveChildren(); - var songs = items.OfType<Audio>().ToList(); - - var others = items.Except(songs).ToList(); - - var totalItems = songs.Count + others.Count; + var totalItems = items.Count; var numComplete = 0; var childUpdateType = ItemUpdateType.None; // Refresh songs - foreach (var item in songs) + foreach (var item in items) { + if (!(item is Audio)) + { + continue; + } + cancellationToken.ThrowIfCancellationRequested(); var updateType = await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); @@ -248,8 +249,13 @@ namespace MediaBrowser.Controller.Entities.Audio await RefreshMetadata(parentRefreshOptions, cancellationToken).ConfigureAwait(false); // Refresh all non-songs - foreach (var item in others) + foreach (var item in items) { + if (item is Audio) + { + continue; + } + cancellationToken.ThrowIfCancellationRequested(); var updateType = await item.RefreshMetadata(parentRefreshOptions, cancellationToken).ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index d4a85b4d0..02e652048 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 6f8d62c0c..c41d3e0cd 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -25,6 +25,7 @@ using System.Threading.Tasks; using MediaBrowser.Controller.Dto; using MediaBrowser.Controller.Extensions; using MediaBrowser.Controller.IO; +using MediaBrowser.Controller.MediaEncoding; using MediaBrowser.Controller.Sorting; using MediaBrowser.Model.Extensions; using MediaBrowser.Model.Globalization; @@ -39,20 +40,26 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Class BaseItem /// </summary> - public abstract class BaseItem : IHasProviderIds, IHasImages, IHasUserData, IHasMetadata, IHasLookupInfo<ItemLookupInfo> + public abstract class BaseItem : IHasMetadata, IHasLookupInfo<ItemLookupInfo> { + protected static Guid[] EmptyGuidArray = new Guid[] { }; + protected static MetadataFields[] EmptyMetadataFieldsArray = new MetadataFields[] { }; + protected static string[] EmptyStringArray = new string[] { }; + protected static MediaUrl[] EmptyMediaUrlArray = new MediaUrl[] { }; + protected static ItemImageInfo[] EmptyItemImageInfoArray = new ItemImageInfo[] { }; + public static readonly LinkedChild[] EmptyLinkedChildArray = new LinkedChild[] { }; + protected BaseItem() { - ThemeSongIds = new List<Guid>(); - ThemeVideoIds = new List<Guid>(); - Tags = new List<string>(); + ThemeSongIds = EmptyGuidArray; + ThemeVideoIds = EmptyGuidArray; + Tags = EmptyStringArray; Genres = new List<string>(); - Studios = new List<string>(); + Studios = EmptyStringArray; ProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - LockedFields = new List<MetadataFields>(); - ImageInfos = new List<ItemImageInfo>(); - InheritedTags = new List<string>(); - ProductionLocations = new List<string>(); + LockedFields = EmptyMetadataFieldsArray; + ImageInfos = EmptyItemImageInfoArray; + ProductionLocations = EmptyStringArray; } public static readonly char[] SlugReplaceChars = { '?', '/', '&' }; @@ -73,8 +80,10 @@ namespace MediaBrowser.Controller.Entities public static string ThemeSongFilename = "theme"; public static string ThemeVideosFolderName = "backdrops"; - public List<Guid> ThemeSongIds { get; set; } - public List<Guid> ThemeVideoIds { get; set; } + [IgnoreDataMember] + public Guid[] ThemeSongIds { get; set; } + [IgnoreDataMember] + public Guid[] ThemeVideoIds { get; set; } [IgnoreDataMember] public string PreferredMetadataCountryCode { get; set; } @@ -87,7 +96,8 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public string Tagline { get; set; } - public List<ItemImageInfo> ImageInfos { get; set; } + [IgnoreDataMember] + public ItemImageInfo[] ImageInfos { get; set; } [IgnoreDataMember] public bool IsVirtualItem { get; set; } @@ -129,12 +139,6 @@ namespace MediaBrowser.Controller.Entities public bool IsInMixedFolder { get; set; } [IgnoreDataMember] - protected virtual bool SupportsIsInMixedFolderDetection - { - get { return false; } - } - - [IgnoreDataMember] public virtual bool SupportsPlayedStatus { get @@ -152,16 +156,6 @@ namespace MediaBrowser.Controller.Entities } } - public bool DetectIsInMixedFolder() - { - if (SupportsIsInMixedFolderDetection) - { - - } - - return IsInMixedFolder; - } - [IgnoreDataMember] public virtual bool SupportsRemoteImageDownloading { @@ -193,27 +187,14 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public string SlugName - { - get - { - var name = Name; - if (string.IsNullOrWhiteSpace(name)) - { - return string.Empty; - } - - return SlugReplaceChars.Aggregate(name, (current, c) => current.Replace(c, SlugChar)); - } - } - - [IgnoreDataMember] public bool IsUnaired { get { return PremiereDate.HasValue && PremiereDate.Value.ToLocalTime().Date >= DateTime.Now.Date; } } + [IgnoreDataMember] public int? TotalBitrate { get; set; } + [IgnoreDataMember] public ExtraType? ExtraType { get; set; } [IgnoreDataMember] @@ -541,6 +522,7 @@ namespace MediaBrowser.Controller.Entities public static ICollectionManager CollectionManager { get; set; } public static IImageProcessor ImageProcessor { get; set; } public static IMediaSourceManager MediaSourceManager { get; set; } + public static IMediaEncoder MediaEncoder { get; set; } /// <summary> /// Returns a <see cref="System.String" /> that represents this instance. @@ -559,7 +541,7 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <value>The locked fields.</value> [IgnoreDataMember] - public List<MetadataFields> LockedFields { get; set; } + public MetadataFields[] LockedFields { get; set; } /// <summary> /// Gets the type of the media. @@ -575,7 +557,7 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public virtual IEnumerable<string> PhysicalLocations + public virtual string[] PhysicalLocations { get { @@ -667,27 +649,34 @@ namespace MediaBrowser.Controller.Entities } var sortable = Name.Trim().ToLower(); - sortable = ConfigurationManager.Configuration.SortRemoveCharacters.Aggregate(sortable, (current, search) => current.Replace(search.ToLower(), string.Empty)); - sortable = ConfigurationManager.Configuration.SortReplaceCharacters.Aggregate(sortable, (current, search) => current.Replace(search.ToLower(), " ")); + foreach (var removeChar in ConfigurationManager.Configuration.SortRemoveCharacters) + { + sortable = sortable.Replace(removeChar, string.Empty); + } + + foreach (var replaceChar in ConfigurationManager.Configuration.SortReplaceCharacters) + { + sortable = sortable.Replace(replaceChar, " "); + } foreach (var search in ConfigurationManager.Configuration.SortRemoveWords) { - var searchLower = search.ToLower(); // Remove from beginning if a space follows - if (sortable.StartsWith(searchLower + " ")) + if (sortable.StartsWith(search + " ")) { - sortable = sortable.Remove(0, searchLower.Length + 1); + sortable = sortable.Remove(0, search.Length + 1); } // Remove from middle if surrounded by spaces - sortable = sortable.Replace(" " + searchLower + " ", " "); + sortable = sortable.Replace(" " + search + " ", " "); // Remove from end if followed by a space - if (sortable.EndsWith(" " + searchLower)) + if (sortable.EndsWith(" " + search)) { - sortable = sortable.Remove(sortable.Length - (searchLower.Length + 1)); + sortable = sortable.Remove(sortable.Length - (search.Length + 1)); } } + return ModifySortChunks(sortable); } @@ -774,7 +763,15 @@ namespace MediaBrowser.Controller.Entities public T FindParent<T>() where T : Folder { - return GetParents().OfType<T>().FirstOrDefault(); + foreach (var parent in GetParents()) + { + var item = parent as T; + if (item != null) + { + return item; + } + } + return null; } [IgnoreDataMember] @@ -819,13 +816,6 @@ namespace MediaBrowser.Controller.Entities public DateTime? EndDate { get; set; } /// <summary> - /// Gets or sets the display type of the media. - /// </summary> - /// <value>The display type of the media.</value> - [IgnoreDataMember] - public string DisplayMediaType { get; set; } - - /// <summary> /// Gets or sets the official rating. /// </summary> /// <value>The official rating.</value> @@ -835,9 +825,6 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public int InheritedParentalRatingValue { get; set; } - [IgnoreDataMember] - public List<string> InheritedTags { get; set; } - /// <summary> /// Gets or sets the critic rating. /// </summary> @@ -864,7 +851,7 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <value>The studios.</value> [IgnoreDataMember] - public List<string> Studios { get; set; } + public string[] Studios { get; set; } /// <summary> /// Gets or sets the genres. @@ -878,9 +865,10 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <value>The tags.</value> [IgnoreDataMember] - public List<string> Tags { get; set; } + public string[] Tags { get; set; } - public List<string> ProductionLocations { get; set; } + [IgnoreDataMember] + public string[] ProductionLocations { get; set; } /// <summary> /// Gets or sets the home page URL. @@ -989,11 +977,11 @@ namespace MediaBrowser.Controller.Entities /// Loads the theme songs. /// </summary> /// <returns>List{Audio.Audio}.</returns> - private static IEnumerable<Audio.Audio> LoadThemeSongs(List<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService) + private static Audio.Audio[] LoadThemeSongs(List<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService) { var files = fileSystemChildren.Where(i => i.IsDirectory) .Where(i => string.Equals(i.Name, ThemeSongsFolderName, StringComparison.OrdinalIgnoreCase)) - .SelectMany(i => directoryService.GetFiles(i.FullName)) + .SelectMany(i => FileSystem.GetFiles(i.FullName)) .ToList(); // Support plex/xbmc convention @@ -1018,18 +1006,18 @@ namespace MediaBrowser.Controller.Entities return audio; // Sort them so that the list can be easily compared for changes - }).OrderBy(i => i.Path).ToList(); + }).OrderBy(i => i.Path).ToArray(); } /// <summary> /// Loads the video backdrops. /// </summary> /// <returns>List{Video}.</returns> - private static IEnumerable<Video> LoadThemeVideos(IEnumerable<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService) + private static Video[] LoadThemeVideos(IEnumerable<FileSystemMetadata> fileSystemChildren, IDirectoryService directoryService) { var files = fileSystemChildren.Where(i => i.IsDirectory) .Where(i => string.Equals(i.Name, ThemeVideosFolderName, StringComparison.OrdinalIgnoreCase)) - .SelectMany(i => directoryService.GetFiles(i.FullName)); + .SelectMany(i => FileSystem.GetFiles(i.FullName)); return LibraryManager.ResolvePaths(files, directoryService, null, new LibraryOptions()) .OfType<Video>() @@ -1048,7 +1036,7 @@ namespace MediaBrowser.Controller.Entities return item; // Sort them so that the list can be easily compared for changes - }).OrderBy(i => i.Path).ToList(); + }).OrderBy(i => i.Path).ToArray(); } public Task RefreshMetadata(CancellationToken cancellationToken) @@ -1156,7 +1144,7 @@ namespace MediaBrowser.Controller.Entities { if (SupportsThemeMedia) { - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { themeSongsChanged = await RefreshThemeSongs(this, options, fileSystemChildren, cancellationToken).ConfigureAwait(false); @@ -1174,7 +1162,7 @@ namespace MediaBrowser.Controller.Entities return themeSongsChanged || themeVideosChanged || localTrailersChanged; } - protected virtual IEnumerable<FileSystemMetadata> GetFileSystemChildren(IDirectoryService directoryService) + protected virtual FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService) { var path = ContainingFolderPath; @@ -1185,7 +1173,7 @@ namespace MediaBrowser.Controller.Entities { var newItems = LibraryManager.FindTrailers(this, fileSystemChildren, options.DirectoryService).ToList(); - var newItemIds = newItems.Select(i => i.Id).ToList(); + var newItemIds = newItems.Select(i => i.Id).ToArray(); var itemsChanged = !item.LocalTrailerIds.SequenceEqual(newItemIds); @@ -1200,9 +1188,9 @@ namespace MediaBrowser.Controller.Entities private async Task<bool> RefreshThemeVideos(BaseItem item, MetadataRefreshOptions options, IEnumerable<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) { - var newThemeVideos = LoadThemeVideos(fileSystemChildren, options.DirectoryService).ToList(); + var newThemeVideos = LoadThemeVideos(fileSystemChildren, options.DirectoryService); - var newThemeVideoIds = newThemeVideos.Select(i => i.Id).ToList(); + var newThemeVideoIds = newThemeVideos.Select(i => i.Id).ToArray(newThemeVideos.Length); var themeVideosChanged = !item.ThemeVideoIds.SequenceEqual(newThemeVideoIds); @@ -1231,8 +1219,8 @@ namespace MediaBrowser.Controller.Entities /// </summary> private async Task<bool> RefreshThemeSongs(BaseItem item, MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) { - var newThemeSongs = LoadThemeSongs(fileSystemChildren, options.DirectoryService).ToList(); - var newThemeSongIds = newThemeSongs.Select(i => i.Id).ToList(); + var newThemeSongs = LoadThemeSongs(fileSystemChildren, options.DirectoryService); + var newThemeSongIds = newThemeSongs.Select(i => i.Id).ToArray(newThemeSongs.Length); var themeSongsChanged = !item.ThemeSongIds.SequenceEqual(newThemeSongIds); @@ -1260,6 +1248,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the provider ids. /// </summary> /// <value>The provider ids.</value> + [IgnoreDataMember] public Dictionary<string, string> ProviderIds { get; set; } [IgnoreDataMember] @@ -1311,12 +1300,9 @@ namespace MediaBrowser.Controller.Entities { var current = this; - if (!SupportsIsInMixedFolderDetection) + if (current.IsInMixedFolder != newItem.IsInMixedFolder) { - if (current.IsInMixedFolder != newItem.IsInMixedFolder) - { - return false; - } + return false; } return true; @@ -1737,12 +1723,28 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("name"); } - if (!Studios.Contains(name, StringComparer.OrdinalIgnoreCase)) + var current = Studios; + + if (!current.Contains(name, StringComparer.OrdinalIgnoreCase)) { - Studios.Add(name); + if (current.Length == 0) + { + Studios = new[] { name }; + } + else + { + var list = current.ToArray(current.Length + 1); + list[list.Length - 1] = name; + Studios = list; + } } } + public void SetStudios(IEnumerable<string> names) + { + Studios = names.Distinct().ToArray(); + } + /// <summary> /// Adds a genre to the item /// </summary> @@ -1769,7 +1771,7 @@ namespace MediaBrowser.Controller.Entities /// <param name="resetPosition">if set to <c>true</c> [reset position].</param> /// <returns>Task.</returns> /// <exception cref="System.ArgumentNullException"></exception> - public virtual async Task MarkPlayed(User user, + public virtual void MarkPlayed(User user, DateTime? datePlayed, bool resetPosition) { @@ -1797,7 +1799,7 @@ namespace MediaBrowser.Controller.Entities data.LastPlayedDate = datePlayed ?? data.LastPlayedDate ?? DateTime.UtcNow; data.Played = true; - await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false); + UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None); } /// <summary> @@ -1806,7 +1808,7 @@ namespace MediaBrowser.Controller.Entities /// <param name="user">The user.</param> /// <returns>Task.</returns> /// <exception cref="System.ArgumentNullException"></exception> - public virtual async Task MarkUnplayed(User user) + public virtual void MarkUnplayed(User user) { if (user == null) { @@ -1823,7 +1825,7 @@ namespace MediaBrowser.Controller.Entities data.LastPlayedDate = null; data.Played = false; - await UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None).ConfigureAwait(false); + UserDataManager.SaveUserData(user.Id, this, data, UserDataSaveReason.TogglePlayed, CancellationToken.None); } /// <summary> @@ -1862,10 +1864,18 @@ namespace MediaBrowser.Controller.Entities if (existingImage != null) { - ImageInfos.Remove(existingImage); + existingImage.Path = image.Path; + existingImage.DateModified = image.DateModified; + existingImage.IsPlaceholder = image.IsPlaceholder; } - ImageInfos.Add(image); + else + { + var currentCount = ImageInfos.Length; + var newList = ImageInfos.ToArray(currentCount + 1); + newList[currentCount] = image; + ImageInfos = newList; + } } public void SetImagePath(ImageType type, int index, FileSystemMetadata file) @@ -1879,7 +1889,10 @@ namespace MediaBrowser.Controller.Entities if (image == null) { - ImageInfos.Add(GetImageInfo(file, type)); + var currentCount = ImageInfos.Length; + var newList = ImageInfos.ToArray(currentCount + 1); + newList[currentCount] = GetImageInfo(file, type); + ImageInfos = newList; } else { @@ -1920,7 +1933,12 @@ namespace MediaBrowser.Controller.Entities public void RemoveImage(ItemImageInfo image) { - ImageInfos.Remove(image); + RemoveImages(new List<ItemImageInfo> { image }); + } + + public void RemoveImages(List<ItemImageInfo> deletedImages) + { + ImageInfos = ImageInfos.Except(deletedImages).ToArray(); } public virtual Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken) @@ -1937,7 +1955,7 @@ namespace MediaBrowser.Controller.Entities .Where(i => i.IsLocalFile) .Select(i => FileSystem.GetDirectoryName(i.Path)) .Distinct(StringComparer.OrdinalIgnoreCase) - .SelectMany(directoryService.GetFilePaths) + .SelectMany(i => FileSystem.GetFilePaths(i)) .ToList(); var deletedImages = ImageInfos @@ -1946,7 +1964,7 @@ namespace MediaBrowser.Controller.Entities if (deletedImages.Count > 0) { - ImageInfos = ImageInfos.Except(deletedImages).ToList(); + ImageInfos = ImageInfos.Except(deletedImages).ToArray(); } return deletedImages.Count > 0; @@ -2066,10 +2084,25 @@ namespace MediaBrowser.Controller.Entities .Where(i => i.IsLocalFile && !newImagePaths.Contains(i.Path, StringComparer.OrdinalIgnoreCase) && !FileSystem.FileExists(i.Path)) .ToList(); - ImageInfos = ImageInfos.Except(deleted).ToList(); + if (deleted.Count > 0) + { + ImageInfos = ImageInfos.Except(deleted).ToArray(); + } } - ImageInfos.AddRange(newImageList.Select(i => GetImageInfo(i, imageType))); + if (newImageList.Count > 0) + { + var currentCount = ImageInfos.Length; + var newList = ImageInfos.ToArray(currentCount + newImageList.Count); + + foreach (var image in newImageList) + { + newList[currentCount] = GetImageInfo(image, imageType); + currentCount++; + } + + ImageInfos = newList; + } return newImageList.Count > 0; } @@ -2107,10 +2140,10 @@ namespace MediaBrowser.Controller.Entities } var filename = System.IO.Path.GetFileNameWithoutExtension(Path); - var extensions = new[] { ".nfo", ".xml", ".srt" }.ToList(); - extensions.AddRange(SupportedImageExtensionsList); + var extensions = new List<string> { ".nfo", ".xml", ".srt" }; + extensions.AddRange(SupportedImageExtensions); - return FileSystem.GetFiles(FileSystem.GetDirectoryName(Path), extensions.ToArray(), false, false) + return FileSystem.GetFiles(FileSystem.GetDirectoryName(Path), extensions.ToArray(extensions.Count), false, false) .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase)) .ToList(); } @@ -2234,7 +2267,7 @@ namespace MediaBrowser.Controller.Entities return path; } - public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, List<ItemFields> fields) + public virtual void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, ItemFields[] fields) { if (RunTimeTicks.HasValue) { @@ -2270,12 +2303,12 @@ namespace MediaBrowser.Controller.Entities if (!item.Studios.SequenceEqual(ownedItem.Studios, StringComparer.Ordinal)) { newOptions.ForceSave = true; - ownedItem.Studios = item.Studios.ToList(); + ownedItem.Studios = item.Studios; } if (!item.ProductionLocations.SequenceEqual(ownedItem.ProductionLocations, StringComparer.Ordinal)) { newOptions.ForceSave = true; - ownedItem.ProductionLocations = item.ProductionLocations.ToList(); + ownedItem.ProductionLocations = item.ProductionLocations; } if (item.CommunityRating != ownedItem.CommunityRating) { @@ -2334,7 +2367,9 @@ namespace MediaBrowser.Controller.Entities public string GetEtag(User user) { - return string.Join("|", GetEtagValues(user).ToArray()).GetMD5().ToString("N"); + var list = GetEtagValues(user); + + return string.Join("|", list.ToArray(list.Count)).GetMD5().ToString("N"); } protected virtual List<string> GetEtagValues(User user) @@ -2357,7 +2392,14 @@ namespace MediaBrowser.Controller.Entities return this; } - return GetParents().FirstOrDefault(i => i.IsTopParent); + foreach (var parent in GetParents()) + { + if (parent.IsTopParent) + { + return parent; + } + } + return null; } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs index 7cb242589..9b1a52f83 100644 --- a/MediaBrowser.Controller/Entities/Book.cs +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -1,7 +1,7 @@ using System; +using System.Linq; using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index d88b7da34..537beb26b 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -27,17 +27,8 @@ namespace MediaBrowser.Controller.Entities public CollectionFolder() { - PhysicalLocationsList = new List<string>(); - PhysicalFolderIds = new List<Guid>(); - } - - [IgnoreDataMember] - protected override bool SupportsShortcutChildren - { - get - { - return true; - } + PhysicalLocationsList = EmptyStringArray; + PhysicalFolderIds = EmptyGuidArray; } [IgnoreDataMember] @@ -149,7 +140,7 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] - public override IEnumerable<string> PhysicalLocations + public override string[] PhysicalLocations { get { @@ -162,10 +153,10 @@ namespace MediaBrowser.Controller.Entities return true; } - public List<string> PhysicalLocationsList { get; set; } - public List<Guid> PhysicalFolderIds { get; set; } + public string[] PhysicalLocationsList { get; set; } + public Guid[] PhysicalFolderIds { get; set; } - protected override IEnumerable<FileSystemMetadata> GetFileSystemChildren(IDirectoryService directoryService) + protected override FileSystemMetadata[] GetFileSystemChildren(IDirectoryService directoryService) { return CreateResolveArgs(directoryService, true).FileSystemChildren; } @@ -177,9 +168,9 @@ namespace MediaBrowser.Controller.Entities if (!changed) { - var locations = PhysicalLocations.ToList(); + var locations = PhysicalLocations; - var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations.ToList(); + var newLocations = CreateResolveArgs(new DirectoryService(Logger, FileSystem), false).PhysicalLocations; if (!locations.SequenceEqual(newLocations)) { @@ -189,7 +180,7 @@ namespace MediaBrowser.Controller.Entities if (!changed) { - var folderIds = PhysicalFolderIds.ToList(); + var folderIds = PhysicalFolderIds; var newFolderIds = GetPhysicalFolders(false).Select(i => i.Id).ToList(); @@ -249,17 +240,17 @@ namespace MediaBrowser.Controller.Entities var changed = !linkedChildren.SequenceEqual(LinkedChildren, new LinkedChildComparer(FileSystem)); - LinkedChildren = linkedChildren; + LinkedChildren = linkedChildren.ToArray(linkedChildren.Count); - var folderIds = PhysicalFolderIds.ToList(); - var newFolderIds = physicalFolders.Select(i => i.Id).ToList(); + var folderIds = PhysicalFolderIds; + var newFolderIds = physicalFolders.Select(i => i.Id).ToArray(); if (!folderIds.SequenceEqual(newFolderIds)) { changed = true; if (setFolders) { - PhysicalFolderIds = newFolderIds.ToList(); + PhysicalFolderIds = newFolderIds; } } @@ -301,24 +292,22 @@ namespace MediaBrowser.Controller.Entities // When resolving the root, we need it's grandchildren (children of user views) var flattenFolderDepth = isPhysicalRoot ? 2 : 0; - var fileSystemDictionary = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); + var files = FileData.GetFilteredFileSystemEntries(directoryService, args.Path, FileSystem, Logger, args, flattenFolderDepth: flattenFolderDepth, resolveShortcuts: isPhysicalRoot || args.IsVf); // Need to remove subpaths that may have been resolved from shortcuts // Example: if \\server\movies exists, then strip out \\server\movies\action if (isPhysicalRoot) { - var paths = LibraryManager.NormalizeRootPathList(fileSystemDictionary.Values); - - fileSystemDictionary = paths.ToDictionary(i => i.FullName); + files = LibraryManager.NormalizeRootPathList(files).ToArray(); } - args.FileSystemDictionary = fileSystemDictionary; + args.FileSystemChildren = files; } _requiresRefresh = _requiresRefresh || !args.PhysicalLocations.SequenceEqual(PhysicalLocations); if (setPhysicalLocations) { - PhysicalLocationsList = args.PhysicalLocations.ToList(); + PhysicalLocationsList = args.PhysicalLocations; } return args; diff --git a/MediaBrowser.Controller/Entities/Extensions.cs b/MediaBrowser.Controller/Entities/Extensions.cs index 5e792a03a..36855a86c 100644 --- a/MediaBrowser.Controller/Entities/Extensions.cs +++ b/MediaBrowser.Controller/Entities/Extensions.cs @@ -1,6 +1,7 @@ using MediaBrowser.Model.Entities; using System; using System.Linq; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.Entities { @@ -12,11 +13,7 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Adds the trailer URL. /// </summary> - /// <param name="item">The item.</param> - /// <param name="url">The URL.</param> - /// <param name="isDirectLink">if set to <c>true</c> [is direct link].</param> - /// <exception cref="System.ArgumentNullException">url</exception> - public static void AddTrailerUrl(this IHasTrailers item, string url, bool isDirectLink) + public static void AddTrailerUrl(this IHasTrailers item, string url) { if (string.IsNullOrWhiteSpace(url)) { @@ -27,10 +24,22 @@ namespace MediaBrowser.Controller.Entities if (current == null) { - item.RemoteTrailers.Add(new MediaUrl + var mediaUrl = new MediaUrl { Url = url - }); + }; + + if (item.RemoteTrailers.Length == 0) + { + item.RemoteTrailers = new[] { mediaUrl }; + } + else + { + var list = item.RemoteTrailers.ToArray(item.RemoteTrailers.Length + 1); + list[list.Length - 1] = mediaUrl; + + item.RemoteTrailers = list; + } } } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 5d74cf218..2e741a8c4 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -20,6 +20,7 @@ using MediaBrowser.Controller.IO; using MediaBrowser.Model.Channels; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.Entities { @@ -37,14 +38,14 @@ namespace MediaBrowser.Controller.Entities /// <value><c>true</c> if this instance is root; otherwise, <c>false</c>.</value> public bool IsRoot { get; set; } - public virtual List<LinkedChild> LinkedChildren { get; set; } + public LinkedChild[] LinkedChildren { get; set; } [IgnoreDataMember] public DateTime? DateLastMediaAdded { get; set; } public Folder() { - LinkedChildren = new List<LinkedChild>(); + LinkedChildren = EmptyLinkedChildArray; } [IgnoreDataMember] @@ -185,7 +186,7 @@ namespace MediaBrowser.Controller.Entities /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> /// <exception cref="System.InvalidOperationException">Unable to add + item.Name</exception> - public async Task AddChild(BaseItem item, CancellationToken cancellationToken) + public void AddChild(BaseItem item, CancellationToken cancellationToken) { item.SetParent(this); @@ -208,7 +209,7 @@ namespace MediaBrowser.Controller.Entities item.DateModified = DateTime.UtcNow; } - await LibraryManager.CreateItem(item, cancellationToken).ConfigureAwait(false); + LibraryManager.CreateItem(item, cancellationToken); } /// <summary> @@ -468,7 +469,7 @@ namespace MediaBrowser.Controller.Entities } } - await LibraryManager.CreateItems(newItems, cancellationToken).ConfigureAwait(false); + LibraryManager.CreateItems(newItems, cancellationToken); } } else @@ -647,15 +648,15 @@ namespace MediaBrowser.Controller.Entities public static bool IsPathOffline(string path, List<string> allLibraryPaths) { - if (FileSystem.FileExists(path)) - { - return false; - } + //if (FileSystem.FileExists(path)) + //{ + // return false; + //} var originalPath = path; // Depending on whether the path is local or unc, it may return either null or '\' at the top - while (!string.IsNullOrEmpty(path) && path.Length > 1) + while (!string.IsNullOrWhiteSpace(path) && path.Length > 1) { if (FileSystem.DirectoryExists(path)) { @@ -706,11 +707,11 @@ namespace MediaBrowser.Controller.Entities public virtual int GetChildCount(User user) { - if (LinkedChildren.Count > 0) + if (LinkedChildren.Length > 0) { if (!(this is ICollectionFolder)) { - return GetChildren(user, true).Count(); + return GetChildren(user, true).Count; } } @@ -797,10 +798,10 @@ namespace MediaBrowser.Controller.Entities if (user != null) { // needed for boxsets - itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User)); + itemsList = itemsList.Where(i => i.IsVisibleStandalone(query.User)).ToList(); } - IEnumerable<BaseItem> returnItems; + BaseItem[] returnItems; int totalCount = 0; if (query.EnableTotalRecordCount) @@ -811,16 +812,16 @@ namespace MediaBrowser.Controller.Entities } else { - returnItems = itemsList; + returnItems = itemsList.ToArray(); } if (limit.HasValue) { - returnItems = returnItems.Skip(startIndex ?? 0).Take(limit.Value); + returnItems = returnItems.Skip(startIndex ?? 0).Take(limit.Value).ToArray(); } else if (startIndex.HasValue) { - returnItems = returnItems.Skip(startIndex.Value); + returnItems = returnItems.Skip(startIndex.Value).ToArray(); } return new QueryResult<BaseItem> @@ -843,7 +844,7 @@ namespace MediaBrowser.Controller.Entities private bool RequiresPostFiltering(InternalItemsQuery query) { - if (LinkedChildren.Count > 0) + if (LinkedChildren.Length > 0) { if (!(this is ICollectionFolder)) { @@ -921,12 +922,6 @@ namespace MediaBrowser.Controller.Entities return true; } - if (query.AirDays.Length > 0) - { - Logger.Debug("Query requires post-filtering due to AirDays"); - return true; - } - if (query.SeriesStatuses.Length > 0) { Logger.Debug("Query requires post-filtering due to SeriesStatuses"); @@ -957,7 +952,7 @@ namespace MediaBrowser.Controller.Entities { var result = LibraryManager.GetItemsResult(query); - if (query.SortBy.Length == 0) + if (query.OrderBy.Length == 0) { var ids = query.ItemIds.ToList(); @@ -970,6 +965,27 @@ namespace MediaBrowser.Controller.Entities return GetItemsInternal(query); } + public BaseItem[] GetItemList(InternalItemsQuery query) + { + query.EnableTotalRecordCount = false; + + if (query.ItemIds.Length > 0) + { + var result = LibraryManager.GetItemList(query); + + if (query.OrderBy.Length == 0) + { + var ids = query.ItemIds.ToList(); + + // Try to preserve order + return result.OrderBy(i => ids.IndexOf(i.Id.ToString("N"))).ToArray(); + } + return result.ToArray(result.Count); + } + + return GetItemsInternal(query).Items; + } + protected virtual QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) { if (SourceType == SourceType.Channel) @@ -984,8 +1000,7 @@ namespace MediaBrowser.Controller.Entities Limit = query.Limit, StartIndex = query.StartIndex, UserId = query.User.Id.ToString("N"), - SortBy = query.SortBy, - SortOrder = query.SortOrder + OrderBy = query.OrderBy }, new SimpleProgress<double>(), CancellationToken.None).Result; } @@ -1028,7 +1043,7 @@ namespace MediaBrowser.Controller.Entities return UserViewBuilder.PostFilterAndSort(items, this, null, query, LibraryManager, ConfigurationManager, collapseBoxSetItems, enableSorting); } - public virtual IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) + public virtual List<BaseItem> GetChildren(User user, bool includeLinkedChildren) { if (user == null) { @@ -1042,7 +1057,7 @@ namespace MediaBrowser.Controller.Entities AddChildren(user, includeLinkedChildren, result, false, null); - return result.Values; + return result.Values.ToList(); } protected virtual IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user) @@ -1203,7 +1218,7 @@ namespace MediaBrowser.Controller.Entities return GetLinkedChildren(); } - if (LinkedChildren.Count == 0) + if (LinkedChildren.Length == 0) { return new List<BaseItem>(); } @@ -1292,14 +1307,9 @@ namespace MediaBrowser.Controller.Entities /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> protected virtual bool RefreshLinkedChildren(IEnumerable<FileSystemMetadata> fileSystemChildren) { - var currentManualLinks = LinkedChildren.Where(i => i.Type == LinkedChildType.Manual).ToList(); - var currentShortcutLinks = LinkedChildren.Where(i => i.Type == LinkedChildType.Shortcut).ToList(); - - List<LinkedChild> newShortcutLinks; - if (SupportsShortcutChildren) { - newShortcutLinks = fileSystemChildren + var newShortcutLinks = fileSystemChildren .Where(i => !i.IsDirectory && FileSystem.IsShortcut(i.FullName)) .Select(i => { @@ -1330,16 +1340,17 @@ namespace MediaBrowser.Controller.Entities }) .Where(i => i != null) .ToList(); - } - else { newShortcutLinks = new List<LinkedChild>(); } - if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer(FileSystem))) - { - Logger.Info("Shortcut links have changed for {0}", Path); + var currentShortcutLinks = LinkedChildren.Where(i => i.Type == LinkedChildType.Shortcut).ToList(); - newShortcutLinks.AddRange(currentManualLinks); - LinkedChildren = newShortcutLinks; - return true; + if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer(FileSystem))) + { + Logger.Info("Shortcut links have changed for {0}", Path); + + newShortcutLinks.AddRange(LinkedChildren.Where(i => i.Type == LinkedChildType.Manual)); + LinkedChildren = newShortcutLinks.ToArray(newShortcutLinks.Count); + return true; + } } foreach (var child in LinkedChildren) @@ -1358,7 +1369,7 @@ namespace MediaBrowser.Controller.Entities /// <param name="datePlayed">The date played.</param> /// <param name="resetPosition">if set to <c>true</c> [reset position].</param> /// <returns>Task.</returns> - public override async Task MarkPlayed(User user, + public override void MarkPlayed(User user, DateTime? datePlayed, bool resetPosition) { @@ -1370,17 +1381,18 @@ namespace MediaBrowser.Controller.Entities EnableTotalRecordCount = false }; - if (!user.Configuration.DisplayMissingEpisodes || !user.Configuration.DisplayUnairedEpisodes) + if (!user.Configuration.DisplayMissingEpisodes) { query.IsVirtualItem = false; } - var itemsResult = GetItems(query); + var itemsResult = GetItemList(query); // Sweep through recursively and update status - var tasks = itemsResult.Items.Select(c => c.MarkPlayed(user, datePlayed, resetPosition)); - - await Task.WhenAll(tasks).ConfigureAwait(false); + foreach (var item in itemsResult) + { + item.MarkPlayed(user, datePlayed, resetPosition); + } } /// <summary> @@ -1388,9 +1400,9 @@ namespace MediaBrowser.Controller.Entities /// </summary> /// <param name="user">The user.</param> /// <returns>Task.</returns> - public override async Task MarkUnplayed(User user) + public override void MarkUnplayed(User user) { - var itemsResult = GetItems(new InternalItemsQuery + var itemsResult = GetItemList(new InternalItemsQuery { User = user, Recursive = true, @@ -1400,14 +1412,15 @@ namespace MediaBrowser.Controller.Entities }); // Sweep through recursively and update status - var tasks = itemsResult.Items.Select(c => c.MarkUnplayed(user)); - - await Task.WhenAll(tasks).ConfigureAwait(false); + foreach (var item in itemsResult) + { + item.MarkUnplayed(user); + } } public override bool IsPlayed(User user) { - var itemsResult = GetItems(new InternalItemsQuery(user) + var itemsResult = GetItemList(new InternalItemsQuery(user) { Recursive = true, IsFolder = false, @@ -1416,7 +1429,7 @@ namespace MediaBrowser.Controller.Entities }); - return itemsResult.Items + return itemsResult .All(i => i.IsPlayed(user)); } @@ -1465,7 +1478,7 @@ namespace MediaBrowser.Controller.Entities } } - public override void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, List<ItemFields> fields) + public override void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, ItemFields[] fields) { if (!SupportsUserDataFromChildren) { diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index baefc9dfa..a99058925 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -3,7 +3,6 @@ using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; @@ -13,14 +12,14 @@ namespace MediaBrowser.Controller.Entities { public Game() { - MultiPartGameFiles = new List<string>(); - RemoteTrailers = new List<MediaUrl>(); - LocalTrailerIds = new List<Guid>(); - RemoteTrailerIds = new List<Guid>(); + MultiPartGameFiles = EmptyStringArray; + RemoteTrailers = EmptyMediaUrlArray; + LocalTrailerIds = EmptyGuidArray; + RemoteTrailerIds = EmptyGuidArray; } - public List<Guid> LocalTrailerIds { get; set; } - public List<Guid> RemoteTrailerIds { get; set; } + public Guid[] LocalTrailerIds { get; set; } + public Guid[] RemoteTrailerIds { get; set; } public override bool CanDownload() { @@ -45,7 +44,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the remote trailers. /// </summary> /// <value>The remote trailers.</value> - public List<MediaUrl> RemoteTrailers { get; set; } + public MediaUrl[] RemoteTrailers { get; set; } /// <summary> /// Gets the type of the media. @@ -84,7 +83,7 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Holds the paths to the game files in the event this is a multipart game /// </summary> - public List<string> MultiPartGameFiles { get; set; } + public string[] MultiPartGameFiles { get; set; } public override List<string> GetUserDataKeys() { @@ -100,7 +99,7 @@ namespace MediaBrowser.Controller.Entities public override IEnumerable<FileSystemMetadata> GetDeletePaths() { - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { return new[] { new FileSystemMetadata @@ -127,16 +126,5 @@ namespace MediaBrowser.Controller.Entities return id; } - - /// <summary> - /// Gets the trailer ids. - /// </summary> - /// <returns>List<Guid>.</returns> - public List<Guid> GetTrailerIds() - { - var list = LocalTrailerIds.ToList(); - list.AddRange(RemoteTrailerIds); - return list; - } } } diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 836020d88..4e78a7fa5 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 4b70eae58..790f8938e 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Entities.Audio; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Extensions; diff --git a/MediaBrowser.Controller/Entities/ICollectionFolder.cs b/MediaBrowser.Controller/Entities/ICollectionFolder.cs index d8b02034c..b70ad322d 100644 --- a/MediaBrowser.Controller/Entities/ICollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/ICollectionFolder.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Entities string Path { get; } string Name { get; } Guid Id { get; } - IEnumerable<string> PhysicalLocations { get; } + string[] PhysicalLocations { get; } } public interface ISupportsUserSpecificView diff --git a/MediaBrowser.Controller/Entities/IHasId.cs b/MediaBrowser.Controller/Entities/IHasId.cs deleted file mode 100644 index 9698adf7a..000000000 --- a/MediaBrowser.Controller/Entities/IHasId.cs +++ /dev/null @@ -1,9 +0,0 @@ -using System; - -namespace MediaBrowser.Controller.Entities -{ - public interface IHasId - { - Guid Id { get; } - } -} diff --git a/MediaBrowser.Controller/Entities/IHasImages.cs b/MediaBrowser.Controller/Entities/IHasImages.cs deleted file mode 100644 index e2b3c0777..000000000 --- a/MediaBrowser.Controller/Entities/IHasImages.cs +++ /dev/null @@ -1,264 +0,0 @@ -using MediaBrowser.Controller.Providers; -using MediaBrowser.Model.Entities; -using System.Collections.Generic; -using System.Threading; -using System.Threading.Tasks; - -using MediaBrowser.Controller.IO; -using MediaBrowser.Controller.Library; -using MediaBrowser.Model.IO; - -namespace MediaBrowser.Controller.Entities -{ - public interface IHasImages : IHasProviderIds, IHasId - { - /// <summary> - /// Gets the name. - /// </summary> - /// <value>The name.</value> - string Name { get; set; } - - /// <summary> - /// Gets the path. - /// </summary> - /// <value>The path.</value> - string Path { get; set; } - - /// <summary> - /// Gets the file name without extension. - /// </summary> - /// <value>The file name without extension.</value> - string FileNameWithoutExtension { get; } - - /// <summary> - /// Gets the type of the location. - /// </summary> - /// <value>The type of the location.</value> - LocationType LocationType { get; } - - /// <summary> - /// Gets the locked fields. - /// </summary> - /// <value>The locked fields.</value> - List<MetadataFields> LockedFields { get; } - - /// <summary> - /// Gets the images. - /// </summary> - /// <param name="imageType">Type of the image.</param> - /// <returns>IEnumerable{ItemImageInfo}.</returns> - IEnumerable<ItemImageInfo> GetImages(ImageType imageType); - - /// <summary> - /// Gets the image path. - /// </summary> - /// <param name="imageType">Type of the image.</param> - /// <param name="imageIndex">Index of the image.</param> - /// <returns>System.String.</returns> - string GetImagePath(ImageType imageType, int imageIndex); - - /// <summary> - /// Gets the image information. - /// </summary> - /// <param name="imageType">Type of the image.</param> - /// <param name="imageIndex">Index of the image.</param> - /// <returns>ItemImageInfo.</returns> - ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex); - - /// <summary> - /// Sets the image. - /// </summary> - /// <param name="type">The type.</param> - /// <param name="index">The index.</param> - /// <param name="file">The file.</param> - void SetImagePath(ImageType type, int index, FileSystemMetadata file); - - /// <summary> - /// Determines whether the specified type has image. - /// </summary> - /// <param name="type">The type.</param> - /// <param name="imageIndex">Index of the image.</param> - /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns> - bool HasImage(ImageType type, int imageIndex); - - /// <summary> - /// Allowses the multiple images. - /// </summary> - /// <param name="type">The type.</param> - /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> - bool AllowsMultipleImages(ImageType type); - - /// <summary> - /// Swaps the images. - /// </summary> - /// <param name="type">The type.</param> - /// <param name="index1">The index1.</param> - /// <param name="index2">The index2.</param> - /// <returns>Task.</returns> - Task SwapImages(ImageType type, int index1, int index2); - - /// <summary> - /// Gets the display type of the media. - /// </summary> - /// <value>The display type of the media.</value> - string DisplayMediaType { get; set; } - - /// <summary> - /// Gets or sets the primary image path. - /// </summary> - /// <value>The primary image path.</value> - string PrimaryImagePath { get; } - - /// <summary> - /// Gets the preferred metadata language. - /// </summary> - /// <returns>System.String.</returns> - string GetPreferredMetadataLanguage(); - - /// <summary> - /// Validates the images and returns true or false indicating if any were removed. - /// </summary> - bool ValidateImages(IDirectoryService directoryService); - - /// <summary> - /// Gets a value indicating whether this instance is owned item. - /// </summary> - /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value> - bool IsOwnedItem { get; } - - /// <summary> - /// Gets the containing folder path. - /// </summary> - /// <value>The containing folder path.</value> - string ContainingFolderPath { get; } - - /// <summary> - /// Adds the images. - /// </summary> - /// <param name="imageType">Type of the image.</param> - /// <param name="images">The images.</param> - /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> - bool AddImages(ImageType imageType, List<FileSystemMetadata> images); - - /// <summary> - /// Determines whether [is save local metadata enabled]. - /// </summary> - /// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns> - bool IsSaveLocalMetadataEnabled(); - - /// <summary> - /// Gets a value indicating whether [supports local metadata]. - /// </summary> - /// <value><c>true</c> if [supports local metadata]; otherwise, <c>false</c>.</value> - bool SupportsLocalMetadata { get; } - - bool DetectIsInMixedFolder(); - - /// <summary> - /// Gets a value indicating whether this instance is locked. - /// </summary> - /// <value><c>true</c> if this instance is locked; otherwise, <c>false</c>.</value> - bool IsLocked { get; } - - /// <summary> - /// Gets a value indicating whether [supports remote image downloading]. - /// </summary> - /// <value><c>true</c> if [supports remote image downloading]; otherwise, <c>false</c>.</value> - bool SupportsRemoteImageDownloading { get; } - - /// <summary> - /// Gets the internal metadata path. - /// </summary> - /// <returns>System.String.</returns> - string GetInternalMetadataPath(); - - /// <summary> - /// Gets a value indicating whether [always scan internal metadata path]. - /// </summary> - /// <value><c>true</c> if [always scan internal metadata path]; otherwise, <c>false</c>.</value> - bool AlwaysScanInternalMetadataPath { get; } - - /// <summary> - /// Determines whether [is internet metadata enabled]. - /// </summary> - /// <returns><c>true</c> if [is internet metadata enabled]; otherwise, <c>false</c>.</returns> - bool IsInternetMetadataEnabled(); - - /// <summary> - /// Removes the image. - /// </summary> - /// <param name="image">The image.</param> - void RemoveImage(ItemImageInfo image); - - /// <summary> - /// Updates to repository. - /// </summary> - /// <param name="updateReason">The update reason.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken); - - /// <summary> - /// Sets the image. - /// </summary> - /// <param name="image">The image.</param> - /// <param name="index">The index.</param> - void SetImage(ItemImageInfo image, int index); - - double? GetDefaultPrimaryImageAspectRatio(); - - int? ProductionYear { get; set; } - } - - public static class HasImagesExtensions - { - /// <summary> - /// Gets the image path. - /// </summary> - /// <param name="item">The item.</param> - /// <param name="imageType">Type of the image.</param> - /// <returns>System.String.</returns> - public static string GetImagePath(this IHasImages item, ImageType imageType) - { - return item.GetImagePath(imageType, 0); - } - - public static bool HasImage(this IHasImages item, ImageType imageType) - { - return item.HasImage(imageType, 0); - } - - /// <summary> - /// Sets the image path. - /// </summary> - /// <param name="item">The item.</param> - /// <param name="imageType">Type of the image.</param> - /// <param name="file">The file.</param> - public static void SetImagePath(this IHasImages item, ImageType imageType, FileSystemMetadata file) - { - item.SetImagePath(imageType, 0, file); - } - - /// <summary> - /// Sets the image path. - /// </summary> - /// <param name="item">The item.</param> - /// <param name="imageType">Type of the image.</param> - /// <param name="file">The file.</param> - public static void SetImagePath(this IHasImages item, ImageType imageType, string file) - { - if (file.StartsWith("http", System.StringComparison.OrdinalIgnoreCase)) - { - item.SetImage(new ItemImageInfo - { - Path = file, - Type = imageType - }, 0); - } - else - { - item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file)); - } - } - } -} diff --git a/MediaBrowser.Controller/Entities/IHasMediaSources.cs b/MediaBrowser.Controller/Entities/IHasMediaSources.cs index 832b9f6c1..54786134f 100644 --- a/MediaBrowser.Controller/Entities/IHasMediaSources.cs +++ b/MediaBrowser.Controller/Entities/IHasMediaSources.cs @@ -1,15 +1,17 @@ using MediaBrowser.Model.Dto; using System.Collections.Generic; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.Entities { - public interface IHasMediaSources : IHasUserData + public interface IHasMediaSources : IHasMetadata { /// <summary> /// Gets the media sources. /// </summary> /// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param> /// <returns>Task{IEnumerable{MediaSourceInfo}}.</returns> - IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution); + List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution); + List<MediaStream> GetMediaStreams(); } } diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 62c67336c..59d9bd9f9 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -1,12 +1,18 @@ using System; using System.Collections.Generic; +using System.Threading; +using System.Threading.Tasks; +using MediaBrowser.Controller.Library; +using MediaBrowser.Controller.Providers; +using MediaBrowser.Model.Entities; +using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.Entities { /// <summary> /// Interface IHasMetadata /// </summary> - public interface IHasMetadata : IHasImages + public interface IHasMetadata : IHasProviderIds, IHasUserData { /// <summary> /// Gets the preferred metadata country code. @@ -64,6 +70,253 @@ namespace MediaBrowser.Controller.Entities int? GetInheritedParentalRatingValue(); int InheritedParentalRatingValue { get; set; } List<string> GetInheritedTags(); - List<string> InheritedTags { get; set; } + long? RunTimeTicks { get; set; } + + /// <summary> + /// Gets the name. + /// </summary> + /// <value>The name.</value> + string Name { get; set; } + + /// <summary> + /// Gets the path. + /// </summary> + /// <value>The path.</value> + string Path { get; set; } + + /// <summary> + /// Gets the file name without extension. + /// </summary> + /// <value>The file name without extension.</value> + string FileNameWithoutExtension { get; } + + /// <summary> + /// Gets the type of the location. + /// </summary> + /// <value>The type of the location.</value> + LocationType LocationType { get; } + + /// <summary> + /// Gets the locked fields. + /// </summary> + /// <value>The locked fields.</value> + MetadataFields[] LockedFields { get; } + + /// <summary> + /// Gets the images. + /// </summary> + /// <param name="imageType">Type of the image.</param> + /// <returns>IEnumerable{ItemImageInfo}.</returns> + IEnumerable<ItemImageInfo> GetImages(ImageType imageType); + + /// <summary> + /// Gets the image path. + /// </summary> + /// <param name="imageType">Type of the image.</param> + /// <param name="imageIndex">Index of the image.</param> + /// <returns>System.String.</returns> + string GetImagePath(ImageType imageType, int imageIndex); + + /// <summary> + /// Gets the image information. + /// </summary> + /// <param name="imageType">Type of the image.</param> + /// <param name="imageIndex">Index of the image.</param> + /// <returns>ItemImageInfo.</returns> + ItemImageInfo GetImageInfo(ImageType imageType, int imageIndex); + + /// <summary> + /// Sets the image. + /// </summary> + /// <param name="type">The type.</param> + /// <param name="index">The index.</param> + /// <param name="file">The file.</param> + void SetImagePath(ImageType type, int index, FileSystemMetadata file); + + /// <summary> + /// Determines whether the specified type has image. + /// </summary> + /// <param name="type">The type.</param> + /// <param name="imageIndex">Index of the image.</param> + /// <returns><c>true</c> if the specified type has image; otherwise, <c>false</c>.</returns> + bool HasImage(ImageType type, int imageIndex); + + /// <summary> + /// Allowses the multiple images. + /// </summary> + /// <param name="type">The type.</param> + /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> + bool AllowsMultipleImages(ImageType type); + + /// <summary> + /// Swaps the images. + /// </summary> + /// <param name="type">The type.</param> + /// <param name="index1">The index1.</param> + /// <param name="index2">The index2.</param> + /// <returns>Task.</returns> + Task SwapImages(ImageType type, int index1, int index2); + + /// <summary> + /// Gets or sets the primary image path. + /// </summary> + /// <value>The primary image path.</value> + string PrimaryImagePath { get; } + + /// <summary> + /// Gets the preferred metadata language. + /// </summary> + /// <returns>System.String.</returns> + string GetPreferredMetadataLanguage(); + + /// <summary> + /// Validates the images and returns true or false indicating if any were removed. + /// </summary> + bool ValidateImages(IDirectoryService directoryService); + + /// <summary> + /// Gets a value indicating whether this instance is owned item. + /// </summary> + /// <value><c>true</c> if this instance is owned item; otherwise, <c>false</c>.</value> + bool IsOwnedItem { get; } + + /// <summary> + /// Gets the containing folder path. + /// </summary> + /// <value>The containing folder path.</value> + string ContainingFolderPath { get; } + + /// <summary> + /// Adds the images. + /// </summary> + /// <param name="imageType">Type of the image.</param> + /// <param name="images">The images.</param> + /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> + bool AddImages(ImageType imageType, List<FileSystemMetadata> images); + + /// <summary> + /// Determines whether [is save local metadata enabled]. + /// </summary> + /// <returns><c>true</c> if [is save local metadata enabled]; otherwise, <c>false</c>.</returns> + bool IsSaveLocalMetadataEnabled(); + + /// <summary> + /// Gets a value indicating whether [supports local metadata]. + /// </summary> + /// <value><c>true</c> if [supports local metadata]; otherwise, <c>false</c>.</value> + bool SupportsLocalMetadata { get; } + + bool IsInMixedFolder { get; } + + /// <summary> + /// Gets a value indicating whether this instance is locked. + /// </summary> + /// <value><c>true</c> if this instance is locked; otherwise, <c>false</c>.</value> + bool IsLocked { get; } + + /// <summary> + /// Gets a value indicating whether [supports remote image downloading]. + /// </summary> + /// <value><c>true</c> if [supports remote image downloading]; otherwise, <c>false</c>.</value> + bool SupportsRemoteImageDownloading { get; } + + /// <summary> + /// Gets the internal metadata path. + /// </summary> + /// <returns>System.String.</returns> + string GetInternalMetadataPath(); + + /// <summary> + /// Gets a value indicating whether [always scan internal metadata path]. + /// </summary> + /// <value><c>true</c> if [always scan internal metadata path]; otherwise, <c>false</c>.</value> + bool AlwaysScanInternalMetadataPath { get; } + + /// <summary> + /// Determines whether [is internet metadata enabled]. + /// </summary> + /// <returns><c>true</c> if [is internet metadata enabled]; otherwise, <c>false</c>.</returns> + bool IsInternetMetadataEnabled(); + + /// <summary> + /// Removes the image. + /// </summary> + /// <param name="image">The image.</param> + void RemoveImage(ItemImageInfo image); + + void RemoveImages(List<ItemImageInfo> images); + + /// <summary> + /// Updates to repository. + /// </summary> + /// <param name="updateReason">The update reason.</param> + /// <param name="cancellationToken">The cancellation token.</param> + /// <returns>Task.</returns> + Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken); + + /// <summary> + /// Sets the image. + /// </summary> + /// <param name="image">The image.</param> + /// <param name="index">The index.</param> + void SetImage(ItemImageInfo image, int index); + + double? GetDefaultPrimaryImageAspectRatio(); + + int? ProductionYear { get; set; } + + string[] Tags { get; set; } + } + + public static class HasMetadataExtensions + { + /// <summary> + /// Gets the image path. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="imageType">Type of the image.</param> + /// <returns>System.String.</returns> + public static string GetImagePath(this IHasMetadata item, ImageType imageType) + { + return item.GetImagePath(imageType, 0); + } + + public static bool HasImage(this IHasMetadata item, ImageType imageType) + { + return item.HasImage(imageType, 0); + } + + /// <summary> + /// Sets the image path. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="imageType">Type of the image.</param> + /// <param name="file">The file.</param> + public static void SetImagePath(this IHasMetadata item, ImageType imageType, FileSystemMetadata file) + { + item.SetImagePath(imageType, 0, file); + } + + /// <summary> + /// Sets the image path. + /// </summary> + /// <param name="item">The item.</param> + /// <param name="imageType">Type of the image.</param> + /// <param name="file">The file.</param> + public static void SetImagePath(this IHasMetadata item, ImageType imageType, string file) + { + if (file.StartsWith("http", System.StringComparison.OrdinalIgnoreCase)) + { + item.SetImage(new ItemImageInfo + { + Path = file, + Type = imageType + }, 0); + } + else + { + item.SetImagePath(imageType, BaseItem.FileSystem.GetFileInfo(file)); + } + } } } diff --git a/MediaBrowser.Controller/Entities/IHasSpecialFeatures.cs b/MediaBrowser.Controller/Entities/IHasSpecialFeatures.cs index b3a0dc237..f4905b7dc 100644 --- a/MediaBrowser.Controller/Entities/IHasSpecialFeatures.cs +++ b/MediaBrowser.Controller/Entities/IHasSpecialFeatures.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; namespace MediaBrowser.Controller.Entities { @@ -9,6 +8,6 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the special feature ids. /// </summary> /// <value>The special feature ids.</value> - List<Guid> SpecialFeatureIds { get; set; } + Guid[] SpecialFeatureIds { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/IHasTrailers.cs b/MediaBrowser.Controller/Entities/IHasTrailers.cs index e5cbdff72..8686c802a 100644 --- a/MediaBrowser.Controller/Entities/IHasTrailers.cs +++ b/MediaBrowser.Controller/Entities/IHasTrailers.cs @@ -11,14 +11,14 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the remote trailers. /// </summary> /// <value>The remote trailers.</value> - List<MediaUrl> RemoteTrailers { get; set; } + MediaUrl[] RemoteTrailers { get; set; } /// <summary> /// Gets or sets the local trailer ids. /// </summary> /// <value>The local trailer ids.</value> - List<Guid> LocalTrailerIds { get; set; } - List<Guid> RemoteTrailerIds { get; set; } + Guid[] LocalTrailerIds { get; set; } + Guid[] RemoteTrailerIds { get; set; } } public static class HasTrailerExtensions diff --git a/MediaBrowser.Controller/Entities/IHasUserData.cs b/MediaBrowser.Controller/Entities/IHasUserData.cs index 0029947ee..ab4f624e2 100644 --- a/MediaBrowser.Controller/Entities/IHasUserData.cs +++ b/MediaBrowser.Controller/Entities/IHasUserData.cs @@ -1,4 +1,5 @@ -using System.Collections.Generic; +using System; +using System.Collections.Generic; using System.Threading.Tasks; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; @@ -8,17 +9,19 @@ namespace MediaBrowser.Controller.Entities /// <summary> /// Interface IHasUserData /// </summary> - public interface IHasUserData : IHasId + public interface IHasUserData { List<string> GetUserDataKeys(); /// <summary> /// Fills the user data dto values. /// </summary> - void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, List<ItemFields> fields); + void FillUserDataDtoValues(UserItemDataDto dto, UserItemData userData, BaseItemDto itemDto, User user, ItemFields[] fields); bool EnableRememberingTrackSelections { get; } bool SupportsPlayedStatus { get; } + + Guid Id { get; } } } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 4f21aaa56..03dc18b7a 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -16,10 +16,6 @@ namespace MediaBrowser.Controller.Entities public int? Limit { get; set; } - public string[] SortBy { get; set; } - - public SortOrder SortOrder { get; set; } - public User User { get; set; } public BaseItem SimilarTo { get; set; } @@ -42,7 +38,6 @@ namespace MediaBrowser.Controller.Entities public bool? IsSpecialSeason { get; set; } public bool? IsMissing { get; set; } public bool? IsUnaired { get; set; } - public bool? IsVirtualUnaired { get; set; } public bool? CollapseBoxSetItems { get; set; } public string NameStartsWithOrGreater { get; set; } @@ -149,7 +144,6 @@ namespace MediaBrowser.Controller.Entities public TrailerType[] TrailerTypes { get; set; } public SourceType[] SourceTypes { get; set; } - public DayOfWeek[] AirDays { get; set; } public SeriesStatus[] SeriesStatuses { get; set; } public string ExternalSeriesId { get; set; } public string ExternalId { get; set; } @@ -161,12 +155,13 @@ namespace MediaBrowser.Controller.Entities public string SeriesPresentationUniqueKey { get; set; } public bool GroupByPresentationUniqueKey { get; set; } + public bool GroupBySeriesPresentationUniqueKey { get; set; } public bool EnableTotalRecordCount { get; set; } public bool ForceDirect { get; set; } public Dictionary<string, string> ExcludeProviderIds { get; set; } public bool EnableGroupByMetadataKey { get; set; } - public List<Tuple<string, SortOrder>> OrderBy { get; set; } + public Tuple<string, SortOrder>[] OrderBy { get; set; } public DateTime? MinDateCreated { get; set; } public DateTime? MinDateLastSaved { get; set; } @@ -191,7 +186,6 @@ namespace MediaBrowser.Controller.Entities BlockUnratedItems = new UnratedItem[] { }; Tags = new string[] { }; OfficialRatings = new string[] { }; - SortBy = new string[] { }; MediaTypes = new string[] { }; IncludeItemTypes = new string[] { }; ExcludeItemTypes = new string[] { }; @@ -213,9 +207,8 @@ namespace MediaBrowser.Controller.Entities PresetViews = new string[] { }; TrailerTypes = new TrailerType[] { }; SourceTypes = new SourceType[] { }; - AirDays = new DayOfWeek[] { }; SeriesStatuses = new SeriesStatus[] { }; - OrderBy = new List<Tuple<string, SortOrder>>(); + OrderBy = new Tuple<string, SortOrder>[] { }; } public InternalItemsQuery(User user) diff --git a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs index 05d23d986..9e0e9c208 100644 --- a/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalPeopleQuery.cs @@ -6,7 +6,7 @@ namespace MediaBrowser.Controller.Entities public class InternalPeopleQuery { public Guid ItemId { get; set; } - public List<string> PersonTypes { get; set; } + public string[] PersonTypes { get; set; } public List<string> ExcludePersonTypes { get; set; } public int? MaxListOrder { get; set; } public Guid AppearsInItemId { get; set; } @@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Entities public InternalPeopleQuery() { - PersonTypes = new List<string>(); + PersonTypes = new string[] {}; ExcludePersonTypes = new List<string>(); } } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 071ed405f..900e8a664 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -1,5 +1,4 @@ -using MediaBrowser.Controller.Entities.TV; -using MediaBrowser.Controller.Providers; +using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; @@ -8,7 +7,6 @@ using System; using System.Collections.Generic; using System.Linq; using MediaBrowser.Model.Serialization; -using MediaBrowser.Controller.Entities.Audio; namespace MediaBrowser.Controller.Entities.Movies { @@ -21,9 +19,9 @@ namespace MediaBrowser.Controller.Entities.Movies public BoxSet() { - RemoteTrailers = new List<MediaUrl>(); - LocalTrailerIds = new List<Guid>(); - RemoteTrailerIds = new List<Guid>(); + RemoteTrailers = EmptyMediaUrlArray; + LocalTrailerIds = EmptyGuidArray; + RemoteTrailerIds = EmptyGuidArray; DisplayOrder = ItemSortBy.PremiereDate; Shares = new List<Share>(); @@ -47,14 +45,14 @@ namespace MediaBrowser.Controller.Entities.Movies } } - public List<Guid> LocalTrailerIds { get; set; } - public List<Guid> RemoteTrailerIds { get; set; } + public Guid[] LocalTrailerIds { get; set; } + public Guid[] RemoteTrailerIds { get; set; } /// <summary> /// Gets or sets the remote trailers. /// </summary> /// <value>The remote trailers.</value> - public List<MediaUrl> RemoteTrailers { get; set; } + public MediaUrl[] RemoteTrailers { get; set; } /// <summary> /// Gets or sets the display order. @@ -82,20 +80,11 @@ namespace MediaBrowser.Controller.Entities.Movies protected override IEnumerable<BaseItem> GetNonCachedChildren(IDirectoryService directoryService) { - if (IsLegacyBoxSet) - { - return base.GetNonCachedChildren(directoryService); - } return new List<BaseItem>(); } protected override List<BaseItem> LoadChildren() { - if (IsLegacyBoxSet) - { - return base.LoadChildren(); - } - // Save a trip to the database return new List<BaseItem>(); } @@ -109,34 +98,6 @@ namespace MediaBrowser.Controller.Entities.Movies } } - [IgnoreDataMember] - protected override bool SupportsShortcutChildren - { - get - { - if (IsLegacyBoxSet) - { - return true; - } - - return false; - } - } - - [IgnoreDataMember] - private bool IsLegacyBoxSet - { - get - { - if (string.IsNullOrWhiteSpace(Path)) - { - return false; - } - - return !FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.DataPath, Path); - } - } - public override bool IsAuthorizedToDelete(User user) { return true; @@ -148,17 +109,6 @@ namespace MediaBrowser.Controller.Entities.Movies } /// <summary> - /// Gets the trailer ids. - /// </summary> - /// <returns>List<Guid>.</returns> - public List<Guid> GetTrailerIds() - { - var list = LocalTrailerIds.ToList(); - list.AddRange(RemoteTrailerIds); - return list; - } - - /// <summary> /// Updates the official rating based on content and returns true or false indicating if it changed. /// </summary> /// <returns></returns> @@ -181,24 +131,24 @@ namespace MediaBrowser.Controller.Entities.Movies StringComparison.OrdinalIgnoreCase); } - public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) + public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren) { var children = base.GetChildren(user, includeLinkedChildren); if (string.Equals(DisplayOrder, ItemSortBy.SortName, StringComparison.OrdinalIgnoreCase)) { // Sort by name - return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(children, user, new[] { ItemSortBy.SortName }, SortOrder.Ascending).ToList(); } if (string.Equals(DisplayOrder, ItemSortBy.PremiereDate, StringComparison.OrdinalIgnoreCase)) { // Sort by release date - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); } // Default sorting - return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending); + return LibraryManager.Sort(children, user, new[] { ItemSortBy.ProductionYear, ItemSortBy.PremiereDate, ItemSortBy.SortName }, SortOrder.Ascending).ToList(); } public BoxSetInfo GetLookupInfo() @@ -218,7 +168,7 @@ namespace MediaBrowser.Controller.Entities.Movies if (base.IsVisible(user)) { - return base.GetChildren(user, true).Any(); + return base.GetChildren(user, true).Count > 0; } return false; diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 8a5b726e2..3a41709fe 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -19,20 +19,20 @@ namespace MediaBrowser.Controller.Entities.Movies /// </summary> public class Movie : Video, IHasSpecialFeatures, IHasTrailers, IHasLookupInfo<MovieInfo>, ISupportsBoxSetGrouping { - public List<Guid> SpecialFeatureIds { get; set; } + public Guid[] SpecialFeatureIds { get; set; } public Movie() { - SpecialFeatureIds = new List<Guid>(); - RemoteTrailers = new List<MediaUrl>(); - LocalTrailerIds = new List<Guid>(); - RemoteTrailerIds = new List<Guid>(); + SpecialFeatureIds = EmptyGuidArray; + RemoteTrailers = EmptyMediaUrlArray; + LocalTrailerIds = EmptyGuidArray; + RemoteTrailerIds = EmptyGuidArray; } - public List<Guid> LocalTrailerIds { get; set; } - public List<Guid> RemoteTrailerIds { get; set; } + public Guid[] LocalTrailerIds { get; set; } + public Guid[] RemoteTrailerIds { get; set; } - public List<MediaUrl> RemoteTrailers { get; set; } + public MediaUrl[] RemoteTrailers { get; set; } /// <summary> /// Gets or sets the name of the TMDB collection. @@ -55,22 +55,13 @@ namespace MediaBrowser.Controller.Entities.Movies return value; } - [IgnoreDataMember] - protected override bool SupportsIsInMixedFolderDetection - { - get - { - return false; - } - } - protected override async Task<bool> RefreshedOwnedItems(MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) { var hasChanges = await base.RefreshedOwnedItems(options, fileSystemChildren, cancellationToken).ConfigureAwait(false); // Must have a parent to have special features // In other words, it must be part of the Parent/Child tree - if (LocationType == LocationType.FileSystem && GetParent() != null && !DetectIsInMixedFolder()) + if (LocationType == LocationType.FileSystem && GetParent() != null && !IsInMixedFolder) { var specialFeaturesChanged = await RefreshSpecialFeatures(options, fileSystemChildren, cancellationToken).ConfigureAwait(false); @@ -86,7 +77,7 @@ namespace MediaBrowser.Controller.Entities.Movies private async Task<bool> RefreshSpecialFeatures(MetadataRefreshOptions options, List<FileSystemMetadata> fileSystemChildren, CancellationToken cancellationToken) { var newItems = LibraryManager.FindExtras(this, fileSystemChildren, options.DirectoryService).ToList(); - var newItemIds = newItems.Select(i => i.Id).ToList(); + var newItemIds = newItems.Select(i => i.Id).ToArray(); var itemsChanged = !SpecialFeatureIds.SequenceEqual(newItemIds); @@ -108,7 +99,7 @@ namespace MediaBrowser.Controller.Entities.Movies { var info = GetItemLookupInfo<MovieInfo>(); - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { var name = System.IO.Path.GetFileName(ContainingFolderPath); @@ -145,7 +136,7 @@ namespace MediaBrowser.Controller.Entities.Movies else { // Try to get the year from the folder name - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath)); diff --git a/MediaBrowser.Controller/Entities/MusicVideo.cs b/MediaBrowser.Controller/Entities/MusicVideo.cs index 7344cb8e4..b7470d679 100644 --- a/MediaBrowser.Controller/Entities/MusicVideo.cs +++ b/MediaBrowser.Controller/Entities/MusicVideo.cs @@ -8,15 +8,16 @@ namespace MediaBrowser.Controller.Entities { public class MusicVideo : Video, IHasArtist, IHasMusicGenres, IHasLookupInfo<MusicVideoInfo> { - public List<string> Artists { get; set; } + [IgnoreDataMember] + public string[] Artists { get; set; } public MusicVideo() { - Artists = new List<string>(); + Artists = EmptyStringArray; } [IgnoreDataMember] - public List<string> AllArtists + public string[] AllArtists { get { @@ -24,15 +25,6 @@ namespace MediaBrowser.Controller.Entities } } - [IgnoreDataMember] - protected override bool SupportsIsInMixedFolderDetection - { - get - { - return false; - } - } - public override UnratedItem GetBlockUnratedType() { return UnratedItem.Music; @@ -61,7 +53,7 @@ namespace MediaBrowser.Controller.Entities else { // Try to get the year from the folder name - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath)); diff --git a/MediaBrowser.Controller/Entities/PeopleHelper.cs b/MediaBrowser.Controller/Entities/PeopleHelper.cs index 40a93d9e6..412eb9499 100644 --- a/MediaBrowser.Controller/Entities/PeopleHelper.cs +++ b/MediaBrowser.Controller/Entities/PeopleHelper.cs @@ -105,7 +105,15 @@ namespace MediaBrowser.Controller.Entities { throw new ArgumentNullException("name"); } - return people.Any(i => string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)); + + foreach (var i in people) + { + if (string.Equals(i.Name, name, StringComparison.OrdinalIgnoreCase)) + { + return true; + } + } + return false; } } } diff --git a/MediaBrowser.Controller/Entities/Person.cs b/MediaBrowser.Controller/Entities/Person.cs index 20d9c7999..b3a91f944 100644 --- a/MediaBrowser.Controller/Entities/Person.cs +++ b/MediaBrowser.Controller/Entities/Person.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Providers; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Entities; diff --git a/MediaBrowser.Controller/Entities/Photo.cs b/MediaBrowser.Controller/Entities/Photo.cs index e95ceee52..8e9eac50c 100644 --- a/MediaBrowser.Controller/Entities/Photo.cs +++ b/MediaBrowser.Controller/Entities/Photo.cs @@ -1,5 +1,4 @@ using MediaBrowser.Model.Drawing; -using System.Linq; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities @@ -39,7 +38,16 @@ namespace MediaBrowser.Controller.Entities { get { - return GetParents().OfType<PhotoAlbum>().FirstOrDefault(); + var parents = GetParents(); + foreach (var parent in parents) + { + var photoAlbum = parent as PhotoAlbum; + if (photoAlbum != null) + { + return photoAlbum; + } + } + return null; } } diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index 8cb65c60a..a6a72d994 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -1,6 +1,5 @@ using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using MediaBrowser.Common.Extensions; using MediaBrowser.Controller.Extensions; diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 45b4de1b3..c30e0ef8e 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -17,14 +17,14 @@ namespace MediaBrowser.Controller.Entities.TV {
public Episode()
{
- RemoteTrailers = new List<MediaUrl>();
- LocalTrailerIds = new List<Guid>();
- RemoteTrailerIds = new List<Guid>();
+ RemoteTrailers = EmptyMediaUrlArray;
+ LocalTrailerIds = EmptyGuidArray;
+ RemoteTrailerIds = EmptyGuidArray;
}
- public List<Guid> LocalTrailerIds { get; set; }
- public List<Guid> RemoteTrailerIds { get; set; }
- public List<MediaUrl> RemoteTrailers { get; set; }
+ public Guid[] LocalTrailerIds { get; set; }
+ public Guid[] RemoteTrailerIds { get; set; }
+ public MediaUrl[] RemoteTrailers { get; set; }
/// <summary>
/// Gets the season in which it aired.
@@ -282,17 +282,11 @@ namespace MediaBrowser.Controller.Entities.TV {
get
{
- return LocationType == LocationType.Virtual && !IsUnaired;
+ return LocationType == LocationType.Virtual;
}
}
[IgnoreDataMember]
- public bool IsVirtualUnaired
- {
- get { return LocationType == LocationType.Virtual && IsUnaired; }
- }
-
- [IgnoreDataMember]
public Guid? SeasonId { get; set; }
[IgnoreDataMember]
public Guid? SeriesId { get; set; }
@@ -346,7 +340,6 @@ namespace MediaBrowser.Controller.Entities.TV id.IsMissingEpisode = IsMissingEpisode;
id.IndexNumberEnd = IndexNumberEnd;
- id.IsVirtualUnaired = IsVirtualUnaired;
return id;
}
diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index b681fdcb1..bf6dc5678 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Entities.TV public override int GetChildCount(User user) { - var result = GetChildren(user, true).Count(); + var result = GetChildren(user, true).Count; return result; } @@ -160,27 +160,27 @@ namespace MediaBrowser.Controller.Entities.TV /// <summary> /// Gets the episodes. /// </summary> - public IEnumerable<Episode> GetEpisodes(User user, DtoOptions options) + public List<BaseItem> GetEpisodes(User user, DtoOptions options) { return GetEpisodes(Series, user, options); } - public IEnumerable<Episode> GetEpisodes(Series series, User user, DtoOptions options) + public List<BaseItem> GetEpisodes(Series series, User user, DtoOptions options) { return GetEpisodes(series, user, null, options); } - public IEnumerable<Episode> GetEpisodes(Series series, User user, IEnumerable<Episode> allSeriesEpisodes, DtoOptions options) + public List<BaseItem> GetEpisodes(Series series, User user, IEnumerable<Episode> allSeriesEpisodes, DtoOptions options) { return series.GetSeasonEpisodes(this, user, allSeriesEpisodes, options); } - public IEnumerable<Episode> GetEpisodes() + public List<BaseItem> GetEpisodes() { return Series.GetSeasonEpisodes(this, null, null, new DtoOptions(true)); } - public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) + public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren) { return GetEpisodes(user, new DtoOptions(true)); } diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 8b73b80b0..60d2624fa 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -22,13 +22,15 @@ namespace MediaBrowser.Controller.Entities.TV { public Series() { - AirDays = new List<DayOfWeek>(); - - RemoteTrailers = new List<MediaUrl>(); - LocalTrailerIds = new List<Guid>(); - RemoteTrailerIds = new List<Guid>(); + RemoteTrailers = EmptyMediaUrlArray; + LocalTrailerIds = EmptyGuidArray; + RemoteTrailerIds = EmptyGuidArray; + AirDays = new DayOfWeek[] { }; } + public DayOfWeek[] AirDays { get; set; } + public string AirTime { get; set; } + [IgnoreDataMember] public override bool SupportsAddingToPlaylist { @@ -62,10 +64,10 @@ namespace MediaBrowser.Controller.Entities.TV } } - public List<Guid> LocalTrailerIds { get; set; } - public List<Guid> RemoteTrailerIds { get; set; } + public Guid[] LocalTrailerIds { get; set; } + public Guid[] RemoteTrailerIds { get; set; } - public List<MediaUrl> RemoteTrailers { get; set; } + public MediaUrl[] RemoteTrailers { get; set; } /// <summary> /// airdate, dvd or absolute @@ -77,16 +79,6 @@ namespace MediaBrowser.Controller.Entities.TV /// </summary> /// <value>The status.</value> public SeriesStatus? Status { get; set; } - /// <summary> - /// Gets or sets the air days. - /// </summary> - /// <value>The air days.</value> - public List<DayOfWeek> AirDays { get; set; } - /// <summary> - /// Gets or sets the air time. - /// </summary> - /// <value>The air time.</value> - public string AirTime { get; set; } /// <summary> /// Gets or sets the date last episode added. @@ -160,12 +152,8 @@ namespace MediaBrowser.Controller.Entities.TV IncludeItemTypes = new[] { typeof(Season).Name }, IsVirtualItem = false, Limit = 0, - DtoOptions = new Dto.DtoOptions + DtoOptions = new Dto.DtoOptions(false) { - Fields = new List<ItemFields> - { - - }, EnableImages = false } }); @@ -181,19 +169,15 @@ namespace MediaBrowser.Controller.Entities.TV { AncestorWithPresentationUniqueKey = null, SeriesPresentationUniqueKey = seriesKey, - DtoOptions = new Dto.DtoOptions + DtoOptions = new Dto.DtoOptions(false) { - Fields = new List<ItemFields> - { - - }, EnableImages = false } }; if (query.IncludeItemTypes.Length == 0) { - query.IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name }; + query.IncludeItemTypes = new[] { typeof(Episode).Name }; } query.IsVirtualItem = false; query.Limit = 0; @@ -225,32 +209,29 @@ namespace MediaBrowser.Controller.Entities.TV return list; } - /// <summary> - /// Gets the trailer ids. - /// </summary> - /// <returns>List<Guid>.</returns> - public List<Guid> GetTrailerIds() - { - var list = LocalTrailerIds.ToList(); - list.AddRange(RemoteTrailerIds); - return list; - } - [IgnoreDataMember] public bool ContainsEpisodesWithoutSeasonFolders { get { - return Children.OfType<Video>().Any(); + var children = Children; + foreach (var child in children) + { + if (child is Video) + { + return true; + } + } + return false; } } - public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) + public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren) { return GetSeasons(user, new DtoOptions(true)); } - public IEnumerable<Season> GetSeasons(User user, DtoOptions options) + public List<BaseItem> GetSeasons(User user, DtoOptions options) { var query = new InternalItemsQuery(user) { @@ -259,7 +240,7 @@ namespace MediaBrowser.Controller.Entities.TV SetSeasonQueryOptions(query, user); - return LibraryManager.GetItemList(query).Cast<Season>(); + return LibraryManager.GetItemList(query); } private void SetSeasonQueryOptions(InternalItemsQuery query, User user) @@ -271,20 +252,12 @@ namespace MediaBrowser.Controller.Entities.TV query.AncestorWithPresentationUniqueKey = null; query.SeriesPresentationUniqueKey = seriesKey; query.IncludeItemTypes = new[] { typeof(Season).Name }; - query.SortBy = new[] {ItemSortBy.SortName}; + query.OrderBy = new[] { ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Ascending)).ToArray(); - if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes) - { - query.IsVirtualItem = false; - } - else if (!config.DisplayMissingEpisodes) + if (!config.DisplayMissingEpisodes) { query.IsMissing = false; } - else if (!config.DisplayUnairedEpisodes) - { - query.IsVirtualUnaired = false; - } } protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) @@ -302,9 +275,9 @@ namespace MediaBrowser.Controller.Entities.TV query.AncestorWithPresentationUniqueKey = null; query.SeriesPresentationUniqueKey = seriesKey; - if (query.SortBy.Length == 0) + if (query.OrderBy.Length == 0) { - query.SortBy = new[] { ItemSortBy.SortName }; + query.OrderBy = new[] { ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Ascending)).ToArray(); } if (query.IncludeItemTypes.Length == 0) { @@ -319,7 +292,7 @@ namespace MediaBrowser.Controller.Entities.TV return LibraryManager.GetItemsResult(query); } - public IEnumerable<Episode> GetEpisodes(User user, DtoOptions options) + public IEnumerable<BaseItem> GetEpisodes(User user, DtoOptions options) { var seriesKey = GetUniqueSeriesKey(this); @@ -328,31 +301,22 @@ namespace MediaBrowser.Controller.Entities.TV AncestorWithPresentationUniqueKey = null, SeriesPresentationUniqueKey = seriesKey, IncludeItemTypes = new[] { typeof(Episode).Name, typeof(Season).Name }, - SortBy = new[] { ItemSortBy.SortName }, + OrderBy = new[] { ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Ascending)).ToArray(), DtoOptions = options }; var config = user.Configuration; - if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes) - { - query.IsVirtualItem = false; - } - else if (!config.DisplayMissingEpisodes) + if (!config.DisplayMissingEpisodes) { query.IsMissing = false; } - else if (!config.DisplayUnairedEpisodes) - { - query.IsVirtualUnaired = false; - } - var allItems = LibraryManager.GetItemList(query).ToList(); + var allItems = LibraryManager.GetItemList(query); var allSeriesEpisodes = allItems.OfType<Episode>().ToList(); var allEpisodes = allItems.OfType<Season>() .SelectMany(i => i.GetEpisodes(this, user, allSeriesEpisodes, options)) - .Reverse() - .ToList(); + .Reverse(); // Specials could appear twice based on above - once in season 0, once in the aired season // This depends on settings for that series @@ -365,20 +329,22 @@ namespace MediaBrowser.Controller.Entities.TV { // Refresh bottom up, children first, then the boxset // By then hopefully the movies within will have Tmdb collection values - var items = GetRecursiveChildren().ToList(); + var items = GetRecursiveChildren(); - var seasons = items.OfType<Season>().ToList(); - var otherItems = items.Except(seasons).ToList(); - - var totalItems = seasons.Count + otherItems.Count; + var totalItems = items.Count; var numComplete = 0; // Refresh current item await RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); // Refresh seasons - foreach (var item in seasons) + foreach (var item in items) { + if (!(item is Season)) + { + continue; + } + cancellationToken.ThrowIfCancellationRequested(); await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); @@ -390,8 +356,13 @@ namespace MediaBrowser.Controller.Entities.TV } // Refresh episodes and other children - foreach (var item in otherItems) + foreach (var item in items) { + if ((item is Season)) + { + continue; + } + cancellationToken.ThrowIfCancellationRequested(); var skipItem = false; @@ -425,7 +396,7 @@ namespace MediaBrowser.Controller.Entities.TV await ProviderManager.RefreshSingleItem(this, refreshOptions, cancellationToken).ConfigureAwait(false); } - public IEnumerable<Episode> GetSeasonEpisodes(Season parentSeason, User user, DtoOptions options) + public List<BaseItem> GetSeasonEpisodes(Season parentSeason, User user, DtoOptions options) { var queryFromSeries = ConfigurationManager.Configuration.DisplaySpecialsWithinSeasons; @@ -439,32 +410,24 @@ namespace MediaBrowser.Controller.Entities.TV AncestorWithPresentationUniqueKey = queryFromSeries ? null : seriesKey, SeriesPresentationUniqueKey = queryFromSeries ? seriesKey : null, IncludeItemTypes = new[] { typeof(Episode).Name }, - SortBy = new[] { ItemSortBy.SortName }, + OrderBy = new[] { ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Ascending)).ToArray(), DtoOptions = options }; if (user != null) { var config = user.Configuration; - if (!config.DisplayMissingEpisodes && !config.DisplayUnairedEpisodes) - { - query.IsVirtualItem = false; - } - else if (!config.DisplayMissingEpisodes) + if (!config.DisplayMissingEpisodes) { query.IsMissing = false; } - else if (!config.DisplayUnairedEpisodes) - { - query.IsVirtualUnaired = false; - } } - var allItems = LibraryManager.GetItemList(query).OfType<Episode>(); + var allItems = LibraryManager.GetItemList(query); return GetSeasonEpisodes(parentSeason, user, allItems, options); } - public IEnumerable<Episode> GetSeasonEpisodes(Season parentSeason, User user, IEnumerable<Episode> allSeriesEpisodes, DtoOptions options) + public List<BaseItem> GetSeasonEpisodes(Season parentSeason, User user, IEnumerable<BaseItem> allSeriesEpisodes, DtoOptions options) { if (allSeriesEpisodes == null) { @@ -475,14 +438,13 @@ namespace MediaBrowser.Controller.Entities.TV var sortBy = (parentSeason.IndexNumber ?? -1) == 0 ? ItemSortBy.SortName : ItemSortBy.AiredEpisodeOrder; - return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending) - .Cast<Episode>(); + return LibraryManager.Sort(episodes, user, new[] { sortBy }, SortOrder.Ascending).ToList(); } /// <summary> /// Filters the episodes by season. /// </summary> - public static IEnumerable<Episode> FilterEpisodesBySeason(IEnumerable<Episode> episodes, Season parentSeason, bool includeSpecials) + public static IEnumerable<BaseItem> FilterEpisodesBySeason(IEnumerable<BaseItem> episodes, Season parentSeason, bool includeSpecials) { var seasonNumber = parentSeason.IndexNumber; var seasonPresentationKey = GetUniqueSeriesKey(parentSeason); @@ -491,7 +453,9 @@ namespace MediaBrowser.Controller.Entities.TV return episodes.Where(episode => { - var currentSeasonNumber = supportSpecialsInSeason ? episode.AiredSeasonNumber : episode.ParentIndexNumber; + var episodeItem = (Episode)episode; + + var currentSeasonNumber = supportSpecialsInSeason ? episodeItem.AiredSeasonNumber : episode.ParentIndexNumber; if (currentSeasonNumber.HasValue && seasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber.Value) { return true; @@ -502,7 +466,7 @@ namespace MediaBrowser.Controller.Entities.TV return true; } - var season = episode.Season; + var season = episodeItem.Season; return season != null && string.Equals(GetUniqueSeriesKey(season), seasonPresentationKey, StringComparison.OrdinalIgnoreCase); }); } diff --git a/MediaBrowser.Controller/Entities/TagExtensions.cs b/MediaBrowser.Controller/Entities/TagExtensions.cs index 0e1df72cd..e5d8f35d9 100644 --- a/MediaBrowser.Controller/Entities/TagExtensions.cs +++ b/MediaBrowser.Controller/Entities/TagExtensions.cs @@ -1,5 +1,7 @@ using System; +using System.Collections.Generic; using System.Linq; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.Entities { @@ -12,9 +14,21 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("name"); } - if (!item.Tags.Contains(name, StringComparer.OrdinalIgnoreCase)) + var current = item.Tags; + + if (!current.Contains(name, StringComparer.OrdinalIgnoreCase)) { - item.Tags.Add(name); + if (current.Length == 0) + { + item.Tags = new[] { name }; + } + else + { + var list = current.ToArray(current.Length + 1); + list[list.Length - 1] = name; + + item.Tags = list; + } } } } diff --git a/MediaBrowser.Controller/Entities/Trailer.cs b/MediaBrowser.Controller/Entities/Trailer.cs index 99acce164..c5144aadf 100644 --- a/MediaBrowser.Controller/Entities/Trailer.cs +++ b/MediaBrowser.Controller/Entities/Trailer.cs @@ -47,7 +47,7 @@ namespace MediaBrowser.Controller.Entities info.IsLocalTrailer = TrailerTypes.Contains(TrailerType.LocalTrailer); - if (!DetectIsInMixedFolder() && LocationType == LocationType.FileSystem) + if (!IsInMixedFolder && LocationType == LocationType.FileSystem) { info.Name = System.IO.Path.GetFileName(ContainingFolderPath); } @@ -73,7 +73,7 @@ namespace MediaBrowser.Controller.Entities else { // Try to get the year from the folder name - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { info = LibraryManager.ParseName(System.IO.Path.GetFileName(ContainingFolderPath)); diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index d5d229bb3..3c89037cc 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -5,7 +5,6 @@ using MediaBrowser.Model.Connect; using MediaBrowser.Model.Serialization; using MediaBrowser.Model.Users; using System; -using System.Linq; using System.Threading; using System.Threading.Tasks; @@ -166,7 +165,7 @@ namespace MediaBrowser.Controller.Entities } } } - + return _policy; } set { _policy = value; } @@ -195,24 +194,24 @@ namespace MediaBrowser.Controller.Entities var oldConfigurationDirectory = ConfigurationDirectoryPath; // Exceptions will be thrown if these paths already exist - if (FileSystem.DirectoryExists(newConfigDirectory)) + if (FileSystem.DirectoryExists(newConfigDirectory)) { FileSystem.DeleteDirectory(newConfigDirectory, true); } - if (FileSystem.DirectoryExists(oldConfigurationDirectory)) + if (FileSystem.DirectoryExists(oldConfigurationDirectory)) { - FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory); + FileSystem.MoveDirectory(oldConfigurationDirectory, newConfigDirectory); } else { - FileSystem.CreateDirectory(newConfigDirectory); + FileSystem.CreateDirectory(newConfigDirectory); } } Name = newName; - return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)) + return RefreshMetadata(new MetadataRefreshOptions(new DirectoryService(Logger, FileSystem)) { ReplaceAllMetadata = true, ImageRefreshMode = ImageRefreshMode.FullRefresh, @@ -224,7 +223,8 @@ namespace MediaBrowser.Controller.Entities public override Task UpdateToRepository(ItemUpdateType updateReason, CancellationToken cancellationToken) { - return UserManager.UpdateUser(this); + UserManager.UpdateUser(this); + return Task.FromResult(true); } /// <summary> @@ -279,7 +279,14 @@ namespace MediaBrowser.Controller.Entities return true; } - return schedules.Any(i => IsParentalScheduleAllowed(i, date)); + foreach (var i in schedules) + { + if (IsParentalScheduleAllowed(i, date)) + { + return true; + } + } + return false; } private bool IsParentalScheduleAllowed(AccessSchedule schedule, DateTime date) @@ -304,7 +311,14 @@ namespace MediaBrowser.Controller.Entities public bool IsFolderGrouped(Guid id) { - return Configuration.GroupedFolders.Select(i => new Guid(i)).Contains(id); + foreach (var i in Configuration.GroupedFolders) + { + if (new Guid(i) == id) + { + return true; + } + } + return false; } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/UserRootFolder.cs b/MediaBrowser.Controller/Entities/UserRootFolder.cs index d35156345..2ed3bf20f 100644 --- a/MediaBrowser.Controller/Entities/UserRootFolder.cs +++ b/MediaBrowser.Controller/Entities/UserRootFolder.cs @@ -24,7 +24,7 @@ namespace MediaBrowser.Controller.Entities { if (_childrenIds == null) { - var list = base.LoadChildren().ToList(); + var list = base.LoadChildren(); _childrenIds = list.Select(i => i.Id).ToList(); return list; } @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Entities public override int GetChildCount(User user) { - return GetChildren(user, true).Count(); + return GetChildren(user, true).Count; } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/UserView.cs b/MediaBrowser.Controller/Entities/UserView.cs index 0d2d69c94..66174034d 100644 --- a/MediaBrowser.Controller/Entities/UserView.cs +++ b/MediaBrowser.Controller/Entities/UserView.cs @@ -4,9 +4,9 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.Querying; using System; using System.Collections.Generic; +using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; -using System.Linq; using MediaBrowser.Controller.Dto; namespace MediaBrowser.Controller.Entities @@ -60,7 +60,7 @@ namespace MediaBrowser.Controller.Entities public override int GetChildCount(User user) { - return GetChildren(user, true).Count(); + return GetChildren(user, true).Count; } protected override QueryResult<BaseItem> GetItemsInternal(InternalItemsQuery query) @@ -80,9 +80,9 @@ namespace MediaBrowser.Controller.Entities .GetUserItems(parent, this, ViewType, query).Result; } - public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) + public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren) { - var result = GetItems(new InternalItemsQuery + var result = GetItemList(new InternalItemsQuery { User = user, EnableTotalRecordCount = false, @@ -90,7 +90,7 @@ namespace MediaBrowser.Controller.Entities }); - return result.Items; + return result.ToList(); } public override bool CanDelete() @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Entities public override IEnumerable<BaseItem> GetRecursiveChildren(User user, InternalItemsQuery query) { - var result = GetItems(new InternalItemsQuery + var result = GetItemList(new InternalItemsQuery { User = user, Recursive = true, @@ -117,7 +117,7 @@ namespace MediaBrowser.Controller.Entities }); - return result.Items.Where(i => UserViewBuilder.FilterItem(i, query)); + return result.Where(i => UserViewBuilder.FilterItem(i, query)); } protected override IEnumerable<BaseItem> GetEligibleChildrenForRecursiveChildren(User user) diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 91e24caeb..3ab82a103 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -397,7 +397,7 @@ namespace MediaBrowser.Controller.Entities }, query.DtoOptions).Select(i => i.Item1 ?? i.Item2.FirstOrDefault()).Where(i => i != null); - query.SortBy = new string[] { }; + query.OrderBy = new Tuple<string, SortOrder>[] { }; return PostFilterAndSort(items, parent, null, query, false, true); } @@ -507,8 +507,7 @@ namespace MediaBrowser.Controller.Entities private QueryResult<BaseItem> GetMovieLatest(Folder parent, User user, InternalItemsQuery query) { - query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName }; - query.SortOrder = SortOrder.Descending; + query.OrderBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Descending)).ToArray(); query.Recursive = true; query.Parent = parent; @@ -521,8 +520,7 @@ namespace MediaBrowser.Controller.Entities private QueryResult<BaseItem> GetMovieResume(Folder parent, User user, InternalItemsQuery query) { - query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName }; - query.SortOrder = SortOrder.Descending; + query.OrderBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Descending)).ToArray(); query.IsResumable = true; query.Recursive = true; query.Parent = parent; @@ -533,7 +531,7 @@ namespace MediaBrowser.Controller.Entities return ConvertToResult(_libraryManager.GetItemList(query)); } - private QueryResult<BaseItem> ConvertToResult(IEnumerable<BaseItem> items) + private QueryResult<BaseItem> ConvertToResult(List<BaseItem> items) { var arr = items.ToArray(); return new QueryResult<BaseItem> @@ -633,8 +631,7 @@ namespace MediaBrowser.Controller.Entities private QueryResult<BaseItem> GetTvLatest(Folder parent, User user, InternalItemsQuery query) { - query.SortBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName }; - query.SortOrder = SortOrder.Descending; + query.OrderBy = new[] { ItemSortBy.DateCreated, ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Descending)).ToArray(); query.Recursive = true; query.Parent = parent; @@ -663,8 +660,7 @@ namespace MediaBrowser.Controller.Entities private QueryResult<BaseItem> GetTvResume(Folder parent, User user, InternalItemsQuery query) { - query.SortBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName }; - query.SortOrder = SortOrder.Descending; + query.OrderBy = new[] { ItemSortBy.DatePlayed, ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Descending)).ToArray(); query.IsResumable = true; query.Recursive = true; query.Parent = parent; @@ -779,7 +775,6 @@ namespace MediaBrowser.Controller.Entities items = FilterVirtualEpisodes(items, query.IsMissing, - query.IsVirtualUnaired, query.IsUnaired); if (collapseBoxSetItems && user != null) @@ -790,7 +785,7 @@ namespace MediaBrowser.Controller.Entities // This must be the last filter if (!string.IsNullOrEmpty(query.AdjacentTo)) { - items = FilterForAdjacency(items, query.AdjacentTo); + items = FilterForAdjacency(items.ToList(), query.AdjacentTo); } return SortAndPage(items, totalRecordLimit, query, libraryManager, enableSorting); @@ -1065,7 +1060,6 @@ namespace MediaBrowser.Controller.Entities private static IEnumerable<BaseItem> FilterVirtualEpisodes( IEnumerable<BaseItem> items, bool? isMissing, - bool? isVirtualUnaired, bool? isUnaired) { if (isMissing.HasValue) @@ -1096,20 +1090,6 @@ namespace MediaBrowser.Controller.Entities }); } - if (isVirtualUnaired.HasValue) - { - var val = isVirtualUnaired.Value; - items = items.Where(i => - { - var e = i as Episode; - if (e != null) - { - return e.IsVirtualUnaired == val; - } - return true; - }); - } - return items; } @@ -1120,9 +1100,9 @@ namespace MediaBrowser.Controller.Entities { items = items.DistinctBy(i => i.GetPresentationUniqueKey(), StringComparer.OrdinalIgnoreCase); - if (query.SortBy.Length > 0) + if (query.OrderBy.Length > 0) { - items = libraryManager.Sort(items, query.User, query.SortBy, query.SortOrder); + items = libraryManager.Sort(items, query.User, query.OrderBy); } var itemsArray = totalRecordLimit.HasValue ? items.Take(totalRecordLimit.Value).ToArray() : items.ToArray(); @@ -1387,8 +1367,8 @@ namespace MediaBrowser.Controller.Entities if (movie != null) { var ok = filterValue - ? movie.SpecialFeatureIds.Count > 0 - : movie.SpecialFeatureIds.Count == 0; + ? movie.SpecialFeatureIds.Length > 0 + : movie.SpecialFeatureIds.Length == 0; if (!ok) { @@ -1463,7 +1443,7 @@ namespace MediaBrowser.Controller.Entities { var filterValue = query.HasThemeSong.Value; - var themeCount = item.ThemeSongIds.Count; + var themeCount = item.ThemeSongIds.Length; var ok = filterValue ? themeCount > 0 : themeCount == 0; if (!ok) @@ -1476,7 +1456,7 @@ namespace MediaBrowser.Controller.Entities { var filterValue = query.HasThemeVideo.Value; - var themeCount = item.ThemeVideoIds.Count; + var themeCount = item.ThemeVideoIds.Length; var ok = filterValue ? themeCount > 0 : themeCount == 0; if (!ok) @@ -1674,15 +1654,6 @@ namespace MediaBrowser.Controller.Entities } } - if (query.AirDays.Length > 0) - { - var ok = new[] { item }.OfType<Series>().Any(p => p.AirDays != null && query.AirDays.Any(d => p.AirDays.Contains(d))); - if (!ok) - { - return false; - } - } - if (query.SeriesStatuses.Length > 0) { var ok = new[] { item }.OfType<Series>().Any(p => p.Status.HasValue && query.SeriesStatuses.Contains(p.Status.Value)); @@ -1788,10 +1759,8 @@ namespace MediaBrowser.Controller.Entities return _userViewManager.GetUserSubView(parent.Id.ToString("N"), type, sortName, CancellationToken.None); } - public static IEnumerable<BaseItem> FilterForAdjacency(IEnumerable<BaseItem> items, string adjacentToId) + public static IEnumerable<BaseItem> FilterForAdjacency(List<BaseItem> list, string adjacentToId) { - var list = items.ToList(); - var adjacentToIdGuid = new Guid(adjacentToId); var adjacentToItem = list.FirstOrDefault(i => i.Id == adjacentToIdGuid); diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index c5d9b9203..ffb601dc4 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -16,6 +16,7 @@ using MediaBrowser.Controller.Channels; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.Entities { @@ -30,9 +31,9 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public string PrimaryVersionId { get; set; } - public List<string> AdditionalParts { get; set; } - public List<string> LocalAlternateVersions { get; set; } - public List<LinkedChild> LinkedAlternateVersions { get; set; } + public string[] AdditionalParts { get; set; } + public string[] LocalAlternateVersions { get; set; } + public LinkedChild[] LinkedAlternateVersions { get; set; } [IgnoreDataMember] public override bool SupportsPlayedStatus @@ -77,15 +78,6 @@ namespace MediaBrowser.Controller.Entities } } - [IgnoreDataMember] - protected override bool SupportsIsInMixedFolderDetection - { - get - { - return true; - } - } - public override string CreatePresentationUniqueKey() { if (!string.IsNullOrWhiteSpace(PrimaryVersionId)) @@ -121,7 +113,7 @@ namespace MediaBrowser.Controller.Entities /// Gets or sets the subtitle paths. /// </summary> /// <value>The subtitle paths.</value> - public List<string> SubtitleFiles { get; set; } + public string[] SubtitleFiles { get; set; } /// <summary> /// Gets or sets a value indicating whether this instance has subtitles. @@ -157,18 +149,23 @@ namespace MediaBrowser.Controller.Entities /// <value>The video3 D format.</value> public Video3DFormat? Video3DFormat { get; set; } - /// <summary> - /// If the video is a folder-rip, this will hold the file list for the largest playlist - /// </summary> - public List<string> PlayableStreamFileNames { get; set; } - - /// <summary> - /// Gets the playable stream files. - /// </summary> - /// <returns>List{System.String}.</returns> - public List<string> GetPlayableStreamFiles() + public string[] GetPlayableStreamFileNames() { - return GetPlayableStreamFiles(Path); + var videoType = VideoType; + + if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.BluRay) + { + videoType = VideoType.BluRay; + } + else if (videoType == VideoType.Iso && IsoType == Model.Entities.IsoType.Dvd) + { + videoType = VideoType.Dvd; + } + else + { + return new string[] { }; + } + return MediaEncoder.GetPlayableStreamFileNames(Path, videoType); } /// <summary> @@ -179,17 +176,15 @@ namespace MediaBrowser.Controller.Entities public Video() { - PlayableStreamFileNames = new List<string>(); - AdditionalParts = new List<string>(); - LocalAlternateVersions = new List<string>(); - SubtitleFiles = new List<string>(); - LinkedAlternateVersions = new List<LinkedChild>(); + AdditionalParts = EmptyStringArray; + LocalAlternateVersions = EmptyStringArray; + SubtitleFiles = EmptyStringArray; + LinkedAlternateVersions = EmptyLinkedChildArray; } public override bool CanDownload() { - if (VideoType == VideoType.HdDvd || VideoType == VideoType.Dvd || - VideoType == VideoType.BluRay) + if (VideoType == VideoType.Dvd || VideoType == VideoType.BluRay) { return false; } @@ -218,20 +213,20 @@ namespace MediaBrowser.Controller.Entities return item.MediaSourceCount; } } - return LinkedAlternateVersions.Count + LocalAlternateVersions.Count + 1; + return LinkedAlternateVersions.Length + LocalAlternateVersions.Length + 1; } } [IgnoreDataMember] public bool IsStacked { - get { return AdditionalParts.Count > 0; } + get { return AdditionalParts.Length > 0; } } [IgnoreDataMember] public bool HasLocalAlternateVersions { - get { return LocalAlternateVersions.Count > 0; } + get { return LocalAlternateVersions.Length > 0; } } public IEnumerable<Guid> GetAdditionalPartIds() @@ -245,6 +240,41 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] + public override SourceType SourceType + { + get + { + if (IsActiveRecording()) + { + return SourceType.LiveTV; + } + + return base.SourceType; + } + } + + protected bool IsActiveRecording() + { + return LiveTvManager.GetActiveRecordingInfo(Path) != null; + } + + public override bool CanDelete() + { + if (IsActiveRecording()) + { + return false; + } + + return base.CanDelete(); + } + + [IgnoreDataMember] + public bool IsCompleteMedia + { + get { return !IsActiveRecording(); } + } + + [IgnoreDataMember] protected virtual bool EnableDefaultVideoUserDataKeys { get @@ -339,8 +369,7 @@ namespace MediaBrowser.Controller.Entities if (!IsPlaceHolder) { - if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd || - VideoType == VideoType.HdDvd) + if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd) { return Path; } @@ -357,7 +386,7 @@ namespace MediaBrowser.Controller.Entities { if (LocationType == LocationType.FileSystem) { - if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd || VideoType == VideoType.HdDvd) + if (VideoType == VideoType.BluRay || VideoType == VideoType.Dvd) { return System.IO.Path.GetFileName(Path); } @@ -395,18 +424,27 @@ namespace MediaBrowser.Controller.Entities return base.IsValidFromResolver(newItem); } - /// <summary> - /// Gets the playable stream files. - /// </summary> - /// <param name="rootPath">The root path.</param> - /// <returns>List{System.String}.</returns> - public List<string> GetPlayableStreamFiles(string rootPath) + public static string[] QueryPlayableStreamFiles(string rootPath, VideoType videoType) { - var allFiles = FileSystem.GetFilePaths(rootPath, true).ToList(); - - return PlayableStreamFileNames.Select(name => allFiles.FirstOrDefault(f => string.Equals(System.IO.Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) - .Where(f => !string.IsNullOrEmpty(f)) - .ToList(); + if (videoType == VideoType.Dvd) + { + return FileSystem.GetFiles(rootPath, new[] { ".vob" }, false, true) + .OrderByDescending(i => i.Length) + .ThenBy(i => i.FullName) + .Take(1) + .Select(i => i.FullName) + .ToArray(); + } + if (videoType == VideoType.BluRay) + { + return FileSystem.GetFiles(rootPath, new[] { ".m2ts" }, false, true) + .OrderByDescending(i => i.Length) + .ThenBy(i => i.FullName) + .Take(1) + .Select(i => i.FullName) + .ToArray(); + } + return new string[] { }; } /// <summary> @@ -500,7 +538,7 @@ namespace MediaBrowser.Controller.Entities public override IEnumerable<FileSystemMetadata> GetDeletePaths() { - if (!DetectIsInMixedFolder()) + if (!IsInMixedFolder) { return new[] { new FileSystemMetadata @@ -514,17 +552,12 @@ namespace MediaBrowser.Controller.Entities return base.GetDeletePaths(); } - public IEnumerable<MediaStream> GetMediaStreams() + public List<MediaStream> GetMediaStreams() { - var mediaSource = GetMediaSources(false) - .FirstOrDefault(); - - if (mediaSource == null) + return MediaSourceManager.GetMediaStreams(new MediaStreamQuery { - return new List<MediaStream>(); - } - - return mediaSource.MediaStreams; + ItemId = Id + }); } public virtual MediaStream GetDefaultVideoStream() @@ -572,7 +605,7 @@ namespace MediaBrowser.Controller.Entities return list; } - public virtual IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public virtual List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { if (SourceType == SourceType.Channel) { @@ -593,6 +626,14 @@ namespace MediaBrowser.Controller.Entities var list = GetAllVideosForMediaSources(); var result = list.Select(i => GetVersionInfo(enablePathSubstitution, i.Item1, i.Item2)).ToList(); + if (IsActiveRecording()) + { + foreach (var mediaSource in result) + { + mediaSource.Type = MediaSourceType.Placeholder; + } + } + return result.OrderBy(i => { if (i.VideoType == VideoType.VideoFile) @@ -619,8 +660,7 @@ namespace MediaBrowser.Controller.Entities throw new ArgumentNullException("media"); } - var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id) - .ToList(); + var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id); var locationType = media.LocationType; @@ -639,7 +679,6 @@ namespace MediaBrowser.Controller.Entities Size = media.Size, Timestamp = media.Timestamp, Type = type, - PlayableStreamFileNames = media.PlayableStreamFileNames.ToList(), SupportsDirectStream = media.VideoType == VideoType.VideoFile, IsRemote = media.IsShortcut }; @@ -714,10 +753,6 @@ namespace MediaBrowser.Controller.Entities { terms.Add("DVD"); } - else if (video.VideoType == VideoType.HdDvd) - { - terms.Add("HD-DVD"); - } else if (video.VideoType == VideoType.Iso) { if (video.IsoType.HasValue) @@ -781,7 +816,7 @@ namespace MediaBrowser.Controller.Entities } } - return string.Join("/", terms.ToArray()); + return string.Join("/", terms.ToArray(terms.Count)); } } diff --git a/MediaBrowser.Controller/Entities/Year.cs b/MediaBrowser.Controller/Entities/Year.cs index 61b1a3b1a..7d820b007 100644 --- a/MediaBrowser.Controller/Entities/Year.cs +++ b/MediaBrowser.Controller/Entities/Year.cs @@ -1,7 +1,6 @@ using System; using System.Collections.Generic; using System.Globalization; -using System.Linq; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities diff --git a/MediaBrowser.Controller/IO/FileData.cs b/MediaBrowser.Controller/IO/FileData.cs index 97b778d0c..880b3a0ce 100644 --- a/MediaBrowser.Controller/IO/FileData.cs +++ b/MediaBrowser.Controller/IO/FileData.cs @@ -3,7 +3,6 @@ using MediaBrowser.Controller.Providers; using MediaBrowser.Model.Logging; using System; using System.Collections.Generic; - using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.IO @@ -13,6 +12,17 @@ namespace MediaBrowser.Controller.IO /// </summary> public static class FileData { + private static Dictionary<string, FileSystemMetadata> GetFileSystemDictionary(FileSystemMetadata[] list) + { + var dict = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase); + + foreach (var file in list) + { + dict[file.FullName] = file; + } + return dict; + } + /// <summary> /// Gets the filtered file system entries. /// </summary> @@ -25,7 +35,7 @@ namespace MediaBrowser.Controller.IO /// <param name="resolveShortcuts">if set to <c>true</c> [resolve shortcuts].</param> /// <returns>Dictionary{System.StringFileSystemInfo}.</returns> /// <exception cref="System.ArgumentNullException">path</exception> - public static Dictionary<string, FileSystemMetadata> GetFilteredFileSystemEntries(IDirectoryService directoryService, + public static FileSystemMetadata[] GetFilteredFileSystemEntries(IDirectoryService directoryService, string path, IFileSystem fileSystem, ILogger logger, @@ -42,13 +52,13 @@ namespace MediaBrowser.Controller.IO throw new ArgumentNullException("args"); } + var entries = directoryService.GetFileSystemEntries(path); + if (!resolveShortcuts && flattenFolderDepth == 0) { - return directoryService.GetFileSystemDictionary(path); + return entries; } - var entries = directoryService.GetFileSystemEntries(path); - var dict = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase); foreach (var entry in entries) @@ -87,7 +97,7 @@ namespace MediaBrowser.Controller.IO { foreach (var child in GetFilteredFileSystemEntries(directoryService, fullName, fileSystem, logger, args, flattenFolderDepth: flattenFolderDepth - 1, resolveShortcuts: resolveShortcuts)) { - dict[child.Key] = child.Value; + dict[child.FullName] = child; } } else @@ -96,7 +106,15 @@ namespace MediaBrowser.Controller.IO } } - return dict; + var returnResult = new FileSystemMetadata[dict.Count]; + var index = 0; + var values = dict.Values; + foreach (var value in values) + { + returnResult[index] = value; + index++; + } + return returnResult; } } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index b726c267c..05845102b 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -181,15 +181,8 @@ namespace MediaBrowser.Controller.Library /// <param name="sortBy">The sort by.</param> /// <param name="sortOrder">The sort order.</param> /// <returns>IEnumerable{BaseItem}.</returns> - IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<string> sortBy, - SortOrder sortOrder); - - /// <summary> - /// Ensure supplied item has only one instance throughout - /// </summary> - /// <param name="item">The item.</param> - /// <returns>The proper instance to the item</returns> - BaseItem GetOrAddByReferenceItem(BaseItem item); + IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<string> sortBy, SortOrder sortOrder); + IEnumerable<BaseItem> Sort(IEnumerable<BaseItem> items, User user, IEnumerable<Tuple<string, SortOrder>> orderBy); /// <summary> /// Gets the user root folder. @@ -202,16 +195,14 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="item">The item.</param> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task CreateItem(BaseItem item, CancellationToken cancellationToken); + void CreateItem(BaseItem item, CancellationToken cancellationToken); /// <summary> /// Creates the items. /// </summary> /// <param name="items">The items.</param> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken); + void CreateItems(IEnumerable<BaseItem> items, CancellationToken cancellationToken); /// <summary> /// Updates the item. @@ -284,7 +275,7 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="paths">The paths.</param> /// <returns>IEnumerable{System.String}.</returns> - IEnumerable<FileSystemMetadata> NormalizeRootPathList(IEnumerable<FileSystemMetadata> paths); + List<FileSystemMetadata> NormalizeRootPathList(IEnumerable<FileSystemMetadata> paths); /// <summary> /// Registers the item. @@ -310,7 +301,7 @@ namespace MediaBrowser.Controller.Library /// <param name="sortName">Name of the sort.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task<UserView>.</returns> - Task<UserView> GetNamedView(User user, + UserView GetNamedView(User user, string name, string parentId, string viewType, @@ -326,7 +317,7 @@ namespace MediaBrowser.Controller.Library /// <param name="sortName">Name of the sort.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task<UserView>.</returns> - Task<UserView> GetNamedView(User user, + UserView GetNamedView(User user, string name, string viewType, string sortName, @@ -370,7 +361,7 @@ namespace MediaBrowser.Controller.Library /// <param name="sortName">Name of the sort.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task<UserView>.</returns> - Task<UserView> GetShadowView(BaseItem parent, + UserView GetShadowView(BaseItem parent, string viewType, string sortName, CancellationToken cancellationToken); @@ -478,8 +469,7 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="item">The item.</param> /// <param name="people">The people.</param> - /// <returns>Task.</returns> - Task UpdatePeople(BaseItem item, List<PersonInfo> people); + void UpdatePeople(BaseItem item, List<PersonInfo> people); /// <summary> /// Gets the item ids. @@ -520,21 +510,21 @@ namespace MediaBrowser.Controller.Library /// <param name="image">The image.</param> /// <param name="imageIndex">Index of the image.</param> /// <returns>Task.</returns> - Task<ItemImageInfo> ConvertImageToLocal(IHasImages item, ItemImageInfo image, int imageIndex); + Task<ItemImageInfo> ConvertImageToLocal(IHasMetadata item, ItemImageInfo image, int imageIndex); /// <summary> /// Gets the items. /// </summary> /// <param name="query">The query.</param> /// <returns>QueryResult<BaseItem>.</returns> - IEnumerable<BaseItem> GetItemList(InternalItemsQuery query); + List<BaseItem> GetItemList(InternalItemsQuery query); - IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, bool allowExternalContent); + List<BaseItem> GetItemList(InternalItemsQuery query, bool allowExternalContent); /// <summary> /// Gets the items. /// </summary> - IEnumerable<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents); + List<BaseItem> GetItemList(InternalItemsQuery query, List<BaseItem> parents); /// <summary> /// Gets the items result. diff --git a/MediaBrowser.Controller/Library/IMediaSourceManager.cs b/MediaBrowser.Controller/Library/IMediaSourceManager.cs index 2f8f37789..204033e1d 100644 --- a/MediaBrowser.Controller/Library/IMediaSourceManager.cs +++ b/MediaBrowser.Controller/Library/IMediaSourceManager.cs @@ -24,19 +24,19 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="itemId">The item identifier.</param> /// <returns>IEnumerable<MediaStream>.</returns> - IEnumerable<MediaStream> GetMediaStreams(Guid itemId); + List<MediaStream> GetMediaStreams(Guid itemId); /// <summary> /// Gets the media streams. /// </summary> /// <param name="mediaSourceId">The media source identifier.</param> /// <returns>IEnumerable<MediaStream>.</returns> - IEnumerable<MediaStream> GetMediaStreams(string mediaSourceId); + List<MediaStream> GetMediaStreams(string mediaSourceId); /// <summary> /// Gets the media streams. /// </summary> /// <param name="query">The query.</param> /// <returns>IEnumerable<MediaStream>.</returns> - IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query); + List<MediaStream> GetMediaStreams(MediaStreamQuery query); /// <summary> /// Gets the playack media sources. @@ -56,7 +56,7 @@ namespace MediaBrowser.Controller.Library /// <param name="enablePathSubstitution">if set to <c>true</c> [enable path substitution].</param> /// <param name="user">The user.</param> /// <returns>IEnumerable<MediaSourceInfo>.</returns> - IEnumerable<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user = null); + List<MediaSourceInfo> GetStaticMediaSources(IHasMediaSources item, bool enablePathSubstitution, User user = null); /// <summary> /// Gets the static media source. diff --git a/MediaBrowser.Controller/Library/IMusicManager.cs b/MediaBrowser.Controller/Library/IMusicManager.cs index 95ba671b4..535e6df7e 100644 --- a/MediaBrowser.Controller/Library/IMusicManager.cs +++ b/MediaBrowser.Controller/Library/IMusicManager.cs @@ -10,16 +10,16 @@ namespace MediaBrowser.Controller.Library /// <summary> /// Gets the instant mix from song. /// </summary> - IEnumerable<Audio> GetInstantMixFromItem(BaseItem item, User user, DtoOptions dtoOptions); - + List<BaseItem> GetInstantMixFromItem(BaseItem item, User user, DtoOptions dtoOptions); + /// <summary> /// Gets the instant mix from artist. /// </summary> - IEnumerable<Audio> GetInstantMixFromArtist(MusicArtist artist, User user, DtoOptions dtoOptions); - + List<BaseItem> GetInstantMixFromArtist(MusicArtist artist, User user, DtoOptions dtoOptions); + /// <summary> /// Gets the instant mix from genre. /// </summary> - IEnumerable<Audio> GetInstantMixFromGenres(IEnumerable<string> genres, User user, DtoOptions dtoOptions); + List<BaseItem> GetInstantMixFromGenres(IEnumerable<string> genres, User user, DtoOptions dtoOptions); } } diff --git a/MediaBrowser.Controller/Library/IUserDataManager.cs b/MediaBrowser.Controller/Library/IUserDataManager.cs index e9954545e..cd4bd2e34 100644 --- a/MediaBrowser.Controller/Library/IUserDataManager.cs +++ b/MediaBrowser.Controller/Library/IUserDataManager.cs @@ -4,7 +4,6 @@ using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using System; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Model.Querying; namespace MediaBrowser.Controller.Library @@ -28,7 +27,7 @@ namespace MediaBrowser.Controller.Library /// <param name="reason">The reason.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); + void SaveUserData(Guid userId, IHasUserData item, UserItemData userData, UserDataSaveReason reason, CancellationToken cancellationToken); UserItemData GetUserData(IHasUserData user, IHasUserData item); @@ -40,14 +39,14 @@ namespace MediaBrowser.Controller.Library /// </summary> UserItemDataDto GetUserDataDto(IHasUserData item, User user); - UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, List<ItemFields> fields); + UserItemDataDto GetUserDataDto(IHasUserData item, BaseItemDto itemDto, User user, ItemFields[] fields); /// <summary> /// Get all user data for the given user /// </summary> /// <param name="userId"></param> /// <returns></returns> - IEnumerable<UserItemData> GetAllUserData(Guid userId); + List<UserItemData> GetAllUserData(Guid userId); /// <summary> /// Save the all provided user data for the given user @@ -56,7 +55,7 @@ namespace MediaBrowser.Controller.Library /// <param name="userData"></param> /// <param name="cancellationToken"></param> /// <returns></returns> - Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken); + void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken); /// <summary> /// Updates playstate for an item and returns true or false indicating if it was played to completion diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index ef68d2560..6da3e53aa 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -91,7 +91,7 @@ namespace MediaBrowser.Controller.Library /// <param name="user">The user.</param> /// <exception cref="System.ArgumentNullException">user</exception> /// <exception cref="System.ArgumentException"></exception> - Task UpdateUser(User user); + void UpdateUser(User user); /// <summary> /// Creates the user. @@ -116,7 +116,7 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="user">The user.</param> /// <returns>Task.</returns> - Task ResetPassword(User user); + void ResetPassword(User user); /// <summary> /// Gets the offline user dto. @@ -130,7 +130,7 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="user">The user.</param> /// <returns>Task.</returns> - Task ResetEasyPassword(User user); + void ResetEasyPassword(User user); /// <summary> /// Changes the password. @@ -138,7 +138,7 @@ namespace MediaBrowser.Controller.Library /// <param name="user">The user.</param> /// <param name="newPasswordSha1">The new password sha1.</param> /// <returns>Task.</returns> - Task ChangePassword(User user, string newPasswordSha1); + void ChangePassword(User user, string newPasswordSha1); /// <summary> /// Changes the easy password. @@ -146,7 +146,7 @@ namespace MediaBrowser.Controller.Library /// <param name="user">The user.</param> /// <param name="newPasswordSha1">The new password sha1.</param> /// <returns>Task.</returns> - Task ChangeEasyPassword(User user, string newPasswordSha1); + void ChangeEasyPassword(User user, string newPasswordSha1); /// <summary> /// Gets the user dto. @@ -179,7 +179,7 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="pin">The pin.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns> - Task<PinRedeemResult> RedeemPasswordResetPin(string pin); + PinRedeemResult RedeemPasswordResetPin(string pin); /// <summary> /// Gets the user policy. @@ -201,14 +201,14 @@ namespace MediaBrowser.Controller.Library /// <param name="userId">The user identifier.</param> /// <param name="newConfiguration">The new configuration.</param> /// <returns>Task.</returns> - Task UpdateConfiguration(string userId, UserConfiguration newConfiguration); + void UpdateConfiguration(string userId, UserConfiguration newConfiguration); /// <summary> /// Updates the user policy. /// </summary> /// <param name="userId">The user identifier.</param> /// <param name="userPolicy">The user policy.</param> - Task UpdateUserPolicy(string userId, UserPolicy userPolicy); + void UpdateUserPolicy(string userId, UserPolicy userPolicy); /// <summary> /// Makes the valid username. diff --git a/MediaBrowser.Controller/Library/IUserViewManager.cs b/MediaBrowser.Controller/Library/IUserViewManager.cs index b46ece49d..76182c641 100644 --- a/MediaBrowser.Controller/Library/IUserViewManager.cs +++ b/MediaBrowser.Controller/Library/IUserViewManager.cs @@ -11,7 +11,7 @@ namespace MediaBrowser.Controller.Library { public interface IUserViewManager { - Task<IEnumerable<Folder>> GetUserViews(UserViewQuery query, CancellationToken cancellationToken); + Task<Folder[]> GetUserViews(UserViewQuery query, CancellationToken cancellationToken); Task<UserView> GetUserSubView(string name, string parentId, string type, string sortName, CancellationToken cancellationToken); diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 76b6d8768..56392eee7 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -4,7 +4,6 @@ using System; using System.Collections.Generic; using System.IO; using System.Linq; - using MediaBrowser.Controller.Configuration; using MediaBrowser.Controller.IO; using MediaBrowser.Model.Configuration; @@ -40,20 +39,7 @@ namespace MediaBrowser.Controller.Library /// Gets the file system children. /// </summary> /// <value>The file system children.</value> - public IEnumerable<FileSystemMetadata> FileSystemChildren - { - get - { - var dict = FileSystemDictionary; - - if (dict == null) - { - return new List<FileSystemMetadata>(); - } - - return dict.Values; - } - } + public FileSystemMetadata[] FileSystemChildren { get; set; } public LibraryOptions LibraryOptions { get; set; } @@ -63,12 +49,6 @@ namespace MediaBrowser.Controller.Library } /// <summary> - /// Gets or sets the file system dictionary. - /// </summary> - /// <value>The file system dictionary.</value> - public Dictionary<string, FileSystemMetadata> FileSystemDictionary { get; set; } - - /// <summary> /// Gets or sets the parent. /// </summary> /// <value>The parent.</value> @@ -153,7 +133,14 @@ namespace MediaBrowser.Controller.Library // Not officially supported but in some cases we can handle it. if (item == null) { - item = parent.GetParents().OfType<T>().FirstOrDefault(); + var parents = parent.GetParents(); + foreach (var currentParent in parents) + { + if (currentParent is T) + { + return true; + } + } } return item != null; @@ -186,12 +173,12 @@ namespace MediaBrowser.Controller.Library /// Gets the physical locations. /// </summary> /// <value>The physical locations.</value> - public IEnumerable<string> PhysicalLocations + public string[] PhysicalLocations { get { var paths = string.IsNullOrWhiteSpace(Path) ? new string[] { } : new[] { Path }; - return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations); + return AdditionalLocations == null ? paths : paths.Concat(AdditionalLocations).ToArray(); } } @@ -224,13 +211,11 @@ namespace MediaBrowser.Controller.Library throw new ArgumentNullException(); } - if (FileSystemDictionary != null) + foreach (var file in FileSystemChildren) { - FileSystemMetadata entry; - - if (FileSystemDictionary.TryGetValue(path, out entry)) + if (string.Equals(file.FullName, path, StringComparison.Ordinal)) { - return entry; + return file; } } diff --git a/MediaBrowser.Controller/Library/NameExtensions.cs b/MediaBrowser.Controller/Library/NameExtensions.cs index 693b7b221..bab334a6d 100644 --- a/MediaBrowser.Controller/Library/NameExtensions.cs +++ b/MediaBrowser.Controller/Library/NameExtensions.cs @@ -1,7 +1,5 @@ using System; using System.Collections.Generic; -using System.Globalization; -using System.Linq; using MediaBrowser.Controller.Extensions; using MediaBrowser.Model.Extensions; @@ -9,25 +7,6 @@ namespace MediaBrowser.Controller.Library { public static class NameExtensions { - public static bool EqualsAny(IEnumerable<string> names, string x) - { - x = NormalizeForComparison(x); - - return names.Any(y => string.Compare(x, y, StringComparison.OrdinalIgnoreCase) == 0); - //return names.Any(y => string.Compare(x, y, CultureInfo.InvariantCulture, CompareOptions.IgnoreCase | CompareOptions.IgnoreNonSpace) == 0); - } - - private static string NormalizeForComparison(string name) - { - if (name == null) - { - return string.Empty; - } - - return name; - //return name.RemoveDiacritics(); - } - private static string RemoveDiacritics(string name) { if (name == null) @@ -44,27 +23,4 @@ namespace MediaBrowser.Controller.Library return names.DistinctBy(RemoveDiacritics, StringComparer.OrdinalIgnoreCase); } } - - public class DistinctNameComparer : IComparer<string>, IEqualityComparer<string> - { - public int Compare(string x, string y) - { - if (string.IsNullOrWhiteSpace(x) && string.IsNullOrWhiteSpace(y)) - { - return 0; - } - - return string.Compare(x.RemoveDiacritics(), y.RemoveDiacritics(), StringComparison.OrdinalIgnoreCase); - } - - public bool Equals(string x, string y) - { - return Compare(x, y) == 0; - } - - public int GetHashCode(string obj) - { - return (obj ?? string.Empty).GetHashCode(); - } - } } diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index 29421ebaf..7c82ec293 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -22,13 +22,13 @@ namespace MediaBrowser.Controller.Library /// </summary> /// <param name="day">The day.</param> /// <returns>List{DayOfWeek}.</returns> - public static List<DayOfWeek> GetAirDays(string day) + public static DayOfWeek[] GetAirDays(string day) { if (!string.IsNullOrWhiteSpace(day)) { if (day.Equals("Daily", StringComparison.OrdinalIgnoreCase)) { - return new List<DayOfWeek> + return new DayOfWeek[] { DayOfWeek.Sunday, DayOfWeek.Monday, @@ -44,13 +44,13 @@ namespace MediaBrowser.Controller.Library if (Enum.TryParse(day, true, out value)) { - return new List<DayOfWeek> + return new DayOfWeek[] { value }; } - return new List<DayOfWeek>(); + return new DayOfWeek[]{}; } return null; } diff --git a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs index 6682942ad..892a7d5b7 100644 --- a/MediaBrowser.Controller/LiveTv/ChannelInfo.cs +++ b/MediaBrowser.Controller/LiveTv/ChannelInfo.cs @@ -25,6 +25,8 @@ namespace MediaBrowser.Controller.LiveTv /// <value>The id of the channel.</value> public string Id { get; set; } + public string Path { get; set; } + public string TunerChannelId { get; set; } public string CallSign { get; set; } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 288b30278..42c31c629 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs @@ -109,7 +109,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="cancellationToken">The cancellation token.</param> /// <returns>QueryResult{RecordingInfoDto}.</returns> Task<QueryResult<BaseItemDto>> GetRecordings(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken); - Task<QueryResult<BaseItemDto>> GetRecordingSeries(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken); + QueryResult<BaseItemDto> GetRecordingSeries(RecordingQuery query, DtoOptions options, CancellationToken cancellationToken); /// <summary> /// Gets the timers. @@ -243,7 +243,7 @@ namespace MediaBrowser.Controller.LiveTv /// Gets the recommended programs internal. /// </summary> /// <returns>Task<QueryResult<LiveTvProgram>>.</returns> - Task<QueryResult<LiveTvProgram>> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken); + Task<QueryResult<BaseItem>> GetRecommendedProgramsInternal(RecommendedProgramQuery query, DtoOptions options, CancellationToken cancellationToken); /// <summary> /// Gets the live tv information. @@ -284,7 +284,7 @@ namespace MediaBrowser.Controller.LiveTv /// <summary> /// Gets the internal channels. /// </summary> - Task<QueryResult<LiveTvChannel>> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken); + Task<QueryResult<BaseItem>> GetInternalChannels(LiveTvChannelQuery query, DtoOptions dtoOptions, CancellationToken cancellationToken); /// <summary> /// Gets the internal recordings. @@ -316,7 +316,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="fields">The fields.</param> /// <param name="user">The user.</param> /// <returns>Task.</returns> - Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> programs, List<ItemFields> fields, User user = null); + Task AddInfoToProgramDto(List<Tuple<BaseItem, BaseItemDto>> programs, ItemFields[] fields, User user = null); /// <summary> /// Saves the tuner host. @@ -335,7 +335,7 @@ namespace MediaBrowser.Controller.LiveTv Task<TunerChannelMapping> SetChannelMapping(string providerId, string tunerChannelNumber, string providerChannelNumber); - TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, List<NameValuePair> mappings, List<ChannelInfo> providerChannels); + TunerChannelMapping GetTunerChannelMapping(ChannelInfo channel, NameValuePair[] mappings, List<ChannelInfo> providerChannels); /// <summary> /// Gets the lineups. @@ -360,7 +360,7 @@ namespace MediaBrowser.Controller.LiveTv /// <param name="items">The items.</param> /// <param name="options">The options.</param> /// <param name="user">The user.</param> - Task AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> items, DtoOptions options, User user); + void AddChannelInfo(List<Tuple<BaseItemDto, LiveTvChannel>> items, DtoOptions options, User user); /// <summary> /// Called when [recording file deleted]. @@ -384,5 +384,9 @@ namespace MediaBrowser.Controller.LiveTv string GetEmbyTvActiveRecordingPath(string id); Task<LiveStream> GetEmbyTvLiveStream(string id); + + ActiveRecordingInfo GetActiveRecordingInfo(string path); + + void AddInfoToRecordingDto(BaseItem item, BaseItemDto dto, ActiveRecordingInfo activeRecordingInfo, User user = null); } } diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs index 1bbd1a008..4b757f0b9 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs @@ -9,7 +9,7 @@ using System.Threading.Tasks; namespace MediaBrowser.Controller.LiveTv { - public interface ILiveTvRecording : IHasImages, IHasMediaSources, IHasUserData, IHasStartDate, IHasProgramAttributes + public interface ILiveTvRecording : IHasMetadata, IHasMediaSources, IHasUserData, IHasStartDate, IHasProgramAttributes { string ServiceName { get; set; } string ExternalId { get; set; } @@ -18,8 +18,6 @@ namespace MediaBrowser.Controller.LiveTv string Container { get; } - long? RunTimeTicks { get; set; } - string GetClientTypeName(); bool IsParentalAllowed(User user); @@ -36,8 +34,15 @@ namespace MediaBrowser.Controller.LiveTv string TimerId { get; set; } RecordingStatus Status { get; set; } DateTime? EndDate { get; set; } - DateTime DateLastSaved { get; set; } DateTime DateCreated { get; set; } - DateTime DateModified { get; set; } + } + + public class ActiveRecordingInfo + { + public string Id { get; set; } + public string Path { get; set; } + public TimerInfo Timer { get; set; } + public ProgramInfo Program { get; set; } + public CancellationTokenSource CancellationTokenSource { get; set; } } } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index 9f8234402..c29d73253 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -6,7 +6,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; @@ -151,9 +150,9 @@ namespace MediaBrowser.Controller.LiveTv return user.Policy.EnableLiveTvManagement; } - public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public override List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { - var list = base.GetMediaSources(enablePathSubstitution).ToList(); + var list = base.GetMediaSources(enablePathSubstitution); foreach (var mediaSource in list) { diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index 898ea9ff4..4a93d0399 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -122,7 +122,7 @@ namespace MediaBrowser.Controller.LiveTv return new List<BaseItem>(); } - public IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { var list = new List<MediaSourceInfo>(); @@ -144,6 +144,11 @@ namespace MediaBrowser.Controller.LiveTv return list; } + public List<MediaStream> GetMediaStreams() + { + return new List<MediaStream>(); + } + protected override string GetInternalMetadataPath(string basePath) { return System.IO.Path.Combine(basePath, "livetv", Id.ToString("N"), "metadata"); diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 9f55a9ff2..1607dbcba 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -9,7 +9,6 @@ using MediaBrowser.Common.Configuration; using MediaBrowser.Model.Entities; using MediaBrowser.Model.Providers; using MediaBrowser.Model.Serialization; -using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.LiveTv { @@ -48,22 +47,19 @@ namespace MediaBrowser.Controller.LiveTv return list; } + private static string EmbyServiceName = "Emby"; public override double? GetDefaultPrimaryImageAspectRatio() { - if (IsMovie) + var serviceName = ServiceName; + if (!IsMovie && !string.Equals(serviceName, EmbyServiceName, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(serviceName)) { - double value = 2; - value /= 3; - - return value; + return null; } - else - { - double value = 2; - value /= 3; - return value; - } + double value = 2; + value /= 3; + + return value; } [IgnoreDataMember] @@ -227,7 +223,7 @@ namespace MediaBrowser.Controller.LiveTv public LiveTvProgramLookupInfo GetLookupInfo() { var info = GetItemLookupInfo<LiveTvProgramLookupInfo>(); - info.IsMovie = IsMovie; + info.IsMovie = IsMovie; return info; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index c29d3dc47..950949f37 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -5,7 +5,6 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.LiveTv; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Serialization; using System.Threading.Tasks; using MediaBrowser.Controller.Library; @@ -54,15 +53,6 @@ namespace MediaBrowser.Controller.LiveTv } [IgnoreDataMember] - protected override bool SupportsIsInMixedFolderDetection - { - get - { - return false; - } - } - - [IgnoreDataMember] public override bool SupportsPlayedStatus { get @@ -159,9 +149,9 @@ namespace MediaBrowser.Controller.LiveTv return user.Policy.EnableLiveTvManagement; } - public override IEnumerable<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) + public override List<MediaSourceInfo> GetMediaSources(bool enablePathSubstitution) { - var list = base.GetMediaSources(enablePathSubstitution).ToList(); + var list = base.GetMediaSources(enablePathSubstitution); foreach (var mediaSource in list) { diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 0b94c85fa..a0002241d 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -109,6 +109,9 @@ namespace MediaBrowser.Controller.LiveTv public bool IsKids { get; set; } public bool IsSports { get; set; } public bool IsNews { get; set; } + public bool IsSeries { get; set; } + public bool IsLive { get; set; } + public bool IsPremiere { get; set; } public int? ProductionYear { get; set; } public string EpisodeTitle { get; set; } public DateTime? OriginalAirDate { get; set; } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 9cba48b74..5ef763b62 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -99,8 +99,6 @@ <Compile Include="Entities\GameSystem.cs" /> <Compile Include="Entities\IHasAspectRatio.cs" /> <Compile Include="Entities\IHasDisplayOrder.cs" /> - <Compile Include="Entities\IHasId.cs" /> - <Compile Include="Entities\IHasImages.cs" /> <Compile Include="Entities\IHasMediaSources.cs" /> <Compile Include="Entities\IHasProgramAttributes.cs" /> <Compile Include="Entities\IHasScreenshots.cs" /> @@ -168,7 +166,6 @@ <Compile Include="LiveTv\TimerEventInfo.cs" /> <Compile Include="LiveTv\TimerInfo.cs" /> <Compile Include="LiveTv\TunerChannelMapping.cs" /> - <Compile Include="MediaEncoding\ChapterImageRefreshOptions.cs" /> <Compile Include="MediaEncoding\EncodingHelper.cs" /> <Compile Include="MediaEncoding\EncodingJobInfo.cs" /> <Compile Include="MediaEncoding\EncodingJobOptions.cs" /> @@ -176,7 +173,6 @@ <Compile Include="MediaEncoding\ImageEncodingOptions.cs" /> <Compile Include="MediaEncoding\IMediaEncoder.cs" /> <Compile Include="MediaEncoding\ISubtitleEncoder.cs" /> - <Compile Include="MediaEncoding\JobLogger.cs" /> <Compile Include="MediaEncoding\MediaInfoRequest.cs" /> <Compile Include="MediaEncoding\MediaStreamSelector.cs" /> <Compile Include="Net\AuthenticatedAttribute.cs" /> @@ -187,14 +183,12 @@ <Compile Include="Net\IHttpResultFactory.cs" /> <Compile Include="Net\IHttpServer.cs" /> <Compile Include="Net\IServerManager.cs" /> - <Compile Include="Net\IServiceRequest.cs" /> <Compile Include="Net\ISessionContext.cs" /> <Compile Include="Net\IWebSocket.cs" /> <Compile Include="Net\IWebSocketConnection.cs" /> <Compile Include="Net\IWebSocketListener.cs" /> <Compile Include="Net\LoggedAttribute.cs" /> <Compile Include="Net\SecurityException.cs" /> - <Compile Include="Net\ServiceRequest.cs" /> <Compile Include="Net\StaticResultOptions.cs" /> <Compile Include="Net\WebSocketConnectEventArgs.cs" /> <Compile Include="Net\WebSocketMessageInfo.cs" /> @@ -339,7 +333,6 @@ <Compile Include="Sync\ISyncDataProvider.cs" /> <Compile Include="Sync\ISyncManager.cs" /> <Compile Include="Sync\ISyncProvider.cs" /> - <Compile Include="Sync\ISyncRepository.cs" /> <Compile Include="Sync\SyncedFileInfo.cs" /> <Compile Include="Sync\SyncedItemProgress.cs" /> <Compile Include="TV\ITVSeriesManager.cs" /> diff --git a/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs b/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs deleted file mode 100644 index e11bd6cdf..000000000 --- a/MediaBrowser.Controller/MediaEncoding/ChapterImageRefreshOptions.cs +++ /dev/null @@ -1,17 +0,0 @@ -using MediaBrowser.Controller.Entities; -using MediaBrowser.Model.Entities; -using System.Collections.Generic; - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class ChapterImageRefreshOptions - { - public Video Video { get; set; } - - public List<ChapterInfo> Chapters { get; set; } - - public bool SaveChapters { get; set; } - - public bool ExtractImages { get; set; } - } -} diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index bd7bbb6fe..531711b55 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -4,13 +4,14 @@ using System.Globalization; using System.IO; using System.Linq; using System.Threading; -using MediaBrowser.Controller.Configuration; +using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Configuration; using MediaBrowser.Model.Dlna; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Entities; using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; +using MediaBrowser.Model.Extensions; namespace MediaBrowser.Controller.MediaEncoding { @@ -19,14 +20,12 @@ namespace MediaBrowser.Controller.MediaEncoding private readonly CultureInfo _usCulture = new CultureInfo("en-US"); private readonly IMediaEncoder _mediaEncoder; - private readonly IServerConfigurationManager _config; private readonly IFileSystem _fileSystem; private readonly ISubtitleEncoder _subtitleEncoder; - public EncodingHelper(IMediaEncoder mediaEncoder, IServerConfigurationManager config, IFileSystem fileSystem, ISubtitleEncoder subtitleEncoder) + public EncodingHelper(IMediaEncoder mediaEncoder, IFileSystem fileSystem, ISubtitleEncoder subtitleEncoder) { _mediaEncoder = mediaEncoder; - _config = config; _fileSystem = fileSystem; _subtitleEncoder = subtitleEncoder; } @@ -151,10 +150,13 @@ namespace MediaBrowser.Controller.MediaEncoding public string GetInputFormat(string container) { - if (string.Equals(container, "mkv", StringComparison.OrdinalIgnoreCase)) + if (string.IsNullOrWhiteSpace(container)) { - return "matroska"; + return null; } + + container = container.Replace("mkv", "matroska", StringComparison.OrdinalIgnoreCase); + if (string.Equals(container, "ts", StringComparison.OrdinalIgnoreCase)) { return "mpegts"; @@ -209,6 +211,10 @@ namespace MediaBrowser.Controller.MediaEncoding { return null; } + if (string.Equals(container, "rtp", StringComparison.OrdinalIgnoreCase)) + { + return null; + } // Seeing reported failures here, not sure yet if this is related to specfying input format if (string.Equals(container, "m4v", StringComparison.OrdinalIgnoreCase)) @@ -772,6 +778,11 @@ namespace MediaBrowser.Controller.MediaEncoding return false; } + if (state.EnableMpDecimate) + { + return false; + } + if (videoStream.IsInterlaced) { if (request.DeInterlace) @@ -923,19 +934,6 @@ namespace MediaBrowser.Controller.MediaEncoding return false; } - // Video bitrate must fall within requested value - if (request.AudioBitRate.HasValue) - { - if (!audioStream.BitRate.HasValue || audioStream.BitRate.Value <= 0) - { - return false; - } - if (audioStream.BitRate.Value > request.AudioBitRate.Value) - { - return false; - } - } - // Channels must fall within requested value var channels = request.AudioChannels ?? request.MaxAudioChannels; if (channels.HasValue) @@ -963,6 +961,19 @@ namespace MediaBrowser.Controller.MediaEncoding } } + // Video bitrate must fall within requested value + if (request.AudioBitRate.HasValue) + { + if (!audioStream.BitRate.HasValue || audioStream.BitRate.Value <= 0) + { + return false; + } + if (audioStream.BitRate.Value > request.AudioBitRate.Value) + { + return false; + } + } + return request.EnableAutoStreamCopy; } @@ -1443,6 +1454,11 @@ namespace MediaBrowser.Controller.MediaEncoding } } + if (state.EnableMpDecimate) + { + filters.Add("mpdecimate,setpts=N/FRAME_RATE/TB"); + } + if (filters.Count > 0) { output += string.Format(" -vf \"{0}\"", string.Join(",", filters.ToArray())); @@ -1515,7 +1531,7 @@ namespace MediaBrowser.Controller.MediaEncoding { var inputModifier = string.Empty; - var numInputFiles = state.PlayableStreamFileNames.Count > 0 ? state.PlayableStreamFileNames.Count : 1; + var numInputFiles = state.PlayableStreamFileNames.Length > 0 ? state.PlayableStreamFileNames.Length : 1; var probeSizeArgument = GetProbeSizeArgument(numInputFiles); string analyzeDurationArgument; @@ -1625,26 +1641,6 @@ namespace MediaBrowser.Controller.MediaEncoding inputModifier += " -f " + inputFormat; } } - - // Only do this for video files due to sometimes unpredictable codec names coming from BDInfo - if (state.VideoType == VideoType.VideoFile && state.RunTimeTicks.HasValue && string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType)) - { - foreach (var stream in state.MediaSource.MediaStreams) - { - if (!stream.IsExternal && stream.Type != MediaStreamType.Subtitle) - { - if (!string.IsNullOrWhiteSpace(stream.Codec) && stream.Index != -1) - { - var decoder = GetDecoderFromCodec(stream.Codec); - - if (!string.IsNullOrWhiteSpace(decoder)) - { - inputModifier += " -codec:" + stream.Index.ToString(_usCulture) + " " + decoder; - } - } - } - } - } } if (state.MediaSource.RequiresLooping) @@ -1675,14 +1671,33 @@ namespace MediaBrowser.Controller.MediaEncoding state.RunTimeTicks = mediaSource.RunTimeTicks; state.RemoteHttpHeaders = mediaSource.RequiredHttpHeaders; + state.IsoType = mediaSource.IsoType; + if (mediaSource.VideoType.HasValue) { state.VideoType = mediaSource.VideoType.Value; - } - - state.IsoType = mediaSource.IsoType; - state.PlayableStreamFileNames = mediaSource.PlayableStreamFileNames.ToList(); + if (mediaSource.VideoType.Value == VideoType.BluRay || mediaSource.VideoType.Value == VideoType.Dvd) + { + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, mediaSource.VideoType.Value).Select(Path.GetFileName).ToArray(); + } + else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.BluRay) + { + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.BluRay).Select(Path.GetFileName).ToArray(); + } + else if (mediaSource.VideoType.Value == VideoType.Iso && state.IsoType == IsoType.Dvd) + { + state.PlayableStreamFileNames = Video.QueryPlayableStreamFiles(state.MediaPath, VideoType.Dvd).Select(Path.GetFileName).ToArray(); + } + else + { + state.PlayableStreamFileNames = new string[]{}; + } + } + else + { + state.PlayableStreamFileNames = new string[] { }; + } if (mediaSource.Timestamp.HasValue) { @@ -1702,7 +1717,8 @@ namespace MediaBrowser.Controller.MediaEncoding state.InputAudioSync = "1"; } - if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(mediaSource.Container, "wma", StringComparison.OrdinalIgnoreCase) || + string.Equals(mediaSource.Container, "asf", StringComparison.OrdinalIgnoreCase)) { // Seeing some stuttering when transcoding wma to audio-only HLS state.InputAudioSync = "1"; @@ -1776,50 +1792,54 @@ namespace MediaBrowser.Controller.MediaEncoding return null; } + return GetVideoDecoder(state.MediaSource.VideoType ?? VideoType.VideoFile, state.VideoStream, encodingOptions); + } + + public string GetVideoDecoder(VideoType videoType, MediaStream videoStream, EncodingOptions encodingOptions) + { // Only use alternative encoders for video files. // When using concat with folder rips, if the mfx session fails to initialize, ffmpeg will be stuck retrying and will not exit gracefully // Since transcoding of folder rips is expiremental anyway, it's not worth adding additional variables such as this. - if (state.VideoType != VideoType.VideoFile) + if (videoType != VideoType.VideoFile) { return null; } - if (state.VideoStream != null && - !string.IsNullOrWhiteSpace(state.VideoStream.Codec) && - !string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType) && - encodingOptions.EnableHardwareDecoding) + if (videoStream != null && + !string.IsNullOrWhiteSpace(videoStream.Codec) && + !string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType)) { if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) { - switch (state.MediaSource.VideoStream.Codec.ToLower()) + switch (videoStream.Codec.ToLower()) { case "avc": case "h264": - if (_mediaEncoder.SupportsDecoder("h264_qsv")) + if (_mediaEncoder.SupportsDecoder("h264_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase)) { // qsv decoder does not support 10-bit input - if ((state.VideoStream.BitDepth ?? 8) > 8) + if ((videoStream.BitDepth ?? 8) > 8) { return null; } return "-c:v h264_qsv "; } break; - //case "hevc": - //case "h265": - // if (_mediaEncoder.SupportsDecoder("hevc_qsv")) - // { - // return "-c:v hevc_qsv "; - // } - // break; + case "hevc": + case "h265": + if (_mediaEncoder.SupportsDecoder("hevc_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("hevc", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v hevc_qsv "; + } + break; case "mpeg2video": - if (_mediaEncoder.SupportsDecoder("mpeg2_qsv")) + if (_mediaEncoder.SupportsDecoder("mpeg2_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase)) { return "-c:v mpeg2_qsv "; } break; case "vc1": - if (_mediaEncoder.SupportsDecoder("vc1_qsv")) + if (_mediaEncoder.SupportsDecoder("vc1_qsv") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase)) { return "-c:v vc1_qsv "; } @@ -1829,22 +1849,40 @@ namespace MediaBrowser.Controller.MediaEncoding else if (string.Equals(encodingOptions.HardwareAccelerationType, "nvenc", StringComparison.OrdinalIgnoreCase)) { - switch (state.MediaSource.VideoStream.Codec.ToLower()) + switch (videoStream.Codec.ToLower()) { case "avc": case "h264": - if (_mediaEncoder.SupportsDecoder("h264_cuvid")) + if (_mediaEncoder.SupportsDecoder("h264_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase)) { return "-c:v h264_cuvid "; } break; case "hevc": case "h265": - if (_mediaEncoder.SupportsDecoder("hevc_cuvid")) + if (_mediaEncoder.SupportsDecoder("hevc_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("hevc", StringComparer.OrdinalIgnoreCase)) { return "-c:v hevc_cuvid "; } break; + case "mpeg2video": + if (_mediaEncoder.SupportsDecoder("mpeg2_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg2video", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v mpeg2_cuvid "; + } + break; + case "vc1": + if (_mediaEncoder.SupportsDecoder("vc1_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("vc1", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v vc1_cuvid "; + } + break; + case "mpeg4": + if (_mediaEncoder.SupportsDecoder("mpeg4_cuvid") && encodingOptions.HardwareDecodingCodecs.Contains("mpeg4", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v mpeg4_cuvid "; + } + break; } } } @@ -2109,6 +2147,7 @@ namespace MediaBrowser.Controller.MediaEncoding var vn = string.Empty; var hasArt = !string.IsNullOrWhiteSpace(state.AlbumCoverPath); + hasArt = false; if (hasArt) { diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index b552579a8..e76217fda 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -27,7 +27,7 @@ namespace MediaBrowser.Controller.MediaEncoding public string MediaPath { get; set; } public bool IsInputVideo { get; set; } public IIsoMount IsoMount { get; set; } - public List<string> PlayableStreamFileNames { get; set; } + public string[] PlayableStreamFileNames { get; set; } public string OutputAudioCodec { get; set; } public int? OutputVideoBitrate { get; set; } public MediaStream SubtitleStream { get; set; } @@ -42,8 +42,8 @@ namespace MediaBrowser.Controller.MediaEncoding public bool ReadInputAtNativeFramerate { get; set; } - private List<TranscodeReason> _transcodeReasons = null; - public List<TranscodeReason> TranscodeReasons + private TranscodeReason[] _transcodeReasons = null; + public TranscodeReason[] TranscodeReasons { get { @@ -53,7 +53,7 @@ namespace MediaBrowser.Controller.MediaEncoding .Split(',') .Where(i => !string.IsNullOrWhiteSpace(i)) .Select(v => (TranscodeReason)Enum.Parse(typeof(TranscodeReason), v, true)) - .ToList(); + .ToArray(); } return _transcodeReasons; @@ -127,6 +127,11 @@ namespace MediaBrowser.Controller.MediaEncoding } } + public bool EnableMpDecimate + { + get { return MediaSource.EnableMpDecimate; } + } + public string AlbumCoverPath { get; set; } public string InputAudioSync { get; set; } @@ -164,7 +169,7 @@ namespace MediaBrowser.Controller.MediaEncoding _logger = logger; TranscodingType = jobType; RemoteHttpHeaders = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); - PlayableStreamFileNames = new List<string>(); + PlayableStreamFileNames = new string[]{}; SupportedAudioCodecs = new List<string>(); SupportedVideoCodecs = new List<string>(); SupportedSubtitleCodecs = new List<string>(); diff --git a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs index 8683a6af4..81269fe3f 100644 --- a/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs +++ b/MediaBrowser.Controller/MediaEncoding/IEncodingManager.cs @@ -1,5 +1,8 @@ -using System.Threading; +using System.Collections.Generic; +using System.Threading; using System.Threading.Tasks; +using MediaBrowser.Controller.Entities; +using MediaBrowser.Model.Entities; namespace MediaBrowser.Controller.MediaEncoding { @@ -8,9 +11,6 @@ namespace MediaBrowser.Controller.MediaEncoding /// <summary> /// Refreshes the chapter images. /// </summary> - /// <param name="options">The options.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task{System.Boolean}.</returns> - Task<bool> RefreshChapterImages(ChapterImageRefreshOptions options, CancellationToken cancellationToken); + Task<bool> RefreshChapterImages(Video video, List<ChapterInfo> chapters, bool extractImages, bool saveChapters, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 10d7b9a7e..31cd96c9a 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -1,9 +1,11 @@ using MediaBrowser.Model.Entities; using MediaBrowser.Model.MediaInfo; using System; +using System.Collections.Generic; using System.Threading; using System.Threading.Tasks; using MediaBrowser.Model.Dlna; +using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.MediaEncoding { @@ -39,29 +41,16 @@ namespace MediaBrowser.Controller.MediaEncoding /// <summary> /// Extracts the video image. /// </summary> - /// <param name="inputFiles">The input files.</param> - /// <param name="protocol">The protocol.</param> - /// <param name="threedFormat">The threed format.</param> - /// <param name="offset">The offset.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task{Stream}.</returns> - Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, Video3DFormat? threedFormat, TimeSpan? offset, CancellationToken cancellationToken); + Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, MediaStream videoStream, Video3DFormat? threedFormat, TimeSpan? offset, CancellationToken cancellationToken); - Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, int? imageStreamIndex, CancellationToken cancellationToken); + Task<string> ExtractVideoImage(string[] inputFiles, string container, MediaProtocol protocol, MediaStream imageStream, int? imageStreamIndex, CancellationToken cancellationToken); /// <summary> /// Extracts the video images on interval. /// </summary> - /// <param name="inputFiles">The input files.</param> - /// <param name="protocol">The protocol.</param> - /// <param name="threedFormat">The threed format.</param> - /// <param name="interval">The interval.</param> - /// <param name="targetDirectory">The target directory.</param> - /// <param name="filenamePrefix">The filename prefix.</param> - /// <param name="maxWidth">The maximum width.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> Task ExtractVideoImagesOnInterval(string[] inputFiles, + string container, + MediaStream videoStream, MediaProtocol protocol, Video3DFormat? threedFormat, TimeSpan interval, @@ -115,6 +104,8 @@ namespace MediaBrowser.Controller.MediaEncoding IProgress<double> progress, CancellationToken cancellationToken); + Task ConvertImage(string inputPath, string outputPath); + /// <summary> /// Escapes the subtitle filter path. /// </summary> @@ -129,5 +120,8 @@ namespace MediaBrowser.Controller.MediaEncoding void SetLogFilename(string name); void ClearLogFilename(); + + string[] GetPlayableStreamFileNames(string path, VideoType videoType); + IEnumerable<string> GetPrimaryPlaylistVobFiles(string path, IIsoMount isoMount, uint? titleNumber); } } diff --git a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs b/MediaBrowser.Controller/MediaEncoding/JobLogger.cs deleted file mode 100644 index 03e4f7771..000000000 --- a/MediaBrowser.Controller/MediaEncoding/JobLogger.cs +++ /dev/null @@ -1,149 +0,0 @@ -using MediaBrowser.Model.Extensions; -using MediaBrowser.Model.Logging; -using System; -using System.Globalization; -using System.IO; -using System.Linq; -using System.Text; - -namespace MediaBrowser.Controller.MediaEncoding -{ - public class JobLogger - { - private readonly CultureInfo _usCulture = new CultureInfo("en-US"); - private readonly ILogger _logger; - - public JobLogger(ILogger logger) - { - _logger = logger; - } - - public async void StartStreamingLog(EncodingJobInfo state, Stream source, Stream target) - { - try - { - using (var reader = new StreamReader(source)) - { - while (!reader.EndOfStream) - { - var line = await reader.ReadLineAsync().ConfigureAwait(false); - - ParseLogLine(line, state); - - var bytes = Encoding.UTF8.GetBytes(Environment.NewLine + line); - - await target.WriteAsync(bytes, 0, bytes.Length).ConfigureAwait(false); - await target.FlushAsync().ConfigureAwait(false); - } - } - } - catch (ObjectDisposedException) - { - // Don't spam the log. This doesn't seem to throw in windows, but sometimes under linux - } - catch (Exception ex) - { - _logger.ErrorException("Error reading ffmpeg log", ex); - } - } - - private void ParseLogLine(string line, EncodingJobInfo state) - { - float? framerate = null; - double? percent = null; - TimeSpan? transcodingPosition = null; - long? bytesTranscoded = null; - int? bitRate = null; - - var parts = line.Split(' '); - - var totalMs = state.RunTimeTicks.HasValue - ? TimeSpan.FromTicks(state.RunTimeTicks.Value).TotalMilliseconds - : 0; - - var startMs = state.BaseRequest.StartTimeTicks.HasValue - ? TimeSpan.FromTicks(state.BaseRequest.StartTimeTicks.Value).TotalMilliseconds - : 0; - - for (var i = 0; i < parts.Length; i++) - { - var part = parts[i]; - - if (string.Equals(part, "fps=", StringComparison.OrdinalIgnoreCase) && - (i + 1 < parts.Length)) - { - var rate = parts[i + 1]; - float val; - - if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val)) - { - framerate = val; - } - } - else if (state.RunTimeTicks.HasValue && - part.StartsWith("time=", StringComparison.OrdinalIgnoreCase)) - { - var time = part.Split(new[] { '=' }, 2).Last(); - TimeSpan val; - - if (TimeSpan.TryParse(time, _usCulture, out val)) - { - var currentMs = startMs + val.TotalMilliseconds; - - var percentVal = currentMs / totalMs; - percent = 100 * percentVal; - - transcodingPosition = val; - } - } - else if (part.StartsWith("size=", StringComparison.OrdinalIgnoreCase)) - { - var size = part.Split(new[] { '=' }, 2).Last(); - - int? scale = null; - if (size.IndexOf("kb", StringComparison.OrdinalIgnoreCase) != -1) - { - scale = 1024; - size = size.Replace("kb", string.Empty, StringComparison.OrdinalIgnoreCase); - } - - if (scale.HasValue) - { - long val; - - if (long.TryParse(size, NumberStyles.Any, _usCulture, out val)) - { - bytesTranscoded = val * scale.Value; - } - } - } - else if (part.StartsWith("bitrate=", StringComparison.OrdinalIgnoreCase)) - { - var rate = part.Split(new[] { '=' }, 2).Last(); - - int? scale = null; - if (rate.IndexOf("kbits/s", StringComparison.OrdinalIgnoreCase) != -1) - { - scale = 1024; - rate = rate.Replace("kbits/s", string.Empty, StringComparison.OrdinalIgnoreCase); - } - - if (scale.HasValue) - { - float val; - - if (float.TryParse(rate, NumberStyles.Any, _usCulture, out val)) - { - bitRate = (int)Math.Ceiling(val * scale.Value); - } - } - } - } - - if (framerate.HasValue || percent.HasValue) - { - state.ReportTranscodingProgress(transcodingPosition, framerate, percent, bytesTranscoded, bitRate); - } - } - } -} diff --git a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs index d5c85197f..70e4db84f 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaEncoderHelpers.cs @@ -1,12 +1,9 @@ using MediaBrowser.Model.IO; using MediaBrowser.Model.MediaInfo; using System; -using System.Collections.Generic; using System.IO; using System.Linq; -using MediaBrowser.Controller.IO; - namespace MediaBrowser.Controller.MediaEncoding { /// <summary> @@ -23,34 +20,34 @@ namespace MediaBrowser.Controller.MediaEncoding /// <param name="isoMount">The iso mount.</param> /// <param name="playableStreamFileNames">The playable stream file names.</param> /// <returns>System.String[][].</returns> - public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, List<string> playableStreamFileNames) + public static string[] GetInputArgument(IFileSystem fileSystem, string videoPath, MediaProtocol protocol, IIsoMount isoMount, string[] playableStreamFileNames) { - if (playableStreamFileNames.Count > 0) + if (playableStreamFileNames.Length > 0) { if (isoMount == null) { - return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames).ToArray(); + return GetPlayableStreamFiles(fileSystem, videoPath, playableStreamFileNames); } - return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames).ToArray(); + return GetPlayableStreamFiles(fileSystem, isoMount.MountedPath, playableStreamFileNames); } return new[] {videoPath}; } - private static List<string> GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, List<string> filenames) + private static string[] GetPlayableStreamFiles(IFileSystem fileSystem, string rootPath, string[] filenames) { - if (filenames.Count == 0) + if (filenames.Length == 0) { - return new List<string>(); + return new string[]{}; } var allFiles = fileSystem .GetFilePaths(rootPath, true) - .ToList(); + .ToArray(); return filenames.Select(name => allFiles.FirstOrDefault(f => string.Equals(Path.GetFileName(f), name, StringComparison.OrdinalIgnoreCase))) .Where(f => !string.IsNullOrEmpty(f)) - .ToList(); + .ToArray(); } } } diff --git a/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs b/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs index 0785ee29f..929f4e649 100644 --- a/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs +++ b/MediaBrowser.Controller/MediaEncoding/MediaInfoRequest.cs @@ -14,12 +14,12 @@ namespace MediaBrowser.Controller.MediaEncoding public DlnaProfileType MediaType { get; set; } public IIsoMount MountedIso { get; set; } public VideoType VideoType { get; set; } - public List<string> PlayableStreamFileNames { get; set; } + public string[] PlayableStreamFileNames { get; set; } public int AnalyzeDurationMs { get; set; } public MediaInfoRequest() { - PlayableStreamFileNames = new List<string>(); + PlayableStreamFileNames = new string[] { }; } } } diff --git a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs b/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs index b025011d7..ecbfaecea 100644 --- a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs +++ b/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs @@ -1,6 +1,4 @@ using System; -using System.Collections.Generic; -using System.Linq; using MediaBrowser.Model.Services; namespace MediaBrowser.Controller.Net @@ -27,6 +25,8 @@ namespace MediaBrowser.Controller.Net /// <value><c>true</c> if [allow before startup wizard]; otherwise, <c>false</c>.</value> public bool AllowBeforeStartupWizard { get; set; } + public bool AllowLocal { get; set; } + /// <summary> /// The request filter is executed before the service. /// </summary> @@ -35,9 +35,7 @@ namespace MediaBrowser.Controller.Net /// <param name="requestDto">The request DTO</param> public void RequestFilter(IRequest request, IResponse response, object requestDto) { - var serviceRequest = new ServiceRequest(request); - - AuthService.Authenticate(serviceRequest, this); + AuthService.Authenticate(request, this); } /// <summary> @@ -51,10 +49,9 @@ namespace MediaBrowser.Controller.Net get { return 0; } } - public IEnumerable<string> GetRoles() + public string[] GetRoles() { - return (Roles ?? string.Empty).Split(',') - .Where(i => !string.IsNullOrWhiteSpace(i)); + return (Roles ?? string.Empty).Split(new []{ ',' }, StringSplitOptions.RemoveEmptyEntries); } } @@ -62,7 +59,8 @@ namespace MediaBrowser.Controller.Net { bool EscapeParentalControl { get; } bool AllowBeforeStartupWizard { get; } + bool AllowLocal { get; } - IEnumerable<string> GetRoles(); + string[] GetRoles(); } } diff --git a/MediaBrowser.Controller/Net/IAuthService.cs b/MediaBrowser.Controller/Net/IAuthService.cs index dc298c8d9..361320250 100644 --- a/MediaBrowser.Controller/Net/IAuthService.cs +++ b/MediaBrowser.Controller/Net/IAuthService.cs @@ -1,9 +1,9 @@ - +using MediaBrowser.Model.Services; + namespace MediaBrowser.Controller.Net { public interface IAuthService { - void Authenticate(IServiceRequest request, - IAuthenticationAttributes authAttribtues); + void Authenticate(IRequest request, IAuthenticationAttributes authAttribtues); } } diff --git a/MediaBrowser.Controller/Net/IAuthorizationContext.cs b/MediaBrowser.Controller/Net/IAuthorizationContext.cs index bdaed6046..5a9d0aa30 100644 --- a/MediaBrowser.Controller/Net/IAuthorizationContext.cs +++ b/MediaBrowser.Controller/Net/IAuthorizationContext.cs @@ -1,4 +1,5 @@ - +using MediaBrowser.Model.Services; + namespace MediaBrowser.Controller.Net { public interface IAuthorizationContext @@ -15,6 +16,6 @@ namespace MediaBrowser.Controller.Net /// </summary> /// <param name="requestContext">The request context.</param> /// <returns>AuthorizationInfo.</returns> - AuthorizationInfo GetAuthorizationInfo(IServiceRequest requestContext); + AuthorizationInfo GetAuthorizationInfo(IRequest requestContext); } } diff --git a/MediaBrowser.Controller/Net/IHttpServer.cs b/MediaBrowser.Controller/Net/IHttpServer.cs index f319244da..f41572b45 100644 --- a/MediaBrowser.Controller/Net/IHttpServer.cs +++ b/MediaBrowser.Controller/Net/IHttpServer.cs @@ -13,13 +13,13 @@ namespace MediaBrowser.Controller.Net /// Gets the URL prefix. /// </summary> /// <value>The URL prefix.</value> - IEnumerable<string> UrlPrefixes { get; } + string[] UrlPrefixes { get; } /// <summary> /// Starts the specified server name. /// </summary> /// <param name="urlPrefixes">The URL prefixes.</param> - void StartServer(IEnumerable<string> urlPrefixes); + void StartServer(string[] urlPrefixes); /// <summary> /// Stops this instance. diff --git a/MediaBrowser.Controller/Net/IServerManager.cs b/MediaBrowser.Controller/Net/IServerManager.cs index 202df2982..a84c48c5b 100644 --- a/MediaBrowser.Controller/Net/IServerManager.cs +++ b/MediaBrowser.Controller/Net/IServerManager.cs @@ -15,7 +15,7 @@ namespace MediaBrowser.Controller.Net /// Starts this instance. /// </summary> /// <param name="urlPrefixes">The URL prefixes.</param> - void Start(IEnumerable<string> urlPrefixes); + void Start(string[] urlPrefixes); /// <summary> /// Sends a message to all clients currently connected via a web socket diff --git a/MediaBrowser.Controller/Net/IServiceRequest.cs b/MediaBrowser.Controller/Net/IServiceRequest.cs deleted file mode 100644 index ebc7e8d65..000000000 --- a/MediaBrowser.Controller/Net/IServiceRequest.cs +++ /dev/null @@ -1,14 +0,0 @@ -using System.Collections.Generic; -using MediaBrowser.Model.Services; - -namespace MediaBrowser.Controller.Net -{ - public interface IServiceRequest - { - string RemoteIp { get; } - QueryParamCollection Headers { get; } - QueryParamCollection QueryString { get; } - IDictionary<string,object> Items { get; } - void AddResponseHeader(string name, string value); - } -} diff --git a/MediaBrowser.Controller/Net/ISessionContext.cs b/MediaBrowser.Controller/Net/ISessionContext.cs index 167e17867..213a66dac 100644 --- a/MediaBrowser.Controller/Net/ISessionContext.cs +++ b/MediaBrowser.Controller/Net/ISessionContext.cs @@ -1,6 +1,7 @@ using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.Session; using System.Threading.Tasks; +using MediaBrowser.Model.Services; namespace MediaBrowser.Controller.Net { @@ -9,7 +10,7 @@ namespace MediaBrowser.Controller.Net Task<SessionInfo> GetSession(object requestContext); Task<User> GetUser(object requestContext); - Task<SessionInfo> GetSession(IServiceRequest requestContext); - Task<User> GetUser(IServiceRequest requestContext); + Task<SessionInfo> GetSession(IRequest requestContext); + Task<User> GetUser(IRequest requestContext); } } diff --git a/MediaBrowser.Controller/Net/LoggedAttribute.cs b/MediaBrowser.Controller/Net/LoggedAttribute.cs index 6a2a5e2e3..eb57392e2 100644 --- a/MediaBrowser.Controller/Net/LoggedAttribute.cs +++ b/MediaBrowser.Controller/Net/LoggedAttribute.cs @@ -30,10 +30,8 @@ namespace MediaBrowser.Controller.Net /// <param name="requestDto">The request DTO</param> public void Filter(IRequest request, IResponse response, object requestDto) { - var serviceRequest = new ServiceRequest(request); - //This code is executed before the service - var auth = AuthorizationContext.GetAuthorizationInfo(serviceRequest); + var auth = AuthorizationContext.GetAuthorizationInfo(request); if (auth != null) { diff --git a/MediaBrowser.Controller/Net/ServiceRequest.cs b/MediaBrowser.Controller/Net/ServiceRequest.cs deleted file mode 100644 index 1f72d0eb2..000000000 --- a/MediaBrowser.Controller/Net/ServiceRequest.cs +++ /dev/null @@ -1,42 +0,0 @@ -using System; -using System.Collections.Generic; -using System.Collections.Specialized; -using MediaBrowser.Model.Services; - -namespace MediaBrowser.Controller.Net -{ - public class ServiceRequest : IServiceRequest - { - private readonly IRequest _request; - - public ServiceRequest(IRequest request) - { - _request = request; - } - - public string RemoteIp - { - get { return _request.RemoteIp; } - } - - public QueryParamCollection Headers - { - get { return _request.Headers; } - } - - public QueryParamCollection QueryString - { - get { return _request.QueryString; } - } - - public IDictionary<string, object> Items - { - get { return _request.Items; } - } - - public void AddResponseHeader(string name, string value) - { - _request.Response.AddHeader(name, value); - } - } -} diff --git a/MediaBrowser.Controller/Notifications/INotificationManager.cs b/MediaBrowser.Controller/Notifications/INotificationManager.cs index cb1e3da90..f9d264314 100644 --- a/MediaBrowser.Controller/Notifications/INotificationManager.cs +++ b/MediaBrowser.Controller/Notifications/INotificationManager.cs @@ -26,7 +26,7 @@ namespace MediaBrowser.Controller.Notifications /// Gets the notification types. /// </summary> /// <returns>IEnumerable{NotificationTypeInfo}.</returns> - IEnumerable<NotificationTypeInfo> GetNotificationTypes(); + List<NotificationTypeInfo> GetNotificationTypes(); /// <summary> /// Gets the notification services. diff --git a/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs b/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs index abf96994f..25aba6bd9 100644 --- a/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs +++ b/MediaBrowser.Controller/Persistence/IDisplayPreferencesRepository.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Entities; using System; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -19,9 +18,9 @@ namespace MediaBrowser.Controller.Persistence /// <param name="client">The client.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, + void SaveDisplayPreferences(DisplayPreferences displayPreferences, string userId, string client, CancellationToken cancellationToken); - + /// <summary> /// Saves all display preferences for a user /// </summary> @@ -29,7 +28,7 @@ namespace MediaBrowser.Controller.Persistence /// <param name="userId">The user id.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId, + void SaveAllDisplayPreferences(IEnumerable<DisplayPreferences> displayPreferences, Guid userId, CancellationToken cancellationToken); /// <summary> /// Gets the display preferences. diff --git a/MediaBrowser.Controller/Persistence/IItemRepository.cs b/MediaBrowser.Controller/Persistence/IItemRepository.cs index 58ae1f3b0..3d05d2fca 100644 --- a/MediaBrowser.Controller/Persistence/IItemRepository.cs +++ b/MediaBrowser.Controller/Persistence/IItemRepository.cs @@ -3,7 +3,6 @@ using MediaBrowser.Model.Entities; using System; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; using MediaBrowser.Model.Dto; using MediaBrowser.Model.Querying; @@ -19,39 +18,35 @@ namespace MediaBrowser.Controller.Persistence /// </summary> /// <param name="item">The item.</param> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task SaveItem(BaseItem item, CancellationToken cancellationToken); + void SaveItem(BaseItem item, CancellationToken cancellationToken); /// <summary> /// Deletes the item. /// </summary> /// <param name="id">The identifier.</param> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task DeleteItem(Guid id, CancellationToken cancellationToken); + void DeleteItem(Guid id, CancellationToken cancellationToken); /// <summary> /// Gets the critic reviews. /// </summary> /// <param name="itemId">The item id.</param> /// <returns>Task{IEnumerable{ItemReview}}.</returns> - IEnumerable<ItemReview> GetCriticReviews(Guid itemId); + List<ItemReview> GetCriticReviews(Guid itemId); /// <summary> /// Saves the critic reviews. /// </summary> /// <param name="itemId">The item id.</param> /// <param name="criticReviews">The critic reviews.</param> - /// <returns>Task.</returns> - Task SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews); + void SaveCriticReviews(Guid itemId, IEnumerable<ItemReview> criticReviews); /// <summary> /// Saves the items. /// </summary> /// <param name="items">The items.</param> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task SaveItems(List<BaseItem> items, CancellationToken cancellationToken); + void SaveItems(List<BaseItem> items, CancellationToken cancellationToken); /// <summary> /// Retrieves the item. @@ -65,7 +60,7 @@ namespace MediaBrowser.Controller.Persistence /// </summary> /// <param name="id"></param> /// <returns></returns> - IEnumerable<ChapterInfo> GetChapters(Guid id); + List<ChapterInfo> GetChapters(Guid id); /// <summary> /// Gets a single chapter for an item @@ -78,18 +73,14 @@ namespace MediaBrowser.Controller.Persistence /// <summary> /// Saves the chapters. /// </summary> - /// <param name="id">The id.</param> - /// <param name="chapters">The chapters.</param> - /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task SaveChapters(Guid id, List<ChapterInfo> chapters, CancellationToken cancellationToken); + void SaveChapters(Guid id, List<ChapterInfo> chapters); /// <summary> /// Gets the media streams. /// </summary> /// <param name="query">The query.</param> /// <returns>IEnumerable{MediaStream}.</returns> - IEnumerable<MediaStream> GetMediaStreams(MediaStreamQuery query); + List<MediaStream> GetMediaStreams(MediaStreamQuery query); /// <summary> /// Saves the media streams. @@ -97,8 +88,7 @@ namespace MediaBrowser.Controller.Persistence /// <param name="id">The identifier.</param> /// <param name="streams">The streams.</param> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken); + void SaveMediaStreams(Guid id, List<MediaStream> streams, CancellationToken cancellationToken); /// <summary> /// Gets the item ids. @@ -132,8 +122,7 @@ namespace MediaBrowser.Controller.Persistence /// </summary> /// <param name="itemId">The item identifier.</param> /// <param name="people">The people.</param> - /// <returns>Task.</returns> - Task UpdatePeople(Guid itemId, List<PersonInfo> people); + void UpdatePeople(Guid itemId, List<PersonInfo> people); /// <summary> /// Gets the people names. @@ -160,8 +149,7 @@ namespace MediaBrowser.Controller.Persistence /// Updates the inherited values. /// </summary> /// <param name="cancellationToken">The cancellation token.</param> - /// <returns>Task.</returns> - Task UpdateInheritedValues(CancellationToken cancellationToken); + void UpdateInheritedValues(CancellationToken cancellationToken); int GetCount(InternalItemsQuery query); diff --git a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs index ca4dc9751..f79a3a9fc 100644 --- a/MediaBrowser.Controller/Persistence/IUserDataRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserDataRepository.cs @@ -2,7 +2,6 @@ using MediaBrowser.Controller.Entities; using System; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -19,7 +18,7 @@ namespace MediaBrowser.Controller.Persistence /// <param name="userData">The user data.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); + void SaveUserData(Guid userId, string key, UserItemData userData, CancellationToken cancellationToken); /// <summary> /// Gets the user data. @@ -36,7 +35,7 @@ namespace MediaBrowser.Controller.Persistence /// </summary> /// <param name="userId"></param> /// <returns></returns> - IEnumerable<UserItemData> GetAllUserData(Guid userId); + List<UserItemData> GetAllUserData(Guid userId); /// <summary> /// Save all user data associated with the given user @@ -45,7 +44,7 @@ namespace MediaBrowser.Controller.Persistence /// <param name="userData"></param> /// <param name="cancellationToken"></param> /// <returns></returns> - Task SaveAllUserData(Guid userId, IEnumerable<UserItemData> userData, CancellationToken cancellationToken); + void SaveAllUserData(Guid userId, UserItemData[] userData, CancellationToken cancellationToken); } } diff --git a/MediaBrowser.Controller/Persistence/IUserRepository.cs b/MediaBrowser.Controller/Persistence/IUserRepository.cs index 80961a369..721ddb7e3 100644 --- a/MediaBrowser.Controller/Persistence/IUserRepository.cs +++ b/MediaBrowser.Controller/Persistence/IUserRepository.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using System.Collections.Generic; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Persistence { @@ -16,7 +15,7 @@ namespace MediaBrowser.Controller.Persistence /// <param name="user">The user.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task DeleteUser(User user, CancellationToken cancellationToken); + void DeleteUser(User user, CancellationToken cancellationToken); /// <summary> /// Saves the user. @@ -24,7 +23,7 @@ namespace MediaBrowser.Controller.Persistence /// <param name="user">The user.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SaveUser(User user, CancellationToken cancellationToken); + void SaveUser(User user, CancellationToken cancellationToken); /// <summary> /// Retrieves all users. diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index c992ac56a..ee96a8c3b 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -89,7 +89,7 @@ namespace MediaBrowser.Controller.Playlists return new List<BaseItem>(); } - public override IEnumerable<BaseItem> GetChildren(User user, bool includeLinkedChildren) + public override List<BaseItem> GetChildren(User user, bool includeLinkedChildren) { return GetPlayableItems(user, new DtoOptions(true)); } @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Playlists if (query != null) { - items = items.Where(i => UserViewBuilder.FilterItem(i, query)); + items = items.Where(i => UserViewBuilder.FilterItem(i, query)).ToList(); } return items; @@ -116,12 +116,12 @@ namespace MediaBrowser.Controller.Playlists return GetLinkedChildrenInfos(); } - private IEnumerable<BaseItem> GetPlayableItems(User user, DtoOptions options) + private List<BaseItem> GetPlayableItems(User user, DtoOptions options) { return GetPlaylistItems(MediaType, base.GetChildren(user, true), user, options); } - public static IEnumerable<BaseItem> GetPlaylistItems(string playlistMediaType, IEnumerable<BaseItem> inputItems, User user, DtoOptions options) + public static List<BaseItem> GetPlaylistItems(string playlistMediaType, IEnumerable<BaseItem> inputItems, User user, DtoOptions options) { if (user != null) { @@ -149,8 +149,7 @@ namespace MediaBrowser.Controller.Playlists Recursive = true, IncludeItemTypes = new[] { typeof(Audio).Name }, GenreIds = new[] { musicGenre.Id.ToString("N") }, - SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, - SortOrder = SortOrder.Ascending, + OrderBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Ascending)).ToArray(), DtoOptions = options }); } @@ -163,8 +162,7 @@ namespace MediaBrowser.Controller.Playlists Recursive = true, IncludeItemTypes = new[] { typeof(Audio).Name }, ArtistIds = new[] { musicArtist.Id.ToString("N") }, - SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, - SortOrder = SortOrder.Ascending, + OrderBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Ascending)).ToArray(), DtoOptions = options }); } @@ -176,16 +174,13 @@ namespace MediaBrowser.Controller.Playlists { Recursive = true, IsFolder = false, - SortBy = new[] { ItemSortBy.SortName }, + OrderBy = new[] { ItemSortBy.SortName }.Select(i => new Tuple<string, SortOrder>(i, SortOrder.Ascending)).ToArray(), MediaTypes = new[] { mediaType }, EnableTotalRecordCount = false, DtoOptions = options }; - var itemsResult = folder.GetItems(query); - var items = itemsResult.Items; - - return items; + return folder.GetItemList(query); } return new[] { item }; diff --git a/MediaBrowser.Controller/Providers/AlbumInfo.cs b/MediaBrowser.Controller/Providers/AlbumInfo.cs index b88477409..74feb4ea2 100644 --- a/MediaBrowser.Controller/Providers/AlbumInfo.cs +++ b/MediaBrowser.Controller/Providers/AlbumInfo.cs @@ -9,7 +9,7 @@ namespace MediaBrowser.Controller.Providers /// Gets or sets the album artist. /// </summary> /// <value>The album artist.</value> - public List<string> AlbumArtists { get; set; } + public string[] AlbumArtists { get; set; } /// <summary> /// Gets or sets the artist provider ids. @@ -22,7 +22,7 @@ namespace MediaBrowser.Controller.Providers { ArtistProviderIds = new Dictionary<string, string>(StringComparer.OrdinalIgnoreCase); SongInfos = new List<SongInfo>(); - AlbumArtists = new List<string>(); + AlbumArtists = EmptyStringArray; } } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 6d220f3a3..d957470d3 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -4,7 +4,6 @@ using System.Collections.Concurrent; using System.Collections.Generic; using System.IO; using System.Linq; - using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; @@ -13,10 +12,10 @@ namespace MediaBrowser.Controller.Providers public class DirectoryService : IDirectoryService { private readonly ILogger _logger; - private readonly IFileSystem _fileSystem; + private readonly IFileSystem _fileSystem; - private readonly ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>> _cache = - new ConcurrentDictionary<string, Dictionary<string, FileSystemMetadata>>(StringComparer.OrdinalIgnoreCase); + private readonly ConcurrentDictionary<string, FileSystemMetadata[]> _cache = + new ConcurrentDictionary<string, FileSystemMetadata[]>(StringComparer.OrdinalIgnoreCase); private readonly ConcurrentDictionary<string, FileSystemMetadata> _fileCache = new ConcurrentDictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase); @@ -24,7 +23,7 @@ namespace MediaBrowser.Controller.Providers public DirectoryService(ILogger logger, IFileSystem fileSystem) { _logger = logger; - _fileSystem = fileSystem; + _fileSystem = fileSystem; } public DirectoryService(IFileSystem fileSystem) @@ -32,28 +31,23 @@ namespace MediaBrowser.Controller.Providers { } - public IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path) + public FileSystemMetadata[] GetFileSystemEntries(string path) { return GetFileSystemEntries(path, false); } - public Dictionary<string, FileSystemMetadata> GetFileSystemDictionary(string path) - { - return GetFileSystemDictionary(path, false); - } - - private Dictionary<string, FileSystemMetadata> GetFileSystemDictionary(string path, bool clearCache) + private FileSystemMetadata[] GetFileSystemEntries(string path, bool clearCache) { if (string.IsNullOrWhiteSpace(path)) { throw new ArgumentNullException("path"); } - Dictionary<string, FileSystemMetadata> entries; + FileSystemMetadata[] entries; if (clearCache) { - Dictionary<string, FileSystemMetadata> removed; + FileSystemMetadata[] removed; _cache.TryRemove(path, out removed); } @@ -62,55 +56,39 @@ namespace MediaBrowser.Controller.Providers { //_logger.Debug("Getting files for " + path); - entries = new Dictionary<string, FileSystemMetadata>(StringComparer.OrdinalIgnoreCase); - try { // using EnumerateFileSystemInfos doesn't handle reparse points (symlinks) - var list = _fileSystem.GetFileSystemEntries(path) - .ToList(); - - // Seeing dupes on some users file system for some reason - foreach (var item in list) - { - entries[item.FullName] = item; - } + entries = _fileSystem.GetFileSystemEntries(path).ToArray(); } catch (IOException) { + entries = new FileSystemMetadata[] { }; } - //var group = entries.ToLookup(i => _fileSystem.GetDirectoryName(i.FullName)).ToList(); - _cache.TryAdd(path, entries); } return entries; } - private IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path, bool clearCache) - { - return GetFileSystemDictionary(path, clearCache).Values; - } - - public IEnumerable<FileSystemMetadata> GetFiles(string path) + public List<FileSystemMetadata> GetFiles(string path) { return GetFiles(path, false); } - public IEnumerable<FileSystemMetadata> GetFiles(string path, bool clearCache) - { - return GetFileSystemEntries(path, clearCache).Where(i => !i.IsDirectory); - } - - public IEnumerable<string> GetFilePaths(string path) - { - return _fileSystem.GetFilePaths(path); - } - - public IEnumerable<string> GetFilePaths(string path, bool clearCache) + public List<FileSystemMetadata> GetFiles(string path, bool clearCache) { - return _fileSystem.GetFilePaths(path); + var list = new List<FileSystemMetadata>(); + var items = GetFileSystemEntries(path, clearCache); + foreach (var item in items) + { + if (!item.IsDirectory) + { + list.Add(item); + } + } + return list; } public FileSystemMetadata GetFile(string path) @@ -133,10 +111,5 @@ namespace MediaBrowser.Controller.Providers return file; //return _fileSystem.GetFileInfo(path); } - - public IEnumerable<FileSystemMetadata> GetDirectories(string path) - { - return GetFileSystemEntries(path, false).Where(i => i.IsDirectory); - } } } diff --git a/MediaBrowser.Controller/Providers/EpisodeInfo.cs b/MediaBrowser.Controller/Providers/EpisodeInfo.cs index b8e88ea53..5df999ab0 100644 --- a/MediaBrowser.Controller/Providers/EpisodeInfo.cs +++ b/MediaBrowser.Controller/Providers/EpisodeInfo.cs @@ -10,7 +10,6 @@ namespace MediaBrowser.Controller.Providers public int? IndexNumberEnd { get; set; } public bool IsMissingEpisode { get; set; } - public bool IsVirtualUnaired { get; set; } public EpisodeInfo() { diff --git a/MediaBrowser.Controller/Providers/IDirectoryService.cs b/MediaBrowser.Controller/Providers/IDirectoryService.cs index 1b203f32c..6f864f4be 100644 --- a/MediaBrowser.Controller/Providers/IDirectoryService.cs +++ b/MediaBrowser.Controller/Providers/IDirectoryService.cs @@ -1,18 +1,12 @@ using System.Collections.Generic; - -using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; namespace MediaBrowser.Controller.Providers { public interface IDirectoryService { - IEnumerable<FileSystemMetadata> GetFileSystemEntries(string path); - IEnumerable<FileSystemMetadata> GetDirectories(string path); - IEnumerable<FileSystemMetadata> GetFiles(string path); - IEnumerable<string> GetFilePaths(string path); - IEnumerable<string> GetFilePaths(string path, bool clearCache); + FileSystemMetadata[] GetFileSystemEntries(string path); + List<FileSystemMetadata> GetFiles(string path); FileSystemMetadata GetFile(string path); - Dictionary<string, FileSystemMetadata> GetFileSystemDictionary(string path); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/IDynamicImageProvider.cs b/MediaBrowser.Controller/Providers/IDynamicImageProvider.cs index 9c3f94763..e96a2d65e 100644 --- a/MediaBrowser.Controller/Providers/IDynamicImageProvider.cs +++ b/MediaBrowser.Controller/Providers/IDynamicImageProvider.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Providers /// </summary> /// <param name="item">The item.</param> /// <returns>IEnumerable{ImageType}.</returns> - IEnumerable<ImageType> GetSupportedImages(IHasImages item); + IEnumerable<ImageType> GetSupportedImages(IHasMetadata item); /// <summary> /// Gets the image. @@ -22,6 +22,6 @@ namespace MediaBrowser.Controller.Providers /// <param name="type">The type.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{DynamicImageResponse}.</returns> - Task<DynamicImageResponse> GetImage(IHasImages item, ImageType type, CancellationToken cancellationToken); + Task<DynamicImageResponse> GetImage(IHasMetadata item, ImageType type, CancellationToken cancellationToken); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/IImageEnhancer.cs b/MediaBrowser.Controller/Providers/IImageEnhancer.cs index a43941607..a993f536d 100644 --- a/MediaBrowser.Controller/Providers/IImageEnhancer.cs +++ b/MediaBrowser.Controller/Providers/IImageEnhancer.cs @@ -13,7 +13,7 @@ namespace MediaBrowser.Controller.Providers /// <param name="item">The item.</param> /// <param name="imageType">Type of the image.</param> /// <returns><c>true</c> if this enhancer will enhance the supplied image for the supplied item, <c>false</c> otherwise</returns> - bool Supports(IHasImages item, ImageType imageType); + bool Supports(IHasMetadata item, ImageType imageType); /// <summary> /// Gets the priority or order in which this enhancer should be run. @@ -27,7 +27,7 @@ namespace MediaBrowser.Controller.Providers /// <param name="item">The item.</param> /// <param name="imageType">Type of the image.</param> /// <returns>Cache key relating to the current state of this item and configuration</returns> - string GetConfigurationCacheKey(IHasImages item, ImageType imageType); + string GetConfigurationCacheKey(IHasMetadata item, ImageType imageType); /// <summary> /// Gets the size of the enhanced image. @@ -37,7 +37,7 @@ namespace MediaBrowser.Controller.Providers /// <param name="imageIndex">Index of the image.</param> /// <param name="originalImageSize">Size of the original image.</param> /// <returns>ImageSize.</returns> - ImageSize GetEnhancedImageSize(IHasImages item, ImageType imageType, int imageIndex, ImageSize originalImageSize); + ImageSize GetEnhancedImageSize(IHasMetadata item, ImageType imageType, int imageIndex, ImageSize originalImageSize); /// <summary> /// Enhances the image async. @@ -49,6 +49,6 @@ namespace MediaBrowser.Controller.Providers /// <param name="imageIndex">Index of the image.</param> /// <returns>Task{Image}.</returns> /// <exception cref="System.ArgumentNullException"></exception> - Task EnhanceImageAsync(IHasImages item, string inputFile, string outputFile, ImageType imageType, int imageIndex); + Task EnhanceImageAsync(IHasMetadata item, string inputFile, string outputFile, ImageType imageType, int imageIndex); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/IImageProvider.cs b/MediaBrowser.Controller/Providers/IImageProvider.cs index 1e5bdfeaf..2b43c9cb8 100644 --- a/MediaBrowser.Controller/Providers/IImageProvider.cs +++ b/MediaBrowser.Controller/Providers/IImageProvider.cs @@ -18,6 +18,6 @@ namespace MediaBrowser.Controller.Providers /// </summary> /// <param name="item">The item.</param> /// <returns><c>true</c> if XXXX, <c>false</c> otherwise</returns> - bool Supports(IHasImages item); + bool Supports(IHasMetadata item); } } diff --git a/MediaBrowser.Controller/Providers/ILocalImageFileProvider.cs b/MediaBrowser.Controller/Providers/ILocalImageFileProvider.cs index 7e5d82843..e93c73a52 100644 --- a/MediaBrowser.Controller/Providers/ILocalImageFileProvider.cs +++ b/MediaBrowser.Controller/Providers/ILocalImageFileProvider.cs @@ -5,6 +5,6 @@ namespace MediaBrowser.Controller.Providers { public interface ILocalImageFileProvider : ILocalImageProvider { - List<LocalImageInfo> GetImages(IHasImages item, IDirectoryService directoryService); + List<LocalImageInfo> GetImages(IHasMetadata item, IDirectoryService directoryService); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index 0ba573da8..77e6a7e40 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -50,7 +50,7 @@ namespace MediaBrowser.Controller.Providers /// <param name="imageIndex">Index of the image.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SaveImage(IHasImages item, string url, ImageType type, int? imageIndex, CancellationToken cancellationToken); + Task SaveImage(IHasMetadata item, string url, ImageType type, int? imageIndex, CancellationToken cancellationToken); /// <summary> /// Saves the image. @@ -62,13 +62,13 @@ namespace MediaBrowser.Controller.Providers /// <param name="imageIndex">Index of the image.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task SaveImage(IHasImages item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken); + Task SaveImage(IHasMetadata item, Stream source, string mimeType, ImageType type, int? imageIndex, CancellationToken cancellationToken); /// <summary> /// Saves the image. /// </summary> /// <returns>Task.</returns> - Task SaveImage(IHasImages item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken); + Task SaveImage(IHasMetadata item, string source, string mimeType, ImageType type, int? imageIndex, bool? saveLocallyWithMedia, CancellationToken cancellationToken); /// <summary> /// Adds the metadata providers. @@ -84,20 +84,20 @@ namespace MediaBrowser.Controller.Providers /// <param name="query">The query.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns> - Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(IHasImages item, RemoteImageQuery query, CancellationToken cancellationToken); + Task<IEnumerable<RemoteImageInfo>> GetAvailableRemoteImages(IHasMetadata item, RemoteImageQuery query, CancellationToken cancellationToken); /// <summary> /// Gets the image providers. /// </summary> /// <param name="item">The item.</param> /// <returns>IEnumerable{ImageProviderInfo}.</returns> - IEnumerable<ImageProviderInfo> GetRemoteImageProviderInfo(IHasImages item); + IEnumerable<ImageProviderInfo> GetRemoteImageProviderInfo(IHasMetadata item); /// <summary> /// Gets all metadata plugins. /// </summary> /// <returns>IEnumerable{MetadataPlugin}.</returns> - IEnumerable<MetadataPluginSummary> GetAllMetadataPlugins(); + MetadataPluginSummary[] GetAllMetadataPlugins(); /// <summary> /// Gets the external urls. @@ -135,7 +135,7 @@ namespace MediaBrowser.Controller.Providers /// </summary> /// <param name="item">The item.</param> /// <returns>MetadataOptions.</returns> - MetadataOptions GetMetadataOptions(IHasImages item); + MetadataOptions GetMetadataOptions(IHasMetadata item); /// <summary> /// Gets the remote search results. diff --git a/MediaBrowser.Controller/Providers/IRemoteImageProvider.cs b/MediaBrowser.Controller/Providers/IRemoteImageProvider.cs index 6b94547bb..86a7939e6 100644 --- a/MediaBrowser.Controller/Providers/IRemoteImageProvider.cs +++ b/MediaBrowser.Controller/Providers/IRemoteImageProvider.cs @@ -18,7 +18,7 @@ namespace MediaBrowser.Controller.Providers /// </summary> /// <param name="item">The item.</param> /// <returns>IEnumerable{ImageType}.</returns> - IEnumerable<ImageType> GetSupportedImages(IHasImages item); + IEnumerable<ImageType> GetSupportedImages(IHasMetadata item); /// <summary> /// Gets the images. @@ -26,7 +26,7 @@ namespace MediaBrowser.Controller.Providers /// <param name="item">The item.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{IEnumerable{RemoteImageInfo}}.</returns> - Task<IEnumerable<RemoteImageInfo>> GetImages(IHasImages item, CancellationToken cancellationToken); + Task<IEnumerable<RemoteImageInfo>> GetImages(IHasMetadata item, CancellationToken cancellationToken); /// <summary> /// Gets the image response. diff --git a/MediaBrowser.Controller/Providers/ItemInfo.cs b/MediaBrowser.Controller/Providers/ItemInfo.cs index 8de11b743..63cc48058 100644 --- a/MediaBrowser.Controller/Providers/ItemInfo.cs +++ b/MediaBrowser.Controller/Providers/ItemInfo.cs @@ -10,7 +10,7 @@ namespace MediaBrowser.Controller.Providers { Path = item.Path; ContainingFolderPath = item.ContainingFolderPath; - IsInMixedFolder = item.DetectIsInMixedFolder(); + IsInMixedFolder = item.IsInMixedFolder; var video = item as Video; if (video != null) diff --git a/MediaBrowser.Controller/Providers/ItemLookupInfo.cs b/MediaBrowser.Controller/Providers/ItemLookupInfo.cs index dc7a04135..98122e776 100644 --- a/MediaBrowser.Controller/Providers/ItemLookupInfo.cs +++ b/MediaBrowser.Controller/Providers/ItemLookupInfo.cs @@ -6,6 +6,8 @@ namespace MediaBrowser.Controller.Providers { public class ItemLookupInfo : IHasProviderIds { + protected static string[] EmptyStringArray = new string[] { }; + /// <summary> /// Gets or sets the name. /// </summary> diff --git a/MediaBrowser.Controller/Providers/MetadataResult.cs b/MediaBrowser.Controller/Providers/MetadataResult.cs index 99402a969..5ed55ea16 100644 --- a/MediaBrowser.Controller/Providers/MetadataResult.cs +++ b/MediaBrowser.Controller/Providers/MetadataResult.cs @@ -1,7 +1,6 @@ using MediaBrowser.Controller.Entities; using System; using System.Collections.Generic; -using System.Linq; namespace MediaBrowser.Controller.Providers { @@ -51,7 +50,15 @@ namespace MediaBrowser.Controller.Providers UserDataList = new List<UserItemData>(); } - var userData = UserDataList.FirstOrDefault(i => string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)); + UserItemData userData = null; + + foreach (var i in UserDataList) + { + if (string.Equals(userId, i.UserId.ToString("N"), StringComparison.OrdinalIgnoreCase)) + { + userData = i; + } + } if (userData == null) { diff --git a/MediaBrowser.Controller/Providers/SongInfo.cs b/MediaBrowser.Controller/Providers/SongInfo.cs index b83912a00..e3a6f5d37 100644 --- a/MediaBrowser.Controller/Providers/SongInfo.cs +++ b/MediaBrowser.Controller/Providers/SongInfo.cs @@ -1,17 +1,16 @@ -using System.Collections.Generic; namespace MediaBrowser.Controller.Providers { public class SongInfo : ItemLookupInfo { - public List<string> AlbumArtists { get; set; } + public string[] AlbumArtists { get; set; } public string Album { get; set; } - public List<string> Artists { get; set; } + public string[] Artists { get; set; } public SongInfo() { - Artists = new List<string>(); - AlbumArtists = new List<string>(); + Artists = EmptyStringArray; + AlbumArtists = EmptyStringArray; } } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Security/IAuthenticationRepository.cs b/MediaBrowser.Controller/Security/IAuthenticationRepository.cs index 219b07028..f80ee6e7f 100644 --- a/MediaBrowser.Controller/Security/IAuthenticationRepository.cs +++ b/MediaBrowser.Controller/Security/IAuthenticationRepository.cs @@ -1,6 +1,5 @@ using MediaBrowser.Model.Querying; using System.Threading; -using System.Threading.Tasks; namespace MediaBrowser.Controller.Security { @@ -12,7 +11,7 @@ namespace MediaBrowser.Controller.Security /// <param name="info">The information.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task Create(AuthenticationInfo info, CancellationToken cancellationToken); + void Create(AuthenticationInfo info, CancellationToken cancellationToken); /// <summary> /// Updates the specified information. @@ -20,7 +19,7 @@ namespace MediaBrowser.Controller.Security /// <param name="info">The information.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> - Task Update(AuthenticationInfo info, CancellationToken cancellationToken); + void Update(AuthenticationInfo info, CancellationToken cancellationToken); /// <summary> /// Gets the specified query. diff --git a/MediaBrowser.Controller/Session/ISessionManager.cs b/MediaBrowser.Controller/Session/ISessionManager.cs index 8d77e0747..603e5ef76 100644 --- a/MediaBrowser.Controller/Session/ISessionManager.cs +++ b/MediaBrowser.Controller/Session/ISessionManager.cs @@ -318,19 +318,19 @@ namespace MediaBrowser.Controller.Session /// </summary> /// <param name="accessToken">The access token.</param> /// <returns>Task.</returns> - Task Logout(string accessToken); + void Logout(string accessToken); /// <summary> /// Revokes the user tokens. /// </summary> /// <returns>Task.</returns> - Task RevokeUserTokens(string userId, string currentAccessToken); + void RevokeUserTokens(string userId, string currentAccessToken); /// <summary> /// Revokes the token. /// </summary> /// <param name="id">The identifier.</param> /// <returns>Task.</returns> - Task RevokeToken(string id); + void RevokeToken(string id); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 11a9ceac4..367a7a467 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -2,7 +2,6 @@ using MediaBrowser.Model.Session; using System; using System.Collections.Generic; -using System.Linq; using MediaBrowser.Controller.Entities; using MediaBrowser.Model.Logging; using MediaBrowser.Model.Threading; @@ -22,13 +21,13 @@ namespace MediaBrowser.Controller.Session _sessionManager = sessionManager; _logger = logger; - AdditionalUsers = new List<SessionUserInfo>(); + AdditionalUsers = new SessionUserInfo[] { }; PlayState = new PlayerStateInfo(); } public PlayerStateInfo PlayState { get; set; } - public List<SessionUserInfo> AdditionalUsers { get; set; } + public SessionUserInfo[] AdditionalUsers { get; set; } public ClientCapabilities Capabilities { get; set; } @@ -42,13 +41,13 @@ namespace MediaBrowser.Controller.Session /// Gets or sets the playable media types. /// </summary> /// <value>The playable media types.</value> - public List<string> PlayableMediaTypes + public string[] PlayableMediaTypes { get { if (Capabilities == null) { - return new List<string>(); + return new string[] { }; } return Capabilities.PlayableMediaTypes; } @@ -138,13 +137,13 @@ namespace MediaBrowser.Controller.Session /// Gets or sets the supported commands. /// </summary> /// <value>The supported commands.</value> - public List<string> SupportedCommands + public string[] SupportedCommands { get { if (Capabilities == null) { - return new List<string>(); + return new string[] { }; } return Capabilities.SupportedCommands; } @@ -194,7 +193,19 @@ namespace MediaBrowser.Controller.Session public bool ContainsUser(Guid userId) { - return (UserId ?? Guid.Empty) == userId || AdditionalUsers.Any(i => userId == new Guid(i.UserId)); + if ((UserId ?? Guid.Empty) == userId) + { + return true; + } + + foreach (var additionalUser in AdditionalUsers) + { + if (userId == new Guid(additionalUser.UserId)) + { + return true; + } + } + return false; } private readonly object _progressLock = new object(); @@ -292,6 +303,7 @@ namespace MediaBrowser.Controller.Session StopAutomaticProgress(); _sessionManager = null; + GC.SuppressFinalize(this); } } } diff --git a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs index d1d5f27be..2199c21e6 100644 --- a/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs +++ b/MediaBrowser.Controller/Subtitles/ISubtitleManager.cs @@ -28,7 +28,7 @@ namespace MediaBrowser.Controller.Subtitles /// <summary> /// Searches the subtitles. /// </summary> - Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitles(Video video, + Task<RemoteSubtitleInfo[]> SearchSubtitles(Video video, string language, bool? isPerfectMatch, CancellationToken cancellationToken); @@ -39,7 +39,7 @@ namespace MediaBrowser.Controller.Subtitles /// <param name="request">The request.</param> /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task{IEnumerable{RemoteSubtitleInfo}}.</returns> - Task<IEnumerable<RemoteSubtitleInfo>> SearchSubtitles(SubtitleSearchRequest request, + Task<RemoteSubtitleInfo[]> SearchSubtitles(SubtitleSearchRequest request, CancellationToken cancellationToken); /// <summary> @@ -74,6 +74,6 @@ namespace MediaBrowser.Controller.Subtitles /// </summary> /// <param name="itemId">The item identifier.</param> /// <returns>IEnumerable{SubtitleProviderInfo}.</returns> - IEnumerable<SubtitleProviderInfo> GetProviders(string itemId); + SubtitleProviderInfo[] GetProviders(string itemId); } } diff --git a/MediaBrowser.Controller/Sync/ISyncManager.cs b/MediaBrowser.Controller/Sync/ISyncManager.cs index 291632ea5..910d697ec 100644 --- a/MediaBrowser.Controller/Sync/ISyncManager.cs +++ b/MediaBrowser.Controller/Sync/ISyncManager.cs @@ -16,6 +16,7 @@ namespace MediaBrowser.Controller.Sync event EventHandler<GenericEventArgs<SyncJob>> SyncJobUpdated; event EventHandler<GenericEventArgs<SyncJobItem>> SyncJobItemUpdated; event EventHandler<GenericEventArgs<SyncJobItem>> SyncJobItemCreated; + event EventHandler<GenericEventArgs<SyncJobItem>> SyncJobItemCancelled; /// <summary> /// Creates the job. @@ -78,7 +79,7 @@ namespace MediaBrowser.Controller.Sync /// <param name="targetId">The target identifier.</param> /// <param name="itemIds">The item ids.</param> /// <returns>Task.</returns> - Task CancelItems(string targetId, IEnumerable<string> itemIds); + Task CancelItems(string targetId, string[] itemIds); /// <summary> /// Adds the parts. @@ -88,9 +89,9 @@ namespace MediaBrowser.Controller.Sync /// <summary> /// Gets the synchronize targets. /// </summary> - IEnumerable<SyncTarget> GetSyncTargets(string userId); + List<SyncTarget> GetSyncTargets(string userId); - IEnumerable<SyncTarget> GetSyncTargets(string userId, bool? supportsRemoteSync); + List<SyncTarget> GetSyncTargets(string userId, bool? supportsRemoteSync); /// <summary> /// Supportses the synchronize. @@ -135,20 +136,6 @@ namespace MediaBrowser.Controller.Sync Task<SyncDataResponse> SyncData(SyncDataRequest request); /// <summary> - /// Marks the job item for removal. - /// </summary> - /// <param name="id">The identifier.</param> - /// <returns>Task.</returns> - Task MarkJobItemForRemoval(string id); - - /// <summary> - /// Unmarks the job item for removal. - /// </summary> - /// <param name="id">The identifier.</param> - /// <returns>Task.</returns> - Task UnmarkJobItemForRemoval(string id); - - /// <summary> /// Gets the library item ids. /// </summary> /// <param name="query">The query.</param> @@ -173,28 +160,24 @@ namespace MediaBrowser.Controller.Sync /// Gets the quality options. /// </summary> /// <param name="targetId">The target identifier.</param> - /// <returns>IEnumerable<SyncQualityOption>.</returns> - IEnumerable<SyncQualityOption> GetQualityOptions(string targetId); + List<SyncQualityOption> GetQualityOptions(string targetId); /// <summary> /// Gets the quality options. /// </summary> /// <param name="targetId">The target identifier.</param> /// <param name="user">The user.</param> - /// <returns>IEnumerable<SyncQualityOption>.</returns> - IEnumerable<SyncQualityOption> GetQualityOptions(string targetId, User user); + List<SyncQualityOption> GetQualityOptions(string targetId, User user); /// <summary> /// Gets the profile options. /// </summary> /// <param name="targetId">The target identifier.</param> - /// <returns>IEnumerable<SyncQualityOption>.</returns> - IEnumerable<SyncProfileOption> GetProfileOptions(string targetId); + List<SyncProfileOption> GetProfileOptions(string targetId); /// <summary> /// Gets the profile options. /// </summary> /// <param name="targetId">The target identifier.</param> /// <param name="user">The user.</param> - /// <returns>IEnumerable<SyncProfileOption>.</returns> - IEnumerable<SyncProfileOption> GetProfileOptions(string targetId, User user); + List<SyncProfileOption> GetProfileOptions(string targetId, User user); } } diff --git a/MediaBrowser.Controller/Sync/ISyncProvider.cs b/MediaBrowser.Controller/Sync/ISyncProvider.cs index aa4b36427..2f60e124e 100644 --- a/MediaBrowser.Controller/Sync/ISyncProvider.cs +++ b/MediaBrowser.Controller/Sync/ISyncProvider.cs @@ -18,13 +18,13 @@ namespace MediaBrowser.Controller.Sync /// </summary> /// <param name="userId">The user identifier.</param> /// <returns>IEnumerable<SyncTarget>.</returns> - IEnumerable<SyncTarget> GetSyncTargets(string userId); + List<SyncTarget> GetSyncTargets(string userId); /// <summary> /// Gets all synchronize targets. /// </summary> /// <returns>IEnumerable<SyncTarget>.</returns> - IEnumerable<SyncTarget> GetAllSyncTargets(); + List<SyncTarget> GetAllSyncTargets(); } public interface IHasUniqueTargetIds diff --git a/MediaBrowser.Controller/Sync/ISyncRepository.cs b/MediaBrowser.Controller/Sync/ISyncRepository.cs deleted file mode 100644 index 8e9b2bf77..000000000 --- a/MediaBrowser.Controller/Sync/ISyncRepository.cs +++ /dev/null @@ -1,80 +0,0 @@ -using System.Collections.Generic; -using MediaBrowser.Model.Querying; -using MediaBrowser.Model.Sync; -using System.Threading.Tasks; - -namespace MediaBrowser.Controller.Sync -{ - public interface ISyncRepository - { - /// <summary> - /// Gets the job. - /// </summary> - /// <param name="id">The identifier.</param> - /// <returns>SyncJob.</returns> - SyncJob GetJob(string id); - - /// <summary> - /// Creates the specified job. - /// </summary> - /// <param name="job">The job.</param> - /// <returns>Task.</returns> - Task Create(SyncJob job); - - /// <summary> - /// Updates the specified job. - /// </summary> - /// <param name="job">The job.</param> - /// <returns>Task.</returns> - Task Update(SyncJob job); - - /// <summary> - /// Deletes the job. - /// </summary> - /// <param name="id">The identifier.</param> - /// <returns>Task.</returns> - Task DeleteJob(string id); - - /// <summary> - /// Gets the jobs. - /// </summary> - /// <param name="query">The query.</param> - /// <returns>QueryResult<SyncJob>.</returns> - QueryResult<SyncJob> GetJobs(SyncJobQuery query); - - /// <summary> - /// Gets the job item. - /// </summary> - /// <param name="id">The identifier.</param> - /// <returns>SyncJobItem.</returns> - SyncJobItem GetJobItem(string id); - - /// <summary> - /// Creates the specified job item. - /// </summary> - /// <param name="jobItem">The job item.</param> - /// <returns>Task.</returns> - Task Create(SyncJobItem jobItem); - - /// <summary> - /// Updates the specified job item. - /// </summary> - /// <param name="jobItem">The job item.</param> - /// <returns>Task.</returns> - Task Update(SyncJobItem jobItem); - - /// <summary> - /// Gets the job items. - /// </summary> - /// <param name="query">The query.</param> - /// <returns>IEnumerable<SyncJobItem>.</returns> - QueryResult<SyncJobItem> GetJobItems(SyncJobItemQuery query); - - /// <summary> - /// Gets the library item ids. - /// </summary> - /// <param name="query">The query.</param> - /// <returns>QueryResult<System.String>.</returns> - Dictionary<string, SyncedItemProgress> GetSyncedItemProgresses(SyncJobItemQuery query); - } -} |
