diff options
Diffstat (limited to 'MediaBrowser.Controller')
28 files changed, 210 insertions, 154 deletions
diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 59b5a38692..92d8d95bcf 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -9,7 +9,6 @@ using System.Globalization; using System.Linq; using System.Threading; using MediaBrowser.Common.Extensions; -using MediaBrowser.Controller.Channels; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities.Audio @@ -24,8 +23,6 @@ namespace MediaBrowser.Controller.Entities.Audio IHasLookupInfo<SongInfo>, IHasMediaSources { - public List<ChannelMediaInfo> ChannelMediaSources { get; set; } - /// <summary> /// Gets or sets the artist. /// </summary> diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index e26e0dfce3..2f99e530e3 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -112,7 +112,7 @@ namespace MediaBrowser.Controller.Entities.Audio public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query) { - query.Genres = new[] { Name }; + query.GenreIds = new[] { Id.ToString("N") }; query.IncludeItemTypes = new[] { typeof(MusicVideo).Name, typeof(Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name }; return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/AudioBook.cs b/MediaBrowser.Controller/Entities/AudioBook.cs index 8b1c338f16..1bdcfb881e 100644 --- a/MediaBrowser.Controller/Entities/AudioBook.cs +++ b/MediaBrowser.Controller/Entities/AudioBook.cs @@ -31,12 +31,10 @@ namespace MediaBrowser.Controller.Entities public string SeriesName { get; set; } [IgnoreDataMember] public Guid? SeriesId { get; set; } - [IgnoreDataMember] - public string SeriesSortName { get; set; } public string FindSeriesSortName() { - return SeriesSortName; + return SeriesName; } public string FindSeriesName() { diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index c8ea4c506f..999f6db3fc 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -84,6 +84,7 @@ namespace MediaBrowser.Controller.Entities public long? Size { get; set; } public string Container { get; set; } + [IgnoreDataMember] public string Tagline { get; set; } @@ -288,7 +289,7 @@ namespace MediaBrowser.Controller.Entities return Path; } - return System.IO.Path.GetDirectoryName(Path); + return FileSystem.GetDirectoryName(Path); } } @@ -835,20 +836,6 @@ namespace MediaBrowser.Controller.Entities public float? CriticRating { get; set; } /// <summary> - /// Gets or sets the critic rating summary. - /// </summary> - /// <value>The critic rating summary.</value> - [IgnoreDataMember] - public string CriticRatingSummary { get; set; } - - /// <summary> - /// Gets or sets the official rating description. - /// </summary> - /// <value>The official rating description.</value> - [IgnoreDataMember] - public string OfficialRatingDescription { get; set; } - - /// <summary> /// Gets or sets the custom rating. /// </summary> /// <value>The custom rating.</value> @@ -1824,7 +1811,7 @@ namespace MediaBrowser.Controller.Entities /// <returns>Task.</returns> public virtual Task ChangedExternally() { - ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(FileSystem)); + ProviderManager.QueueRefresh(Id, new MetadataRefreshOptions(FileSystem), RefreshPriority.High); return Task.FromResult(true); } @@ -1924,7 +1911,7 @@ namespace MediaBrowser.Controller.Entities { var allFiles = ImageInfos .Where(i => i.IsLocalFile) - .Select(i => System.IO.Path.GetDirectoryName(i.Path)) + .Select(i => FileSystem.GetDirectoryName(i.Path)) .Distinct(StringComparer.OrdinalIgnoreCase) .SelectMany(directoryService.GetFilePaths) .ToList(); @@ -2099,7 +2086,7 @@ namespace MediaBrowser.Controller.Entities var extensions = new[] { ".nfo", ".xml", ".srt" }.ToList(); extensions.AddRange(SupportedImageExtensionsList); - return FileSystem.GetFiles(System.IO.Path.GetDirectoryName(Path), extensions.ToArray(), false, false) + return FileSystem.GetFiles(FileSystem.GetDirectoryName(Path), extensions.ToArray(), false, false) .Where(i => System.IO.Path.GetFileNameWithoutExtension(i.FullName).StartsWith(filename, StringComparison.OrdinalIgnoreCase)) .ToList(); } @@ -2298,16 +2285,6 @@ namespace MediaBrowser.Controller.Entities ownedItem.CustomRating = item.CustomRating; newOptions.ForceSave = true; } - if (!string.Equals(item.CriticRatingSummary, ownedItem.CriticRatingSummary, StringComparison.Ordinal)) - { - ownedItem.CriticRatingSummary = item.CriticRatingSummary; - newOptions.ForceSave = true; - } - if (!string.Equals(item.OfficialRatingDescription, ownedItem.OfficialRatingDescription, StringComparison.Ordinal)) - { - ownedItem.OfficialRatingDescription = item.OfficialRatingDescription; - newOptions.ForceSave = true; - } } return ownedItem.RefreshMetadata(newOptions, cancellationToken); diff --git a/MediaBrowser.Controller/Entities/Book.cs b/MediaBrowser.Controller/Entities/Book.cs index a6da389f05..7cb2425899 100644 --- a/MediaBrowser.Controller/Entities/Book.cs +++ b/MediaBrowser.Controller/Entities/Book.cs @@ -24,12 +24,10 @@ namespace MediaBrowser.Controller.Entities public string SeriesName { get; set; } [IgnoreDataMember] public Guid? SeriesId { get; set; } - [IgnoreDataMember] - public string SeriesSortName { get; set; } public string FindSeriesSortName() { - return SeriesSortName; + return SeriesName; } public string FindSeriesName() { diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 62ea21a798..24474ba559 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -213,7 +213,7 @@ namespace MediaBrowser.Controller.Entities .SelectMany(c => c.LinkedChildren) .ToList(); - var changed = !linkedChildren.SequenceEqual(LinkedChildren, new LinkedChildComparer()); + var changed = !linkedChildren.SequenceEqual(LinkedChildren, new LinkedChildComparer(FileSystem)); LinkedChildren = linkedChildren; @@ -332,13 +332,13 @@ namespace MediaBrowser.Controller.Entities .OfType<Folder>() .ToList(); - return PhysicalLocations.Where(i => !string.Equals(i, Path, StringComparison.OrdinalIgnoreCase)).SelectMany(i => GetPhysicalParents(i, rootChildren)).DistinctBy(i => i.Id); + return PhysicalLocations.Where(i => !FileSystem.AreEqual(i, Path)).SelectMany(i => GetPhysicalParents(i, rootChildren)).DistinctBy(i => i.Id); } private IEnumerable<Folder> GetPhysicalParents(string path, List<Folder> rootChildren) { var result = rootChildren - .Where(i => string.Equals(i.Path, path, StringComparison.OrdinalIgnoreCase)) + .Where(i => FileSystem.AreEqual(i.Path, path)) .ToList(); if (result.Count == 0) diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 268fefbd3e..edac27f99b 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -640,7 +640,7 @@ namespace MediaBrowser.Controller.Entities return true; } - path = System.IO.Path.GetDirectoryName(path); + path = FileSystem.GetDirectoryName(path); } return allLibraryPaths.Any(i => ContainsPath(i, originalPath)); @@ -1206,11 +1206,17 @@ namespace MediaBrowser.Controller.Entities return GetLinkedChildren(); } - var locations = user.RootFolder - .Children + if (LinkedChildren.Count == 0) + { + return new List<BaseItem>(); + } + + var allUserRootChildren = user.RootFolder.Children.OfType<Folder>().ToList(); + + var collectionFolderIds = allUserRootChildren .OfType<CollectionFolder>() .Where(i => i.IsVisible(user)) - .SelectMany(i => i.PhysicalLocations) + .Select(i => i.Id) .ToList(); return LinkedChildren @@ -1228,9 +1234,16 @@ namespace MediaBrowser.Controller.Entities return null; } } - else if (childLocationType == LocationType.FileSystem && !locations.Any(l => FileSystem.ContainsSubPath(l, child.Path))) + else if (childLocationType == LocationType.FileSystem) { - return null; + var itemCollectionFolderIds = + LibraryManager.GetCollectionFolders(child, allUserRootChildren) + .Select(f => f.Id).ToList(); + + if (!itemCollectionFolderIds.Any(collectionFolderIds.Contains)) + { + return null; + } } } @@ -1323,7 +1336,7 @@ namespace MediaBrowser.Controller.Entities } else { newShortcutLinks = new List<LinkedChild>(); } - if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer())) + if (!newShortcutLinks.SequenceEqual(currentShortcutLinks, new LinkedChildComparer(FileSystem))) { Logger.Info("Shortcut links have changed for {0}", Path); diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index d19552c07f..baefc9dfa8 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -105,7 +105,7 @@ namespace MediaBrowser.Controller.Entities return new[] { new FileSystemMetadata { - FullName = System.IO.Path.GetDirectoryName(Path), + FullName = FileSystem.GetDirectoryName(Path), IsDirectory = true } }; diff --git a/MediaBrowser.Controller/Entities/GameGenre.cs b/MediaBrowser.Controller/Entities/GameGenre.cs index 4187167b95..093b191b6b 100644 --- a/MediaBrowser.Controller/Entities/GameGenre.cs +++ b/MediaBrowser.Controller/Entities/GameGenre.cs @@ -81,7 +81,7 @@ namespace MediaBrowser.Controller.Entities public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query) { - query.Genres = new[] { Name }; + query.GenreIds = new[] { Id.ToString("N") }; query.IncludeItemTypes = new[] { typeof(Game).Name }; return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index 9769efdd01..6569a1e6c0 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -93,7 +93,7 @@ namespace MediaBrowser.Controller.Entities public IEnumerable<BaseItem> GetTaggedItems(InternalItemsQuery query) { - query.Genres = new[] { Name }; + query.GenreIds = new[] { Id.ToString("N") }; query.ExcludeItemTypes = new[] { typeof(Game).Name, typeof(MusicVideo).Name, typeof(Audio.Audio).Name, typeof(MusicAlbum).Name, typeof(MusicArtist).Name }; return LibraryManager.GetItemList(query); diff --git a/MediaBrowser.Controller/Entities/IHasSeries.cs b/MediaBrowser.Controller/Entities/IHasSeries.cs index 203be93e88..20efdc2b8b 100644 --- a/MediaBrowser.Controller/Entities/IHasSeries.cs +++ b/MediaBrowser.Controller/Entities/IHasSeries.cs @@ -11,7 +11,6 @@ namespace MediaBrowser.Controller.Entities /// <value>The name of the series.</value> string SeriesName { get; set; } string FindSeriesName(); - string SeriesSortName { get; set; } string FindSeriesSortName(); Guid? SeriesId { get; set; } Guid? FindSeriesId(); diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index ea4d60a446..092461c842 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -129,7 +129,6 @@ namespace MediaBrowser.Controller.Entities public string[] AncestorIds { get; set; } public string[] TopParentIds { get; set; } - public LocationType[] LocationTypes { get; set; } public string[] PresetViews { get; set; } public SourceType[] SourceTypes { get; set; } public SourceType[] ExcludeSourceTypes { get; set; } @@ -176,7 +175,6 @@ namespace MediaBrowser.Controller.Entities case ItemFields.DateCreated: case ItemFields.SortName: case ItemFields.Overview: - case ItemFields.OfficialRatingDescription: case ItemFields.HomePageUrl: case ItemFields.VoteCount: case ItemFields.DisplayMediaType: @@ -187,7 +185,6 @@ namespace MediaBrowser.Controller.Entities case ItemFields.OriginalTitle: case ItemFields.Tags: case ItemFields.DateLastMediaAdded: - case ItemFields.CriticRatingSummary: return fields.Count == 0 || fields.Contains(name); default: return true; @@ -230,7 +227,6 @@ namespace MediaBrowser.Controller.Entities TopParentIds = new string[] { }; ExcludeTags = new string[] { }; ExcludeInheritedTags = new string[] { }; - LocationTypes = new LocationType[] { }; PresetViews = new string[] { }; SourceTypes = new SourceType[] { }; ExcludeSourceTypes = new SourceType[] { }; diff --git a/MediaBrowser.Controller/Entities/LinkedChild.cs b/MediaBrowser.Controller/Entities/LinkedChild.cs index 4d3c13c6e3..6031a2448a 100644 --- a/MediaBrowser.Controller/Entities/LinkedChild.cs +++ b/MediaBrowser.Controller/Entities/LinkedChild.cs @@ -1,5 +1,6 @@ using System; using System.Collections.Generic; +using MediaBrowser.Model.IO; using MediaBrowser.Model.Serialization; namespace MediaBrowser.Controller.Entities @@ -40,11 +41,18 @@ namespace MediaBrowser.Controller.Entities public class LinkedChildComparer : IEqualityComparer<LinkedChild> { + private readonly IFileSystem _fileSystem; + + public LinkedChildComparer(IFileSystem fileSystem) + { + _fileSystem = fileSystem; + } + public bool Equals(LinkedChild x, LinkedChild y) { if (x.Type == y.Type) { - return string.Equals(x.Path, y.Path, StringComparison.OrdinalIgnoreCase); + return _fileSystem.AreEqual(x.Path, y.Path); } return false; } diff --git a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs index 030831717a..3f733ce035 100644 --- a/MediaBrowser.Controller/Entities/Movies/BoxSet.cs +++ b/MediaBrowser.Controller/Entities/Movies/BoxSet.cs @@ -152,9 +152,7 @@ namespace MediaBrowser.Controller.Entities.Movies var currentOfficialRating = OfficialRating; // Gather all possible ratings - var ratings = GetRecursiveChildren() - .Concat(GetLinkedChildren()) - .Where(i => i is Movie || i is Series || i is MusicAlbum || i is Game) + var ratings = GetRecursiveChildren(i => i is Movie || i is Series || i is MusicAlbum || i is Game) .Select(i => i.OfficialRating) .Where(i => !string.IsNullOrEmpty(i)) .Distinct(StringComparer.OrdinalIgnoreCase) @@ -205,7 +203,7 @@ namespace MediaBrowser.Controller.Entities.Movies if (base.IsVisible(user)) { - return GetChildren(user, true).Any(); + return base.GetChildren(user, true).Any(); } return false; diff --git a/MediaBrowser.Controller/Entities/TV/Episode.cs b/MediaBrowser.Controller/Entities/TV/Episode.cs index 31bf8d28bd..c2f7a6168b 100644 --- a/MediaBrowser.Controller/Entities/TV/Episode.cs +++ b/MediaBrowser.Controller/Entities/TV/Episode.cs @@ -57,13 +57,10 @@ namespace MediaBrowser.Controller.Entities.TV /// <value>The index number.</value> public int? IndexNumberEnd { get; set; }
- [IgnoreDataMember]
- public string SeriesSortName { get; set; }
-
public string FindSeriesSortName()
{
var series = Series;
- return series == null ? SeriesSortName : series.SortName;
+ return series == null ? SeriesName : series.SortName;
}
[IgnoreDataMember] diff --git a/MediaBrowser.Controller/Entities/TV/Season.cs b/MediaBrowser.Controller/Entities/TV/Season.cs index be268782d5..ed04b5ddcb 100644 --- a/MediaBrowser.Controller/Entities/TV/Season.cs +++ b/MediaBrowser.Controller/Entities/TV/Season.cs @@ -51,9 +51,6 @@ namespace MediaBrowser.Controller.Entities.TV get { return SeriesId; } } - [IgnoreDataMember] - public string SeriesSortName { get; set; } - public override double? GetDefaultPrimaryImageAspectRatio() { double value = 2; @@ -65,7 +62,7 @@ namespace MediaBrowser.Controller.Entities.TV public string FindSeriesSortName() { var series = Series; - return series == null ? SeriesSortName : series.SortName; + return series == null ? SeriesName : series.SortName; } // Genre, Rating and Stuido will all be the same @@ -125,7 +122,7 @@ namespace MediaBrowser.Controller.Entities.TV return series.Path; } - return System.IO.Path.GetDirectoryName(Path); + return FileSystem.GetDirectoryName(Path); } } diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index f879d0fd8f..8da069f62b 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -586,7 +586,7 @@ namespace MediaBrowser.Controller.Entities { query.Recursive = true; query.ParentId = queryParent.Id; - query.Genres = new[] { displayParent.Name }; + query.GenreIds = new[] { displayParent.Id.ToString("N") }; query.SetUser(user); query.IncludeItemTypes = new[] { typeof(Movie).Name }; @@ -729,7 +729,7 @@ namespace MediaBrowser.Controller.Entities { query.Recursive = true; query.ParentId = queryParent.Id; - query.Genres = new[] { displayParent.Name }; + query.GenreIds = new[] { displayParent.Id.ToString("N") }; query.SetUser(user); query.IncludeItemTypes = new[] { typeof(Series).Name }; @@ -905,6 +905,11 @@ namespace MediaBrowser.Controller.Entities return false; } + if (request.GenreIds.Length > 0) + { + return false; + } + if (request.HasImdbId.HasValue) { return false; @@ -1768,26 +1773,6 @@ namespace MediaBrowser.Controller.Entities return new List<Folder> { parent }; } - private IEnumerable<BaseItem> GetRecursiveChildren(Folder parent, User user, IEnumerable<string> viewTypes) - { - if (parent == null || parent is UserView) - { - if (user == null) - { - return GetMediaFolders(null, viewTypes).SelectMany(i => i.GetRecursiveChildren()); - } - - return GetMediaFolders(user, viewTypes).SelectMany(i => i.GetRecursiveChildren(user)); - } - - if (user == null) - { - return parent.GetRecursiveChildren(); - } - - return parent.GetRecursiveChildren(user); - } - private async Task<QueryResult<BaseItem>> GetLiveTvView(Folder queryParent, User user, InternalItemsQuery query) { if (query.Recursive) diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 0618fc489e..90aa3690a9 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -33,7 +33,6 @@ namespace MediaBrowser.Controller.Entities public List<string> AdditionalParts { get; set; } public List<string> LocalAlternateVersions { get; set; } public List<LinkedChild> LinkedAlternateVersions { get; set; } - public List<ChannelMediaInfo> ChannelMediaSources { get; set; } [IgnoreDataMember] public override bool SupportsPlayedStatus @@ -158,7 +157,6 @@ namespace MediaBrowser.Controller.Entities PlayableStreamFileNames = new List<string>(); AdditionalParts = new List<string>(); LocalAlternateVersions = new List<string>(); - Tags = new List<string>(); SubtitleFiles = new List<string>(); LinkedAlternateVersions = new List<LinkedChild>(); } @@ -313,7 +311,7 @@ namespace MediaBrowser.Controller.Entities { if (IsStacked) { - return System.IO.Path.GetDirectoryName(Path); + return FileSystem.GetDirectoryName(Path); } if (!IsPlaceHolder) @@ -591,41 +589,46 @@ namespace MediaBrowser.Controller.Entities .ToList(); } - private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video i, MediaSourceType type) + private static MediaSourceInfo GetVersionInfo(bool enablePathSubstitution, Video media, MediaSourceType type) { - var mediaStreams = MediaSourceManager.GetMediaStreams(i.Id) + if (media == null) + { + throw new ArgumentNullException("media"); + } + + var mediaStreams = MediaSourceManager.GetMediaStreams(media.Id) .ToList(); - var locationType = i.LocationType; + var locationType = media.LocationType; var info = new MediaSourceInfo { - Id = i.Id.ToString("N"), - IsoType = i.IsoType, + Id = media.Id.ToString("N"), + IsoType = media.IsoType, Protocol = locationType == LocationType.Remote ? MediaProtocol.Http : MediaProtocol.File, MediaStreams = mediaStreams, - Name = GetMediaSourceName(i, mediaStreams), - Path = enablePathSubstitution ? GetMappedPath(i, i.Path, locationType) : i.Path, - RunTimeTicks = i.RunTimeTicks, - Video3DFormat = i.Video3DFormat, - VideoType = i.VideoType, - Container = i.Container, - Size = i.Size, - Timestamp = i.Timestamp, + Name = GetMediaSourceName(media, mediaStreams), + Path = enablePathSubstitution ? GetMappedPath(media, media.Path, locationType) : media.Path, + RunTimeTicks = media.RunTimeTicks, + Video3DFormat = media.Video3DFormat, + VideoType = media.VideoType, + Container = media.Container, + Size = media.Size, + Timestamp = media.Timestamp, Type = type, - PlayableStreamFileNames = i.PlayableStreamFileNames.ToList(), - SupportsDirectStream = i.VideoType == VideoType.VideoFile, - IsRemote = i.IsShortcut + PlayableStreamFileNames = media.PlayableStreamFileNames.ToList(), + SupportsDirectStream = media.VideoType == VideoType.VideoFile, + IsRemote = media.IsShortcut }; if (info.Protocol == MediaProtocol.File) { - info.ETag = i.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); + info.ETag = media.DateModified.Ticks.ToString(CultureInfo.InvariantCulture).GetMD5().ToString("N"); } - if (i.IsShortcut) + if (media.IsShortcut) { - info.Path = i.ShortcutPath; + info.Path = media.ShortcutPath; if (info.Path.StartsWith("Http", StringComparison.OrdinalIgnoreCase)) { @@ -647,16 +650,16 @@ namespace MediaBrowser.Controller.Entities if (string.IsNullOrEmpty(info.Container)) { - if (i.VideoType == VideoType.VideoFile || i.VideoType == VideoType.Iso) + if (media.VideoType == VideoType.VideoFile || media.VideoType == VideoType.Iso) { - if (!string.IsNullOrWhiteSpace(i.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) + if (!string.IsNullOrWhiteSpace(media.Path) && locationType != LocationType.Remote && locationType != LocationType.Virtual) { - info.Container = System.IO.Path.GetExtension(i.Path).TrimStart('.'); + info.Container = System.IO.Path.GetExtension(media.Path).TrimStart('.'); } } } - info.Bitrate = i.TotalBitrate; + info.Bitrate = media.TotalBitrate; info.InferTotalBitrate(); return info; diff --git a/MediaBrowser.Controller/Library/ILibraryManager.cs b/MediaBrowser.Controller/Library/ILibraryManager.cs index ebebe71a32..dd23799407 100644 --- a/MediaBrowser.Controller/Library/ILibraryManager.cs +++ b/MediaBrowser.Controller/Library/ILibraryManager.cs @@ -456,6 +456,8 @@ namespace MediaBrowser.Controller.Library /// <returns>IEnumerable<Folder>.</returns> List<Folder> GetCollectionFolders(BaseItem item); + List<Folder> GetCollectionFolders(BaseItem item, List<Folder> allUserRootChildren); + LibraryOptions GetLibraryOptions(BaseItem item); /// <summary> diff --git a/MediaBrowser.Controller/Library/ItemResolveArgs.cs b/MediaBrowser.Controller/Library/ItemResolveArgs.cs index 763d27ebaf..3aa4d4ee2c 100644 --- a/MediaBrowser.Controller/Library/ItemResolveArgs.cs +++ b/MediaBrowser.Controller/Library/ItemResolveArgs.cs @@ -114,7 +114,7 @@ namespace MediaBrowser.Controller.Library return false; } - var parentDir = System.IO.Path.GetDirectoryName(Path) ?? string.Empty; + var parentDir = BaseItem.FileSystem.GetDirectoryName(Path) ?? string.Empty; return parentDir.Length > _appPaths.RootFolderPath.Length && parentDir.StartsWith(_appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase); @@ -130,7 +130,7 @@ namespace MediaBrowser.Controller.Library { get { - return IsDirectory && string.Equals(Path, _appPaths.RootFolderPath, StringComparison.OrdinalIgnoreCase); + return IsDirectory && BaseItem.FileSystem.AreEqual(Path, _appPaths.RootFolderPath); } } @@ -300,7 +300,7 @@ namespace MediaBrowser.Controller.Library if (args != null) { if (args.Path == null && Path == null) return true; - return args.Path != null && args.Path.Equals(Path, StringComparison.OrdinalIgnoreCase); + return args.Path != null && BaseItem.FileSystem.AreEqual(args.Path, Path); } return false; } diff --git a/MediaBrowser.Controller/Library/PlaybackProgressEventArgs.cs b/MediaBrowser.Controller/Library/PlaybackProgressEventArgs.cs index bcf39558e1..0644719b64 100644 --- a/MediaBrowser.Controller/Library/PlaybackProgressEventArgs.cs +++ b/MediaBrowser.Controller/Library/PlaybackProgressEventArgs.cs @@ -16,6 +16,7 @@ namespace MediaBrowser.Controller.Library public BaseItemInfo MediaInfo { get; set; } public string MediaSourceId { get; set; } public bool IsPaused { get; set; } + public bool IsAutomated { get; set; } public string DeviceId { get; set; } public string DeviceName { get; set; } diff --git a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs index fede81faf4..6e2fe2495a 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvChannel.cs @@ -16,7 +16,11 @@ namespace MediaBrowser.Controller.LiveTv { var list = base.GetUserDataKeys(); - list.Insert(0, GetClientTypeName() + "-" + Name); + if (!ConfigurationManager.Configuration.DisableLiveTvChannelUserDataName) + { + list.Insert(0, GetClientTypeName() + "-" + Name); + } + return list; } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs index 22d09f34a1..ca0b97a9f6 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingHelper.cs @@ -732,7 +732,7 @@ namespace MediaBrowser.Controller.MediaEncoding if (string.Equals(videoEncoder, "libx264", StringComparison.OrdinalIgnoreCase)) { - param += " -x264opts:0 subme=0:rc_lookahead=10:me_range=4:me=dia:no_chroma_me:8x8dct=0:partitions=none"; + param += " -x264opts:0 subme=0:me_range=4:rc_lookahead=10:me=dia:no_chroma_me:8x8dct=0:partitions=none"; } if (!string.Equals(videoEncoder, "h264_omx", StringComparison.OrdinalIgnoreCase) && @@ -1517,12 +1517,6 @@ namespace MediaBrowser.Controller.MediaEncoding inputModifier += " " + GetFastSeekCommandLineParameter(state.BaseRequest); inputModifier = inputModifier.Trim(); - //inputModifier += " -fflags +genpts+ignidx+igndts"; - //if (state.IsVideoRequest && genPts) - //{ - // inputModifier += " -fflags +genpts"; - //} - if (!string.IsNullOrEmpty(state.InputAudioSync)) { inputModifier += " -async " + state.InputAudioSync; @@ -1538,6 +1532,21 @@ namespace MediaBrowser.Controller.MediaEncoding inputModifier += " -re"; } + var flags = new List<string>(); + if (state.IgnoreDts) + { + flags.Add("+igndts"); + } + if (state.IgnoreIndex) + { + flags.Add("+ignidx"); + } + + if (flags.Count > 0) + { + inputModifier += " -fflags " + string.Join("", flags.ToArray()); + } + var videoDecoder = GetVideoDecoder(state, encodingOptions); if (!string.IsNullOrWhiteSpace(videoDecoder)) { @@ -1725,6 +1734,11 @@ namespace MediaBrowser.Controller.MediaEncoding if (state.VideoStream != null && !string.IsNullOrWhiteSpace(state.VideoStream.Codec)) { + if (!string.IsNullOrWhiteSpace(encodingOptions.HardwareAccelerationType)) + { + return "-hwaccel auto"; + } + if (string.Equals(encodingOptions.HardwareAccelerationType, "qsv", StringComparison.OrdinalIgnoreCase)) { switch (state.MediaSource.VideoStream.Codec.ToLower()) @@ -1974,5 +1988,65 @@ namespace MediaBrowser.Controller.MediaEncoding return args; } + + public string GetProgressiveAudioFullCommandLine(EncodingJobInfo state, EncodingOptions encodingOptions, string outputPath) + { + var audioTranscodeParams = new List<string>(); + + var bitrate = state.OutputAudioBitrate; + + if (bitrate.HasValue) + { + audioTranscodeParams.Add("-ab " + bitrate.Value.ToString(_usCulture)); + } + + if (state.OutputAudioChannels.HasValue) + { + audioTranscodeParams.Add("-ac " + state.OutputAudioChannels.Value.ToString(_usCulture)); + } + + // opus will fail on 44100 + if (!string.Equals(state.OutputAudioCodec, "opus", StringComparison.OrdinalIgnoreCase)) + { + if (state.OutputAudioSampleRate.HasValue) + { + audioTranscodeParams.Add("-ar " + state.OutputAudioSampleRate.Value.ToString(_usCulture)); + } + } + + var albumCoverInput = string.Empty; + var mapArgs = string.Empty; + var metadata = string.Empty; + var vn = string.Empty; + + var hasArt = !string.IsNullOrWhiteSpace(state.AlbumCoverPath); + + if (hasArt) + { + albumCoverInput = " -i \"" + state.AlbumCoverPath + "\""; + mapArgs = " -map 0:a -map 1:v -c:1:v copy"; + metadata = " -metadata:s:v title=\"Album cover\" -metadata:s:v comment=\"Cover(Front)\""; + } + else + { + vn = " -vn"; + } + + var threads = GetNumberOfThreads(state, encodingOptions, false); + + var inputModifier = GetInputModifier(state, encodingOptions); + + return string.Format("{0} {1}{7}{8} -threads {2}{3} {4} -id3v2_version 3 -write_id3v1 1{6} -y \"{5}\"", + inputModifier, + GetInputArgument(state, encodingOptions), + threads, + vn, + string.Join(" ", audioTranscodeParams.ToArray()), + outputPath, + metadata, + albumCoverInput, + mapArgs).Trim(); + } + } } diff --git a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs index f3e6280aaf..28ada9daeb 100644 --- a/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs +++ b/MediaBrowser.Controller/MediaEncoding/EncodingJobInfo.cs @@ -39,6 +39,16 @@ namespace MediaBrowser.Controller.MediaEncoding public bool ReadInputAtNativeFramerate { get; set; } + public bool IgnoreDts + { + get { return MediaSource.IgnoreDts; } + } + + public bool IgnoreIndex + { + get { return MediaSource.IgnoreIndex; } + } + public string OutputContainer { get; set; } public string OutputVideoSync @@ -56,6 +66,8 @@ namespace MediaBrowser.Controller.MediaEncoding } } + public string AlbumCoverPath { get; set; } + public string InputAudioSync { get; set; } public string InputVideoSync { get; set; } public TransportStreamTimestamp InputTimestamp { get; set; } diff --git a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs index 78ed1dc59b..bac9807a90 100644 --- a/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs +++ b/MediaBrowser.Controller/MediaEncoding/IMediaEncoder.cs @@ -126,7 +126,6 @@ namespace MediaBrowser.Controller.MediaEncoding Task UpdateEncoderPath(string path, string pathType); bool SupportsEncoder(string encoder); - bool IsDefaultEncoderPath { get; } void SetLogFilename(string name); void ClearLogFilename(); diff --git a/MediaBrowser.Controller/Playlists/Playlist.cs b/MediaBrowser.Controller/Playlists/Playlist.cs index 0eb4353759..fb1410f4af 100644 --- a/MediaBrowser.Controller/Playlists/Playlist.cs +++ b/MediaBrowser.Controller/Playlists/Playlist.cs @@ -134,34 +134,27 @@ namespace MediaBrowser.Controller.Playlists var musicGenre = item as MusicGenre; if (musicGenre != null) { - var items = LibraryManager.GetItemList(new InternalItemsQuery(user) + return LibraryManager.GetItemList(new InternalItemsQuery(user) { Recursive = true, IncludeItemTypes = new[] { typeof(Audio).Name }, - Genres = new[] { musicGenre.Name } + GenreIds = new[] { musicGenre.Id.ToString("N") }, + SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, + SortOrder = SortOrder.Ascending }); - - return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending); } var musicArtist = item as MusicArtist; if (musicArtist != null) { - Func<BaseItem, bool> filter = i => + return LibraryManager.GetItemList(new InternalItemsQuery(user) { - var audio = i as Audio; - return audio != null && audio.HasAnyArtist(musicArtist.Name); - }; - - var items = user == null - ? LibraryManager.RootFolder.GetRecursiveChildren(filter) - : user.RootFolder.GetRecursiveChildren(user, new InternalItemsQuery(user) - { - IncludeItemTypes = new[] { typeof(Audio).Name }, - ArtistIds = new[] { musicArtist.Id.ToString("N") } - }); - - return LibraryManager.Sort(items, user, new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, SortOrder.Ascending); + Recursive = true, + IncludeItemTypes = new[] { typeof(Audio).Name }, + ArtistIds = new[] { musicArtist.Id.ToString("N") }, + SortBy = new[] { ItemSortBy.AlbumArtist, ItemSortBy.Album, ItemSortBy.SortName }, + SortOrder = SortOrder.Ascending + }); } var folder = item as Folder; diff --git a/MediaBrowser.Controller/Providers/DirectoryService.cs b/MediaBrowser.Controller/Providers/DirectoryService.cs index 40093df3af..62db007b90 100644 --- a/MediaBrowser.Controller/Providers/DirectoryService.cs +++ b/MediaBrowser.Controller/Providers/DirectoryService.cs @@ -63,11 +63,11 @@ 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) + var list = _fileSystem.GetFileSystemEntries(path) .ToList(); // Seeing dupes on some users file system for some reason @@ -80,7 +80,7 @@ namespace MediaBrowser.Controller.Providers { } - //var group = entries.ToLookup(i => Path.GetDirectoryName(i.FullName)).ToList(); + //var group = entries.ToLookup(i => _fileSystem.GetDirectoryName(i.FullName)).ToList(); _cache.TryAdd(path, entries); } diff --git a/MediaBrowser.Controller/Providers/IProviderManager.cs b/MediaBrowser.Controller/Providers/IProviderManager.cs index f4d45c7e0c..c0bc902140 100644 --- a/MediaBrowser.Controller/Providers/IProviderManager.cs +++ b/MediaBrowser.Controller/Providers/IProviderManager.cs @@ -20,9 +20,7 @@ namespace MediaBrowser.Controller.Providers /// <summary> /// Queues the refresh. /// </summary> - /// <param name="itemId">The item identifier.</param> - /// <param name="options">The options.</param> - void QueueRefresh(Guid itemId, MetadataRefreshOptions options); + void QueueRefresh(Guid itemId, MetadataRefreshOptions options, RefreshPriority priority); /// <summary> /// Refreshes the full item. @@ -161,4 +159,11 @@ namespace MediaBrowser.Controller.Providers /// <returns>Task{HttpResponseInfo}.</returns> Task<HttpResponseInfo> GetSearchImage(string providerName, string url, CancellationToken cancellationToken); } + + public enum RefreshPriority + { + High = 0, + Normal = 1, + Low = 2 + } }
\ No newline at end of file |
