diff options
Diffstat (limited to 'MediaBrowser.Controller')
48 files changed, 518 insertions, 364 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/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs index f899c7262..70bdc52e6 100644 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -58,10 +58,7 @@ namespace MediaBrowser.Controller.Connect /// <summary> /// Authenticates the specified username. /// </summary> - /// <param name="username">The username.</param> - /// <param name="passwordMd5">The password MD5.</param> - /// <returns>Task.</returns> - Task<ConnectAuthenticationResult> Authenticate(string username, string passwordMd5); + Task<ConnectAuthenticationResult> Authenticate(string username, string password, string passwordMd5); /// <summary> /// Gets the local user. 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 113f823f5..d7b68d1e7 100644 --- a/MediaBrowser.Controller/Drawing/IImageProcessor.cs +++ b/MediaBrowser.Controller/Drawing/IImageProcessor.cs @@ -118,5 +118,7 @@ namespace MediaBrowser.Controller.Drawing IImageEncoder ImageEncoder { get; set; } void SaveImageSize(string path, DateTime imageDateModified, ImageSize size); + + bool SupportsTransparency(string path); } } diff --git a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs index fac21c744..26283b5ea 100644 --- a/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs +++ b/MediaBrowser.Controller/Drawing/ImageProcessingOptions.cs @@ -10,6 +10,11 @@ namespace MediaBrowser.Controller.Drawing { public class ImageProcessingOptions { + public ImageProcessingOptions() + { + RequiresAutoOrientation = true; + } + public string ItemId { get; set; } public string ItemType { get; set; } public IHasMetadata Item { get; set; } @@ -32,7 +37,7 @@ namespace MediaBrowser.Controller.Drawing public List<IImageEnhancer> Enhancers { get; set; } - public List<ImageFormat> SupportedOutputFormats { get; set; } + public ImageFormat[] SupportedOutputFormats { get; set; } public bool AddPlayedIndicator { get; set; } @@ -43,6 +48,7 @@ namespace MediaBrowser.Controller.Drawing public string BackgroundColor { get; set; } public string ForegroundLayer { get; set; } + public bool RequiresAutoOrientation { get; set; } public bool HasDefaultOptions(string originalImagePath) { 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/IDtoService.cs b/MediaBrowser.Controller/Dto/IDtoService.cs index 76ecd8180..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 @@ -40,7 +39,6 @@ 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, ItemFields[] fields, User user = null, BaseItem owner = null); /// <summary> @@ -60,10 +58,9 @@ 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<BaseItemDto[]> GetBaseItemDtos(BaseItem[] items, DtoOptions options, User user = null, BaseItem owner = null); + BaseItemDto[] GetBaseItemDtos(BaseItem[] items, DtoOptions options, User user = null, BaseItem owner = null); - Task<BaseItemDto[]> GetBaseItemDtos(List<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. diff --git a/MediaBrowser.Controller/Entities/AggregateFolder.cs b/MediaBrowser.Controller/Entities/AggregateFolder.cs index 2105ef907..00fac1eab 100644 --- a/MediaBrowser.Controller/Entities/AggregateFolder.cs +++ b/MediaBrowser.Controller/Entities/AggregateFolder.cs @@ -137,7 +137,7 @@ namespace MediaBrowser.Controller.Entities { FileInfo = FileSystem.GetDirectoryInfo(path), Path = path, - Parent = Parent + Parent = GetParent() as Folder }; // Gather child folder and files diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 3ebf4da00..02a9f15a9 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -154,46 +154,28 @@ namespace MediaBrowser.Controller.Entities.Audio { var list = base.GetUserDataKeys(); - if (ConfigurationManager.Configuration.EnableStandaloneMusicKeys) - { - var songKey = IndexNumber.HasValue ? IndexNumber.Value.ToString("0000") : string.Empty; - - - if (ParentIndexNumber.HasValue) - { - songKey = ParentIndexNumber.Value.ToString("0000") + "-" + songKey; - } - songKey += Name; + var songKey = IndexNumber.HasValue ? IndexNumber.Value.ToString("0000") : string.Empty; - if (!string.IsNullOrWhiteSpace(Album)) - { - songKey = Album + "-" + songKey; - } - - var albumArtist = AlbumArtists.Length == 0 ? null : AlbumArtists[0]; - if (!string.IsNullOrWhiteSpace(albumArtist)) - { - songKey = albumArtist + "-" + songKey; - } - list.Insert(0, songKey); - } - else + if (ParentIndexNumber.HasValue) { - var parent = AlbumEntity; + songKey = ParentIndexNumber.Value.ToString("0000") + "-" + songKey; + } + songKey += Name; - if (parent != null && IndexNumber.HasValue) - { - list.InsertRange(0, parent.GetUserDataKeys().Select(i => - { - var songKey = (ParentIndexNumber != null ? ParentIndexNumber.Value.ToString("0000 - ") : "") - + IndexNumber.Value.ToString("0000 - "); + if (!string.IsNullOrWhiteSpace(Album)) + { + songKey = Album + "-" + songKey; + } - return i + songKey; - })); - } + var albumArtist = AlbumArtists.Length == 0 ? null : AlbumArtists[0]; + if (!string.IsNullOrWhiteSpace(albumArtist)) + { + songKey = albumArtist + "-" + songKey; } + list.Insert(0, songKey); + return list; } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs index 7af8161ca..acda9ae02 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicAlbum.cs @@ -145,13 +145,10 @@ namespace MediaBrowser.Controller.Entities.Audio { var list = base.GetUserDataKeys(); - if (ConfigurationManager.Configuration.EnableStandaloneMusicKeys) + var albumArtist = AlbumArtist; + if (!string.IsNullOrWhiteSpace(albumArtist)) { - var albumArtist = AlbumArtist; - if (!string.IsNullOrWhiteSpace(albumArtist)) - { - list.Insert(0, albumArtist + "-" + Name); - } + list.Insert(0, albumArtist + "-" + Name); } var id = this.GetProviderId(MetadataProviders.MusicBrainzAlbum); diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 513b85d8b..502ba6c60 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -97,7 +97,7 @@ namespace MediaBrowser.Controller.Entities public string Tagline { get; set; } [IgnoreDataMember] - public ItemImageInfo[] ImageInfos { get; set; } + public virtual ItemImageInfo[] ImageInfos { get; set; } [IgnoreDataMember] public bool IsVirtualItem { get; set; } @@ -187,21 +187,6 @@ 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; } @@ -231,6 +216,9 @@ namespace MediaBrowser.Controller.Entities [IgnoreDataMember] public Guid Id { get; set; } + [IgnoreDataMember] + public Guid OwnerId { get; set; } + /// <summary> /// Gets or sets a value indicating whether this instance is hd. /// </summary> @@ -336,12 +324,31 @@ namespace MediaBrowser.Controller.Entities { get { + if (OwnerId != Guid.Empty) + { + return true; + } + + // legacy + // Local trailer, special feature, theme video, etc. // An item that belongs to another item but is not part of the Parent-Child tree - return !IsFolder && ParentId == Guid.Empty && LocationType == LocationType.FileSystem; + // This is a hack for now relying on ExtraType. Eventually we may need to persist this + if (ParentId == Guid.Empty && !IsFolder && LocationType == LocationType.FileSystem) + { + return true; + } + + return false; } } + public BaseItem GetOwner() + { + var ownerId = OwnerId; + return ownerId == Guid.Empty ? null : LibraryManager.GetItemById(ownerId); + } + /// <summary> /// Gets or sets the type of the location. /// </summary> @@ -664,27 +671,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); } @@ -735,17 +749,12 @@ namespace MediaBrowser.Controller.Entities ParentId = parent == null ? Guid.Empty : parent.Id; } - [IgnoreDataMember] - public IEnumerable<Folder> Parents - { - get { return GetParents().OfType<Folder>(); } - } - public BaseItem GetParent() { - if (ParentId != Guid.Empty) + var parentId = ParentId; + if (parentId != Guid.Empty) { - return LibraryManager.GetItemById(ParentId); + return LibraryManager.GetItemById(parentId); } return null; @@ -771,7 +780,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] @@ -779,11 +796,13 @@ namespace MediaBrowser.Controller.Entities { get { - if (ParentId == Guid.Empty) + var parentId = ParentId; + + if (parentId == Guid.Empty) { return null; } - return ParentId; + return parentId; } } @@ -918,9 +937,10 @@ namespace MediaBrowser.Controller.Entities { get { - if (!string.IsNullOrWhiteSpace(OfficialRating)) + var officialRating = OfficialRating; + if (!string.IsNullOrWhiteSpace(officialRating)) { - return OfficialRating; + return officialRating; } var parent = DisplayParent; @@ -938,9 +958,10 @@ namespace MediaBrowser.Controller.Entities { get { - if (!string.IsNullOrWhiteSpace(CustomRating)) + var customRating = CustomRating; + if (!string.IsNullOrWhiteSpace(customRating)) { - return CustomRating; + return customRating; } var parent = DisplayParent; @@ -1000,8 +1021,11 @@ namespace MediaBrowser.Controller.Entities { audio = dbItem; } - - audio.ExtraType = MediaBrowser.Model.Entities.ExtraType.ThemeSong; + else + { + // item is new + audio.ExtraType = MediaBrowser.Model.Entities.ExtraType.ThemeSong; + } return audio; @@ -1030,8 +1054,11 @@ namespace MediaBrowser.Controller.Entities { item = dbItem; } - - item.ExtraType = MediaBrowser.Model.Entities.ExtraType.ThemeVideo; + else + { + // item is new + item.ExtraType = MediaBrowser.Model.Entities.ExtraType.ThemeVideo; + } return item; @@ -1176,8 +1203,25 @@ namespace MediaBrowser.Controller.Entities var newItemIds = newItems.Select(i => i.Id).ToArray(); var itemsChanged = !item.LocalTrailerIds.SequenceEqual(newItemIds); + var ownerId = item.Id; + + var tasks = newItems.Select(i => + { + var subOptions = new MetadataRefreshOptions(options); + + if (!i.ExtraType.HasValue || + i.ExtraType.Value != Model.Entities.ExtraType.Trailer || + i.OwnerId != ownerId || + i.ParentId != Guid.Empty) + { + i.ExtraType = Model.Entities.ExtraType.Trailer; + i.OwnerId = ownerId; + i.ParentId = Guid.Empty; + subOptions.ForceSave = true; + } - var tasks = newItems.Select(i => RefreshMetadataForOwnedItem(i, true, options, cancellationToken)); + return RefreshMetadataForOwnedItem(i, true, subOptions, cancellationToken); + }); await Task.WhenAll(tasks).ConfigureAwait(false); @@ -1194,13 +1238,20 @@ namespace MediaBrowser.Controller.Entities var themeVideosChanged = !item.ThemeVideoIds.SequenceEqual(newThemeVideoIds); + var ownerId = item.Id; + var tasks = newThemeVideos.Select(i => { var subOptions = new MetadataRefreshOptions(options); - if (!i.IsThemeMedia) + if (!i.ExtraType.HasValue || + i.ExtraType.Value != Model.Entities.ExtraType.ThemeVideo || + i.OwnerId != ownerId || + i.ParentId != Guid.Empty) { - i.ExtraType = MediaBrowser.Model.Entities.ExtraType.ThemeVideo; + i.ExtraType = Model.Entities.ExtraType.ThemeVideo; + i.OwnerId = ownerId; + i.ParentId = Guid.Empty; subOptions.ForceSave = true; } @@ -1224,13 +1275,20 @@ namespace MediaBrowser.Controller.Entities var themeSongsChanged = !item.ThemeSongIds.SequenceEqual(newThemeSongIds); + var ownerId = item.Id; + var tasks = newThemeSongs.Select(i => { var subOptions = new MetadataRefreshOptions(options); - if (!i.IsThemeMedia) + if (!i.ExtraType.HasValue || + i.ExtraType.Value != Model.Entities.ExtraType.ThemeSong || + i.OwnerId != ownerId || + i.ParentId != Guid.Empty) { - i.ExtraType = MediaBrowser.Model.Entities.ExtraType.ThemeSong; + i.ExtraType = Model.Entities.ExtraType.ThemeSong; + i.OwnerId = ownerId; + i.ParentId = Guid.Empty; subOptions.ForceSave = true; } @@ -1866,7 +1924,6 @@ namespace MediaBrowser.Controller.Entities { existingImage.Path = image.Path; existingImage.DateModified = image.DateModified; - existingImage.IsPlaceholder = image.IsPlaceholder; } else @@ -1900,7 +1957,6 @@ namespace MediaBrowser.Controller.Entities image.Path = file.FullName; image.DateModified = imageInfo.DateModified; - image.IsPlaceholder = false; } } @@ -2140,8 +2196,8 @@ 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(extensions.Count), false, false) .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase)) @@ -2357,6 +2413,14 @@ namespace MediaBrowser.Controller.Entities newOptions.ForceSave = true; } + //var parentId = Id; + //if (!video.IsOwnedItem || video.ParentId != parentId) + //{ + // video.IsOwnedItem = true; + // video.ParentId = parentId; + // newOptions.ForceSave = true; + //} + if (video == null) { return Task.FromResult(true); @@ -2392,7 +2456,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] @@ -2473,5 +2544,21 @@ namespace MediaBrowser.Controller.Entities { return null; } + + public virtual ItemUpdateType OnMetadataChanged() + { + var updateType = ItemUpdateType.None; + + var item = this; + + var inheritedParentalRatingValue = item.GetInheritedParentalRatingValue() ?? 0; + if (inheritedParentalRatingValue != item.InheritedParentalRatingValue) + { + item.InheritedParentalRatingValue = inheritedParentalRatingValue; + updateType |= ItemUpdateType.MetadataImport; + } + + return updateType; + } } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 537beb26b..a83e084db 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -280,7 +280,7 @@ namespace MediaBrowser.Controller.Entities { FileInfo = FileSystem.GetDirectoryInfo(path), Path = path, - Parent = Parent, + Parent = GetParent() as Folder, CollectionType = CollectionType }; diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 8a87f3c6a..6d88f7015 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -378,6 +378,7 @@ namespace MediaBrowser.Controller.Entities cancellationToken.ThrowIfCancellationRequested(); var validChildren = new List<BaseItem>(); + var validChildrenNeedGeneration = false; var allLibraryPaths = LibraryManager .GetVirtualFolders() @@ -474,11 +475,7 @@ namespace MediaBrowser.Controller.Entities } else { - if (recursive || refreshChildMetadata) - { - // used below - validChildren = Children.ToList(); - } + validChildrenNeedGeneration = true; } progress.Report(10); @@ -502,6 +499,12 @@ namespace MediaBrowser.Controller.Entities ProviderManager.OnRefreshProgress(folder, newPct); }); + if (validChildrenNeedGeneration) + { + validChildren = Children.ToList(); + validChildrenNeedGeneration = false; + } + await ValidateSubFolders(validChildren.OfType<Folder>().ToList(), directoryService, innerProgress, cancellationToken).ConfigureAwait(false); } } @@ -536,6 +539,12 @@ namespace MediaBrowser.Controller.Entities } else { + if (validChildrenNeedGeneration) + { + validChildren = Children.ToList(); + validChildrenNeedGeneration = false; + } + await RefreshMetadataRecursive(validChildren, refreshOptions, recursive, innerProgress, cancellationToken); } } @@ -565,7 +574,7 @@ namespace MediaBrowser.Controller.Entities }); await RefreshChildMetadata(child, refreshOptions, recursive && child.IsFolder, innerProgress, cancellationToken) - .ConfigureAwait(false); + .ConfigureAwait(false); } numComplete++; @@ -588,7 +597,10 @@ namespace MediaBrowser.Controller.Entities } else { - await child.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); + if (refreshOptions.RefreshItem(child)) + { + await child.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); + } if (recursive) { @@ -952,7 +964,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(); @@ -973,7 +985,7 @@ namespace MediaBrowser.Controller.Entities { var result = LibraryManager.GetItemList(query); - if (query.SortBy.Length == 0) + if (query.OrderBy.Length == 0) { var ids = query.ItemIds.ToList(); @@ -1000,8 +1012,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; } @@ -1197,11 +1208,21 @@ namespace MediaBrowser.Controller.Entities /// Gets the linked children. /// </summary> /// <returns>IEnumerable{BaseItem}.</returns> - public IEnumerable<BaseItem> GetLinkedChildren() + public List<BaseItem> GetLinkedChildren() { - return LinkedChildren - .Select(GetLinkedChild) - .Where(i => i != null); + var linkedChildren = LinkedChildren; + var list = new List<BaseItem>(linkedChildren.Length); + + foreach (var i in linkedChildren) + { + var child = GetLinkedChild(i); + + if (child != null) + { + list.Add(child); + } + } + return list; } protected virtual bool FilterLinkedChildrenPerUser @@ -1212,16 +1233,19 @@ namespace MediaBrowser.Controller.Entities } } - public IEnumerable<BaseItem> GetLinkedChildren(User user) + public List<BaseItem> GetLinkedChildren(User user) { if (!FilterLinkedChildrenPerUser || user == null) { return GetLinkedChildren(); } - if (LinkedChildren.Length == 0) + var linkedChildren = LinkedChildren; + var list = new List<BaseItem>(linkedChildren.Length); + + if (linkedChildren.Length == 0) { - return new List<BaseItem>(); + return list; } var allUserRootChildren = user.RootFolder.Children.OfType<Folder>().ToList(); @@ -1232,37 +1256,43 @@ namespace MediaBrowser.Controller.Entities .Select(i => i.Id) .ToList(); - return LinkedChildren - .Select(i => + foreach (var i in linkedChildren) + { + var child = GetLinkedChild(i); + + if (child == null) { - var child = GetLinkedChild(i); + continue; + } + + var childOwner = child.IsOwnedItem ? (child.GetOwner() ?? child) : child; - if (child != null) + if (childOwner != null) + { + var childLocationType = childOwner.LocationType; + if (childLocationType == LocationType.Remote || childLocationType == LocationType.Virtual) { - var childLocationType = child.LocationType; - if (childLocationType == LocationType.Remote || childLocationType == LocationType.Virtual) + if (!childOwner.IsVisibleStandalone(user)) { - if (!child.IsVisibleStandalone(user)) - { - return null; - } + continue; } - else if (childLocationType == LocationType.FileSystem) - { - var itemCollectionFolderIds = - LibraryManager.GetCollectionFolders(child, allUserRootChildren) - .Select(f => f.Id).ToList(); + } + else if (childLocationType == LocationType.FileSystem) + { + var itemCollectionFolderIds = + LibraryManager.GetCollectionFolders(childOwner, allUserRootChildren).Select(f => f.Id); - if (!itemCollectionFolderIds.Any(collectionFolderIds.Contains)) - { - return null; - } + if (!itemCollectionFolderIds.Any(collectionFolderIds.Contains)) + { + continue; } } + } + + list.Add(child); + } - return child; - }) - .Where(i => i != null); + return list; } /// <summary> diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 59d9bd9f9..4146686b2 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -266,6 +266,8 @@ namespace MediaBrowser.Controller.Entities int? ProductionYear { get; set; } string[] Tags { get; set; } + + ItemUpdateType OnMetadataChanged(); } public static class HasMetadataExtensions diff --git a/MediaBrowser.Controller/Entities/IHasProgramAttributes.cs b/MediaBrowser.Controller/Entities/IHasProgramAttributes.cs index 106b8bce4..90786d44d 100644 --- a/MediaBrowser.Controller/Entities/IHasProgramAttributes.cs +++ b/MediaBrowser.Controller/Entities/IHasProgramAttributes.cs @@ -15,5 +15,6 @@ namespace MediaBrowser.Controller.Entities bool IsPremiere { get; set; } ProgramAudio? Audio { get; set; } string EpisodeTitle { get; set; } + string ServiceName { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/IHasTrailers.cs b/MediaBrowser.Controller/Entities/IHasTrailers.cs index 8686c802a..07dde3789 100644 --- a/MediaBrowser.Controller/Entities/IHasTrailers.cs +++ b/MediaBrowser.Controller/Entities/IHasTrailers.cs @@ -5,7 +5,7 @@ using System.Linq; namespace MediaBrowser.Controller.Entities { - public interface IHasTrailers : IHasProviderIds + public interface IHasTrailers : IHasMetadata { /// <summary> /// Gets or sets the remote trailers. diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 04833d049..a7f6c6014 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; } @@ -164,8 +160,9 @@ namespace MediaBrowser.Controller.Entities public bool ForceDirect { get; set; } public Dictionary<string, string> ExcludeProviderIds { get; set; } public bool EnableGroupByMetadataKey { get; set; } + public bool? HasChapterImages { 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; } @@ -173,6 +170,10 @@ namespace MediaBrowser.Controller.Entities public DtoOptions DtoOptions { get; set; } public int MinSimilarityScore { get; set; } + public string HasNoAudioTrackWithLanguage { get; set; } + public string HasNoInternalSubtitleTrackWithLanguage { get; set; } + public string HasNoExternalSubtitleTrackWithLanguage { get; set; } + public string HasNoSubtitleTrackWithLanguage { get; set; } public InternalItemsQuery() { @@ -190,7 +191,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,7 +213,7 @@ namespace MediaBrowser.Controller.Entities TrailerTypes = new TrailerType[] { }; SourceTypes = new SourceType[] { }; SeriesStatuses = new SeriesStatus[] { }; - OrderBy = new List<Tuple<string, SortOrder>>(); + OrderBy = new Tuple<string, SortOrder>[] { }; } public InternalItemsQuery(User user) diff --git a/MediaBrowser.Controller/Entities/ItemImageInfo.cs b/MediaBrowser.Controller/Entities/ItemImageInfo.cs index 672595db8..6b2d2392d 100644 --- a/MediaBrowser.Controller/Entities/ItemImageInfo.cs +++ b/MediaBrowser.Controller/Entities/ItemImageInfo.cs @@ -24,12 +24,6 @@ namespace MediaBrowser.Controller.Entities /// <value>The date modified.</value> public DateTime DateModified { get; set; } - /// <summary> - /// Gets or sets a value indicating whether this instance is placeholder. - /// </summary> - /// <value><c>true</c> if this instance is placeholder; otherwise, <c>false</c>.</value> - public bool IsPlaceholder { get; set; } - [IgnoreDataMember] public bool IsLocalFile { diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 900e8a664..bd8d9024d 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -80,16 +80,44 @@ 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>(); } [IgnoreDataMember] + private bool IsLegacyBoxSet + { + get + { + if (string.IsNullOrWhiteSpace(Path)) + { + return false; + } + + if (LinkedChildren.Length > 0) + { + return false; + } + + return !FileSystem.ContainsSubPath(ConfigurationManager.ApplicationPaths.DataPath, Path); + } + } + + [IgnoreDataMember] public override bool IsPreSorted { get diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs index 3a41709fe..2e0e01944 100644 --- a/MediaBrowser.Controller/Entities/Movies/Movie.cs +++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs @@ -81,7 +81,20 @@ namespace MediaBrowser.Controller.Entities.Movies var itemsChanged = !SpecialFeatureIds.SequenceEqual(newItemIds); - var tasks = newItems.Select(i => RefreshMetadataForOwnedItem(i, false, options, cancellationToken)); + var ownerId = Id; + + var tasks = newItems.Select(i => + { + var subOptions = new MetadataRefreshOptions(options); + + if (i.OwnerId != ownerId) + { + i.OwnerId = ownerId; + subOptions.ForceSave = true; + } + + return RefreshMetadataForOwnedItem(i, false, subOptions, cancellationToken); + }); await Task.WhenAll(tasks).ConfigureAwait(false); diff --git a/MediaBrowser.Controller/Entities/TV/Series.cs b/MediaBrowser.Controller/Entities/TV/Series.cs index 6514d31d2..5931c32e1 100644 --- a/MediaBrowser.Controller/Entities/TV/Series.cs +++ b/MediaBrowser.Controller/Entities/TV/Series.cs @@ -252,7 +252,7 @@ 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) { @@ -275,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) { @@ -301,7 +301,7 @@ 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; @@ -347,7 +347,10 @@ namespace MediaBrowser.Controller.Entities.TV cancellationToken.ThrowIfCancellationRequested(); - await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); + if (refreshOptions.RefreshItem(item)) + { + await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); + } numComplete++; double percent = numComplete; @@ -382,7 +385,10 @@ namespace MediaBrowser.Controller.Entities.TV if (!skipItem) { - await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); + if (refreshOptions.RefreshItem(item)) + { + await item.RefreshMetadata(refreshOptions, cancellationToken).ConfigureAwait(false); + } } numComplete++; @@ -410,7 +416,7 @@ 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) @@ -453,7 +459,7 @@ namespace MediaBrowser.Controller.Entities.TV return episodes.Where(episode => { - var episodeItem = (Episode) episode; + var episodeItem = (Episode)episode; var currentSeasonNumber = supportSpecialsInSeason ? episodeItem.AiredSeasonNumber : episode.ParentIndexNumber; if (currentSeasonNumber.HasValue && seasonNumber.HasValue && currentSeasonNumber.Value == seasonNumber.Value) diff --git a/MediaBrowser.Controller/Entities/User.cs b/MediaBrowser.Controller/Entities/User.cs index 3c89037cc..e9a794e79 100644 --- a/MediaBrowser.Controller/Entities/User.cs +++ b/MediaBrowser.Controller/Entities/User.cs @@ -30,12 +30,26 @@ namespace MediaBrowser.Controller.Entities /// <value>The password.</value> public string Password { get; set; } public string EasyPassword { get; set; } + public string Salt { get; set; } public string ConnectUserName { get; set; } public string ConnectUserId { get; set; } public UserLinkType? ConnectLinkType { get; set; } public string ConnectAccessKey { get; set; } + // Strictly to remove IgnoreDataMember + public override ItemImageInfo[] ImageInfos + { + get + { + return base.ImageInfos; + } + set + { + base.ImageInfos = value; + } + } + /// <summary> /// Gets or sets the path. /// </summary> diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index acfa239d3..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; @@ -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; @@ -1104,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(); diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 86b52bd77..e9f7d5932 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -22,12 +22,6 @@ namespace MediaBrowser.Controller Task<SystemInfo> GetSystemInfo(); /// <summary> - /// Gets a value indicating whether this instance is running as service. - /// </summary> - /// <value><c>true</c> if this instance is running as service; otherwise, <c>false</c>.</value> - bool IsRunningAsService { get; } - - /// <summary> /// Gets a value indicating whether [supports automatic run at startup]. /// </summary> /// <value><c>true</c> if [supports automatic run at startup]; otherwise, <c>false</c>.</value> @@ -90,5 +84,7 @@ namespace MediaBrowser.Controller void LaunchUrl(string url); void EnableLoopback(string appName); + + string PackageRuntime { get; } } } diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index 265d4d786..3001e3366 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -181,8 +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); + 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. @@ -563,8 +563,6 @@ namespace MediaBrowser.Controller.Library QueryResult<Tuple<BaseItem, ItemCounts>> GetAlbumArtists(InternalItemsQuery query); QueryResult<Tuple<BaseItem, ItemCounts>> GetAllArtists(InternalItemsQuery query); - void RegisterIgnoredPath(string path); - void UnRegisterIgnoredPath(string path); int GetCount(InternalItemsQuery query); } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Library/IUserManager.cs b/MediaBrowser.Controller/Library/IUserManager.cs index 6da3e53aa..d4232c77e 100644 --- a/MediaBrowser.Controller/Library/IUserManager.cs +++ b/MediaBrowser.Controller/Library/IUserManager.cs @@ -59,16 +59,6 @@ namespace MediaBrowser.Controller.Library User GetUserByName(string name); /// <summary> - /// Authenticates a User and returns a result indicating whether or not it succeeded - /// </summary> - /// <param name="username">The username.</param> - /// <param name="passwordSha1">The password sha1.</param> - /// <param name="remoteEndPoint">The remote end point.</param> - /// <returns>Task{System.Boolean}.</returns> - /// <exception cref="System.ArgumentNullException">user</exception> - Task<User> AuthenticateUser(string username, string passwordSha1, string remoteEndPoint); - - /// <summary> /// Refreshes metadata for each user /// </summary> /// <param name="cancellationToken">The cancellation token.</param> @@ -135,18 +125,12 @@ namespace MediaBrowser.Controller.Library /// <summary> /// Changes the password. /// </summary> - /// <param name="user">The user.</param> - /// <param name="newPasswordSha1">The new password sha1.</param> - /// <returns>Task.</returns> - void ChangePassword(User user, string newPasswordSha1); + void ChangePassword(User user, string newPassword, string newPasswordSha1); /// <summary> /// Changes the easy password. /// </summary> - /// <param name="user">The user.</param> - /// <param name="newPasswordSha1">The new password sha1.</param> - /// <returns>Task.</returns> - void ChangeEasyPassword(User user, string newPasswordSha1); + void ChangeEasyPassword(User user, string newPassword, string newPasswordSha1); /// <summary> /// Gets the user dto. @@ -159,12 +143,7 @@ namespace MediaBrowser.Controller.Library /// <summary> /// Authenticates the user. /// </summary> - /// <param name="username">The username.</param> - /// <param name="passwordSha1">The password sha1.</param> - /// <param name="passwordMd5">The password MD5.</param> - /// <param name="remoteEndPoint">The remote end point.</param> - /// <returns>Task<System.Boolean>.</returns> - Task<User> AuthenticateUser(string username, string passwordSha1, string passwordMd5, string remoteEndPoint); + Task<User> AuthenticateUser(string username, string password, string passwordSha1, string passwordMd5, string remoteEndPoint); /// <summary> /// Starts the forgot password process. diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs b/MediaBrowser.Controller/LiveTv/ILiveTvManager.cs index 6ff630590..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. @@ -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]. diff --git a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs index 4b757f0b9..ed3b74bf9 100644 --- a/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs +++ b/MediaBrowser.Controller/LiveTv/ILiveTvRecording.cs @@ -42,7 +42,6 @@ namespace MediaBrowser.Controller.LiveTv 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/LiveStream.cs b/MediaBrowser.Controller/LiveTv/LiveStream.cs index b90d0e3d2..20947462e 100644 --- a/MediaBrowser.Controller/LiveTv/LiveStream.cs +++ b/MediaBrowser.Controller/LiveTv/LiveStream.cs @@ -51,7 +51,7 @@ namespace MediaBrowser.Controller.LiveTv return Task.FromResult(true); } - protected Stream GetInputStream(string path, long startPosition, bool allowAsyncFileRead) + protected Stream GetInputStream(string path, bool allowAsyncFileRead) { var fileOpenOptions = FileOpenOptions.SequentialScan; diff --git a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs index c29d73253..8fa96076b 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvAudioRecording.cs @@ -91,20 +91,7 @@ namespace MediaBrowser.Controller.LiveTv public override double? GetDefaultPrimaryImageAspectRatio() { - if (IsMovie) - { - double value = 2; - value /= 3; - - return value; - } - else - { - double value = 2; - value /= 3; - - return value; - } + return LiveTvProgram.GetDefaultPrimaryImageAspectRatio(this); } public override string GetClientTypeName() diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index 1607dbcba..1c1637330 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -47,19 +47,31 @@ namespace MediaBrowser.Controller.LiveTv return list; } - private static string EmbyServiceName = "Emby"; - public override double? GetDefaultPrimaryImageAspectRatio() + public static double? GetDefaultPrimaryImageAspectRatio(IHasProgramAttributes item) { - var serviceName = ServiceName; - if (!IsMovie && !string.Equals(serviceName, EmbyServiceName, StringComparison.OrdinalIgnoreCase) || !string.IsNullOrWhiteSpace(serviceName)) + var serviceName = item.ServiceName; + if (!item.IsMovie + && !string.Equals(serviceName, EmbyServiceName, StringComparison.OrdinalIgnoreCase) + && !string.Equals(serviceName, "Next Pvr", StringComparison.OrdinalIgnoreCase)) { - return null; + double value = 16; + value /= 9; + + return value; } + else + { + double value = 2; + value /= 3; - double value = 2; - value /= 3; + return value; + } + } - return value; + private static string EmbyServiceName = "Emby"; + public override double? GetDefaultPrimaryImageAspectRatio() + { + return GetDefaultPrimaryImageAspectRatio(this); } [IgnoreDataMember] @@ -88,6 +100,9 @@ namespace MediaBrowser.Controller.LiveTv [IgnoreDataMember] public string EpisodeTitle { get; set; } + [IgnoreDataMember] + public string ShowId { get; set; } + /// <summary> /// Gets or sets a value indicating whether this instance is movie. /// </summary> diff --git a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs index 950949f37..c5fe7b1b3 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvVideoRecording.cs @@ -100,20 +100,7 @@ namespace MediaBrowser.Controller.LiveTv public override double? GetDefaultPrimaryImageAspectRatio() { - if (IsMovie) - { - double value = 2; - value /= 3; - - return value; - } - else - { - double value = 2; - value /= 3; - - return value; - } + return LiveTvProgram.GetDefaultPrimaryImageAspectRatio(this); } [IgnoreDataMember] diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index 26766f51a..5ef763b62 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -183,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" /> diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 736f1b32f..657b9c959 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -56,10 +56,14 @@ namespace MediaBrowser.Controller.MediaEncoding { return GetAvailableEncoder("h264_nvenc", defaultEncoder); } - if (string.Equals(hwType, "h264_omx", StringComparison.OrdinalIgnoreCase)) + if (string.Equals(hwType, "omx", StringComparison.OrdinalIgnoreCase)) { return GetAvailableEncoder("h264_omx", defaultEncoder); } + if (string.Equals(hwType, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase)) + { + return GetAvailableEncoder("h264_v4l2m2m", defaultEncoder); + } if (string.Equals(hwType, "vaapi", StringComparison.OrdinalIgnoreCase) && !string.IsNullOrWhiteSpace(encodingOptions.VaapiDevice)) { if (IsVaapiSupported(state)) @@ -692,7 +696,8 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.IsNullOrEmpty(request.Profile)) { if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase) && - !string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) + !string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) && + !string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase)) { // not supported by h264_omx param += " -profile:v " + request.Profile; @@ -761,11 +766,17 @@ namespace MediaBrowser.Controller.MediaEncoding if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase) && !string.Equals(videoEncoder, "h264_qsv", StringComparison.OrdinalIgnoreCase) && - !string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) + !string.Equals(videoEncoder, "h264_vaapi", StringComparison.OrdinalIgnoreCase) && + !string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase)) { param = "-pix_fmt yuv420p " + param; } + if (string.Equals(videoEncoder, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase)) + { + param = "-pix_fmt nv21 " + param; + } + return param; } @@ -1021,11 +1032,11 @@ namespace MediaBrowser.Controller.MediaEncoding { if (sourceBitrate <= 2000000) { - sourceBitrate *= 2; + sourceBitrate = Convert.ToInt32(sourceBitrate * 2.5); } else if (sourceBitrate <= 3000000) { - sourceBitrate = Convert.ToInt32(sourceBitrate * 1.5); + sourceBitrate = Convert.ToInt32(sourceBitrate * 2); } var bitrate = Math.Min(sourceBitrate, requestedBitrate); @@ -1277,10 +1288,7 @@ namespace MediaBrowser.Controller.MediaEncoding /// <summary> /// Gets the internal graphical subtitle param. /// </summary> - /// <param name="state">The state.</param> - /// <param name="outputVideoCodec">The output video codec.</param> - /// <returns>System.String.</returns> - public string GetGraphicalSubtitleParam(EncodingJobInfo state, string outputVideoCodec) + public string GetGraphicalSubtitleParam(EncodingJobInfo state, EncodingOptions options, string outputVideoCodec) { var outputSizeParam = string.Empty; @@ -1289,7 +1297,7 @@ namespace MediaBrowser.Controller.MediaEncoding // Add resolution params, if specified if (request.Width.HasValue || request.Height.HasValue || request.MaxHeight.HasValue || request.MaxWidth.HasValue) { - outputSizeParam = GetOutputSizeParam(state, outputVideoCodec).TrimEnd('"'); + outputSizeParam = GetOutputSizeParam(state, options, outputVideoCodec).TrimEnd('"'); if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { @@ -1332,11 +1340,8 @@ namespace MediaBrowser.Controller.MediaEncoding /// <summary> /// If we're going to put a fixed size on the command line, this will calculate it /// </summary> - /// <param name="state">The state.</param> - /// <param name="outputVideoCodec">The output video codec.</param> - /// <param name="allowTimeStampCopy">if set to <c>true</c> [allow time stamp copy].</param> - /// <returns>System.String.</returns> public string GetOutputSizeParam(EncodingJobInfo state, + EncodingOptions options, string outputVideoCodec, bool allowTimeStampCopy = true) { @@ -1354,7 +1359,14 @@ namespace MediaBrowser.Controller.MediaEncoding if (state.DeInterlace && !string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) { - filters.Add("yadif=0:-1:0"); + if (string.Equals(options.DeinterlaceMethod, "bobandweave", StringComparison.OrdinalIgnoreCase)) + { + filters.Add("yadif=1:-1:0"); + } + else + { + filters.Add("yadif=0:-1:0"); + } } if (string.Equals(outputVideoCodec, "h264_vaapi", StringComparison.OrdinalIgnoreCase)) @@ -1389,13 +1401,22 @@ namespace MediaBrowser.Controller.MediaEncoding } else { + var isExynosV4L2 = string.Equals(outputVideoCodec, "h264_v4l2m2m", StringComparison.OrdinalIgnoreCase); + // If fixed dimensions were supplied if (request.Width.HasValue && request.Height.HasValue) { var widthParam = request.Width.Value.ToString(_usCulture); var heightParam = request.Height.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc({0}/2)*2:trunc({1}/2)*2", widthParam, heightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc({0}/64)*64:trunc({1}/2)*2", widthParam, heightParam)); + } + else + { + filters.Add(string.Format("scale=trunc({0}/2)*2:trunc({1}/2)*2", widthParam, heightParam)); + } } // If Max dimensions were supplied, for width selects lowest even number between input width and width req size and selects lowest even number from in width*display aspect and requested size @@ -1404,7 +1425,14 @@ namespace MediaBrowser.Controller.MediaEncoding var maxWidthParam = request.MaxWidth.Value.ToString(_usCulture); var maxHeightParam = request.MaxHeight.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/2)*2:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/64)*64:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam)); + } + else + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,min({0}\\,{1}*dar))/2)*2:trunc(min(max(iw/dar\\,ih)\\,min({0}/dar\\,{1}))/2)*2", maxWidthParam, maxHeightParam)); + } } // If a fixed width was requested @@ -1420,7 +1448,14 @@ namespace MediaBrowser.Controller.MediaEncoding { var heightParam = request.Height.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(oh*a/2)*2:{0}", heightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(oh*a/64)*64:{0}", heightParam)); + } + else + { + filters.Add(string.Format("scale=trunc(oh*a/2)*2:{0}", heightParam)); + } } // If a max width was requested @@ -1428,7 +1463,14 @@ namespace MediaBrowser.Controller.MediaEncoding { var maxWidthParam = request.MaxWidth.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/2)*2:trunc(ow/dar/2)*2", maxWidthParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/64)*64:trunc(ow/dar/2)*2", maxWidthParam)); + } + else + { + filters.Add(string.Format("scale=trunc(min(max(iw\\,ih*dar)\\,{0})/2)*2:trunc(ow/dar/2)*2", maxWidthParam)); + } } // If a max height was requested @@ -1436,7 +1478,14 @@ namespace MediaBrowser.Controller.MediaEncoding { var maxHeightParam = request.MaxHeight.Value.ToString(_usCulture); - filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); + if (isExynosV4L2) + { + filters.Add(string.Format("scale=trunc(oh*a/64)*64:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); + } + else + { + filters.Add(string.Format("scale=trunc(oh*a/2)*2:min(max(iw/dar\\,ih)\\,{0})", maxHeightParam)); + } } } @@ -1568,6 +1617,11 @@ namespace MediaBrowser.Controller.MediaEncoding inputModifier += " " + GetFastSeekCommandLineParameter(state.BaseRequest); inputModifier = inputModifier.Trim(); + if (state.InputProtocol == MediaProtocol.Rtsp) + { + inputModifier += " -rtsp_transport tcp"; + } + if (!string.IsNullOrEmpty(state.InputAudioSync)) { inputModifier += " -async " + state.InputAudioSync; @@ -1578,7 +1632,7 @@ namespace MediaBrowser.Controller.MediaEncoding inputModifier += " -vsync " + state.InputVideoSync; } - if (state.ReadInputAtNativeFramerate) + if (state.ReadInputAtNativeFramerate && state.InputProtocol != MediaProtocol.Rtsp) { inputModifier += " -re"; } @@ -1686,7 +1740,7 @@ namespace MediaBrowser.Controller.MediaEncoding } else { - state.PlayableStreamFileNames = new string[]{}; + state.PlayableStreamFileNames = new string[] { }; } } else @@ -1880,6 +1934,20 @@ namespace MediaBrowser.Controller.MediaEncoding break; } } + + else if (string.Equals(encodingOptions.HardwareAccelerationType, "omx", StringComparison.OrdinalIgnoreCase)) + { + switch (videoStream.Codec.ToLower()) + { + case "avc": + case "h264": + if (_mediaEncoder.SupportsDecoder("h264_mmal") && encodingOptions.HardwareDecodingCodecs.Contains("h264", StringComparer.OrdinalIgnoreCase)) + { + return "-c:v h264_mmal"; + } + break; + } + } } // leave blank so ffmpeg will decide @@ -2025,7 +2093,7 @@ namespace MediaBrowser.Controller.MediaEncoding // Add resolution params, if specified if (!hasGraphicalSubs) { - var outputSizeParam = GetOutputSizeParam(state, videoCodec); + var outputSizeParam = GetOutputSizeParam(state, encodingOptions, videoCodec); args += outputSizeParam; hasCopyTs = outputSizeParam.IndexOf("copyts", StringComparison.OrdinalIgnoreCase) != -1; } @@ -2049,7 +2117,7 @@ namespace MediaBrowser.Controller.MediaEncoding // This is for internal graphical subs if (hasGraphicalSubs) { - args += GetGraphicalSubtitleParam(state, videoCodec); + args += GetGraphicalSubtitleParam(state, encodingOptions, videoCodec); } if (!state.RunTimeTicks.HasValue) diff --git a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs b/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs index 81e294069..ecbfaecea 100644 --- a/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs +++ b/MediaBrowser.Controller/Net/AuthenticatedAttribute.cs @@ -1,5 +1,4 @@ using System; -using System.Collections.Generic; using MediaBrowser.Model.Services; namespace MediaBrowser.Controller.Net @@ -26,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> @@ -34,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> @@ -50,7 +49,7 @@ namespace MediaBrowser.Controller.Net get { return 0; } } - public IEnumerable<string> GetRoles() + public string[] GetRoles() { return (Roles ?? string.Empty).Split(new []{ ',' }, StringSplitOptions.RemoveEmptyEntries); } @@ -60,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/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index e36e6ad5d..ee96a8c3b 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -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,7 +174,7 @@ 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 diff --git a/MediaBrowser.Controller/Providers/IImageEnhancer.cs b/MediaBrowser.Controller/Providers/IImageEnhancer.cs index a993f536d..90f7296c6 100644 --- a/MediaBrowser.Controller/Providers/IImageEnhancer.cs +++ b/MediaBrowser.Controller/Providers/IImageEnhancer.cs @@ -39,6 +39,8 @@ namespace MediaBrowser.Controller.Providers /// <returns>ImageSize.</returns> ImageSize GetEnhancedImageSize(IHasMetadata item, ImageType imageType, int imageIndex, ImageSize originalImageSize); + EnhancedImageInfo GetEnhancedImageInfo(IHasMetadata item, string inputFile, ImageType imageType, int imageIndex); + /// <summary> /// Enhances the image async. /// </summary> @@ -51,4 +53,9 @@ namespace MediaBrowser.Controller.Providers /// <exception cref="System.ArgumentNullException"></exception> Task EnhanceImageAsync(IHasMetadata item, string inputFile, string outputFile, ImageType imageType, int imageIndex); } + + public class EnhancedImageInfo + { + public bool RequiresTransparency { get; set; } + } }
\ No newline at end of file diff --git a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs index 86cef628e..0df2370bd 100644 --- a/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs +++ b/MediaBrowser.Controller/Providers/MetadataRefreshOptions.cs @@ -1,5 +1,7 @@ -using System.Linq; - +using System; +using System.Collections.Generic; +using System.Linq; +using MediaBrowser.Controller.Entities; using MediaBrowser.Controller.IO; using MediaBrowser.Model.IO; using MediaBrowser.Model.Logging; @@ -20,6 +22,8 @@ namespace MediaBrowser.Controller.Providers public MetadataRefreshMode MetadataRefreshMode { get; set; } public RemoteSearchResult SearchResult { get; set; } + public List<string> RefreshPaths { get; set; } + public bool ForceSave { get; set; } public MetadataRefreshOptions(IFileSystem fileSystem) @@ -44,6 +48,26 @@ namespace MediaBrowser.Controller.Providers ReplaceAllImages = copy.ReplaceAllImages; ReplaceImages = copy.ReplaceImages.ToList(); SearchResult = copy.SearchResult; + + if (copy.RefreshPaths != null && copy.RefreshPaths.Count > 0) + { + if (RefreshPaths == null) + { + RefreshPaths = new List<string>(); + } + + RefreshPaths.AddRange(copy.RefreshPaths); + } + } + + public bool RefreshItem(BaseItem item) + { + if (RefreshPaths != null && RefreshPaths.Count > 0) + { + return RefreshPaths.Contains(item.Path ?? string.Empty, StringComparer.OrdinalIgnoreCase); + } + + return true; } } } diff --git a/MediaBrowser.Controller/Session/AuthenticationRequest.cs b/MediaBrowser.Controller/Session/AuthenticationRequest.cs index 362f5b2b9..1b684fa8f 100644 --- a/MediaBrowser.Controller/Session/AuthenticationRequest.cs +++ b/MediaBrowser.Controller/Session/AuthenticationRequest.cs @@ -5,6 +5,7 @@ namespace MediaBrowser.Controller.Session { public string Username { get; set; } public string UserId { get; set; } + public string Password { get; set; } public string PasswordSha1 { get; set; } public string PasswordMd5 { get; set; } public string App { get; set; } diff --git a/MediaBrowser.Controller/Session/SessionInfo.cs b/MediaBrowser.Controller/Session/SessionInfo.cs index 90c1de2f2..367a7a467 100644 --- a/MediaBrowser.Controller/Session/SessionInfo.cs +++ b/MediaBrowser.Controller/Session/SessionInfo.cs @@ -303,6 +303,7 @@ namespace MediaBrowser.Controller.Session StopAutomaticProgress(); _sessionManager = null; + GC.SuppressFinalize(this); } } } |
