diff options
| author | Luke <luke.pulverenti@gmail.com> | 2017-01-26 15:40:15 -0500 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2017-01-26 15:40:15 -0500 |
| commit | 1cd5e208713a057680b915c9136e0d4493611ed3 (patch) | |
| tree | 59e258ecd246dfb253c06cade5f0092af9874774 /MediaBrowser.Controller | |
| parent | 0d0e4ad695f3657d7ca3eef1ed54fe8608a490a1 (diff) | |
| parent | 9ebf9162ab68fbf61a1dd5e7801eb9abe985762c (diff) | |
Merge pull request #2425 from MediaBrowser/beta
Beta
Diffstat (limited to 'MediaBrowser.Controller')
19 files changed, 131 insertions, 105 deletions
diff --git a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs index 1216ae3522..ba20395d1b 100644 --- a/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs +++ b/MediaBrowser.Controller/Channels/ChannelMediaInfo.cs @@ -49,9 +49,11 @@ namespace MediaBrowser.Controller.Channels SupportsDirectPlay = true; } - public MediaSourceInfo ToMediaSource() + public MediaSourceInfo ToMediaSource(Guid itemId) { - var id = Path.GetMD5().ToString("N"); + var id = string.IsNullOrWhiteSpace(Path) ? + itemId.ToString("N") : + Path.GetMD5().ToString("N"); var source = new MediaSourceInfo { @@ -65,16 +67,12 @@ namespace MediaBrowser.Controller.Channels Name = id, Id = id, ReadAtNativeFramerate = ReadAtNativeFramerate, - SupportsDirectStream = Protocol == MediaProtocol.File, - SupportsDirectPlay = SupportsDirectPlay + SupportsDirectStream = false, + SupportsDirectPlay = SupportsDirectPlay, + IsRemote = true }; - var bitrate = (AudioBitrate ?? 0) + (VideoBitrate ?? 0); - - if (bitrate > 0) - { - source.Bitrate = bitrate; - } + source.InferTotalBitrate(); return source; } diff --git a/MediaBrowser.Controller/Chapters/IChapterManager.cs b/MediaBrowser.Controller/Chapters/IChapterManager.cs index 4b39e66cc2..05517ebcd4 100644 --- a/MediaBrowser.Controller/Chapters/IChapterManager.cs +++ b/MediaBrowser.Controller/Chapters/IChapterManager.cs @@ -26,11 +26,5 @@ namespace MediaBrowser.Controller.Chapters /// <param name="cancellationToken">The cancellation token.</param> /// <returns>Task.</returns> Task SaveChapters(string itemId, List<ChapterInfo> chapters, CancellationToken cancellationToken); - - /// <summary> - /// Gets the configuration. - /// </summary> - /// <returns>ChapterOptions.</returns> - ChapterOptions GetConfiguration(); } } diff --git a/MediaBrowser.Controller/Connect/IConnectManager.cs b/MediaBrowser.Controller/Connect/IConnectManager.cs index e004eaccfa..f899c72623 100644 --- a/MediaBrowser.Controller/Connect/IConnectManager.cs +++ b/MediaBrowser.Controller/Connect/IConnectManager.cs @@ -61,7 +61,7 @@ namespace MediaBrowser.Controller.Connect /// <param name="username">The username.</param> /// <param name="passwordMd5">The password MD5.</param> /// <returns>Task.</returns> - Task Authenticate(string username, string passwordMd5); + Task<ConnectAuthenticationResult> Authenticate(string username, string passwordMd5); /// <summary> /// Gets the local user. diff --git a/MediaBrowser.Controller/Entities/Audio/Audio.cs b/MediaBrowser.Controller/Entities/Audio/Audio.cs index 3a6a7765b1..4cc6a7c7e9 100644 --- a/MediaBrowser.Controller/Entities/Audio/Audio.cs +++ b/MediaBrowser.Controller/Entities/Audio/Audio.cs @@ -267,15 +267,8 @@ namespace MediaBrowser.Controller.Entities.Audio } } - var bitrate = i.TotalBitrate ?? - info.MediaStreams.Where(m => m.Type == MediaStreamType.Audio) - .Select(m => m.BitRate ?? 0) - .Sum(); - - if (bitrate > 0) - { - info.Bitrate = bitrate; - } + info.Bitrate = i.TotalBitrate; + info.InferTotalBitrate(); return info; } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs index 1d2716b64a..37631bbe8a 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicArtist.cs @@ -45,6 +45,15 @@ namespace MediaBrowser.Controller.Entities.Audio } [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + + [IgnoreDataMember] public override bool SupportsAddingToPlaylist { get { return true; } diff --git a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs index d75b31f6ae..bbe1a54a49 100644 --- a/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs +++ b/MediaBrowser.Controller/Entities/Audio/MusicGenre.cs @@ -40,6 +40,15 @@ namespace MediaBrowser.Controller.Entities.Audio } } + [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + /// <summary> /// Returns the folder containing the item. /// If the item is a folder, it returns the folder itself diff --git a/MediaBrowser.Controller/Entities/AudioBook.cs b/MediaBrowser.Controller/Entities/AudioBook.cs index efeb9b497d..c15cae8b13 100644 --- a/MediaBrowser.Controller/Entities/AudioBook.cs +++ b/MediaBrowser.Controller/Entities/AudioBook.cs @@ -17,6 +17,15 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] + public override bool SupportsPlayedStatus + { + get + { + return true; + } + } + + [IgnoreDataMember] public string SeriesPresentationUniqueKey { get; set; } [IgnoreDataMember] public string SeriesName { get; set; } diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index 2aa53d6515..4cfea4c70e 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -53,6 +53,7 @@ namespace MediaBrowser.Controller.Entities ImageInfos = new List<ItemImageInfo>(); InheritedTags = new List<string>(); ProductionLocations = new List<string>(); + SourceType = SourceType.Library; } public static readonly char[] SlugReplaceChars = { '?', '/', '&' }; @@ -272,9 +273,6 @@ namespace MediaBrowser.Controller.Entities public virtual string Path { get; set; } [IgnoreDataMember] - public bool IsOffline { get; set; } - - [IgnoreDataMember] public virtual SourceType SourceType { get; set; } /// <summary> @@ -338,20 +336,6 @@ namespace MediaBrowser.Controller.Entities } } - public Task UpdateIsOffline(bool newValue) - { - var item = this; - - if (item.IsOffline != newValue) - { - item.IsOffline = newValue; - // this is creating too many repeated db updates - //return item.UpdateToRepository(ItemUpdateType.None, CancellationToken.None); - } - - return Task.FromResult(true); - } - /// <summary> /// Gets or sets the type of the location. /// </summary> @@ -1355,6 +1339,11 @@ namespace MediaBrowser.Controller.Entities if (string.IsNullOrWhiteSpace(lang)) { + lang = LibraryManager.GetLibraryOptions(this).PreferredMetadataLanguage; + } + + if (string.IsNullOrWhiteSpace(lang)) + { lang = ConfigurationManager.Configuration.PreferredMetadataLanguage; } @@ -1385,6 +1374,11 @@ namespace MediaBrowser.Controller.Entities if (string.IsNullOrWhiteSpace(lang)) { + lang = LibraryManager.GetLibraryOptions(this).MetadataCountryCode; + } + + if (string.IsNullOrWhiteSpace(lang)) + { lang = ConfigurationManager.Configuration.MetadataCountryCode; } @@ -1606,12 +1600,15 @@ namespace MediaBrowser.Controller.Entities return true; } - var userCollectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList(); - var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id); + var itemCollectionFolders = LibraryManager.GetCollectionFolders(this).Select(i => i.Id).ToList(); - if (!itemCollectionFolders.Any(userCollectionFolders.Contains)) + if (itemCollectionFolders.Count > 0) { - return false; + var userCollectionFolders = user.RootFolder.GetChildren(user, true).Select(i => i.Id).ToList(); + if (!itemCollectionFolders.Any(userCollectionFolders.Contains)) + { + return false; + } } } @@ -1631,6 +1628,15 @@ namespace MediaBrowser.Controller.Entities } } + [IgnoreDataMember] + public virtual bool IsDisplayedAsFolder + { + get + { + return false; + } + } + public virtual string GetClientTypeName() { if (IsFolder && SourceType == SourceType.Channel && !(this is Channel)) diff --git a/MediaBrowser.Controller/Entities/CollectionFolder.cs b/MediaBrowser.Controller/Entities/CollectionFolder.cs index 681f16f07c..62ea21a798 100644 --- a/MediaBrowser.Controller/Entities/CollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/CollectionFolder.cs @@ -121,7 +121,6 @@ namespace MediaBrowser.Controller.Entities { LibraryOptions[path] = options; - options.SchemaVersion = 3; XmlSerializer.SerializeToFile(options, GetLibraryOptionsPath(path)); } } diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 943c9d8822..cdd503bba4 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -86,6 +86,15 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + + [IgnoreDataMember] public virtual bool SupportsCumulativeRunTimeTicks { get @@ -360,6 +369,11 @@ namespace MediaBrowser.Controller.Entities var validChildren = new List<BaseItem>(); + var allLibraryPaths = LibraryManager + .GetVirtualFolders() + .SelectMany(i => i.Locations) + .ToList(); + if (locationType != LocationType.Remote && locationType != LocationType.Virtual) { IEnumerable<BaseItem> nonCachedChildren; @@ -393,7 +407,6 @@ namespace MediaBrowser.Controller.Entities if (currentChildren.TryGetValue(child.Id, out currentChild) && IsValidFromResolver(currentChild, child)) { - await currentChild.UpdateIsOffline(false).ConfigureAwait(false); validChildren.Add(currentChild); continue; @@ -420,9 +433,8 @@ namespace MediaBrowser.Controller.Entities { } - else if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path)) + else if (!string.IsNullOrEmpty(item.Path) && IsPathOffline(item.Path, allLibraryPaths)) { - await item.UpdateIsOffline(true).ConfigureAwait(false); } else { @@ -437,7 +449,6 @@ namespace MediaBrowser.Controller.Entities Logger.Debug("Removed item: " + item.Path); item.SetParent(null); - item.IsOffline = false; await LibraryManager.DeleteItem(item, new DeleteOptions { DeleteFileLocation = false }).ConfigureAwait(false); LibraryManager.ReportItemRemoved(item); } @@ -603,6 +614,11 @@ namespace MediaBrowser.Controller.Entities /// <returns><c>true</c> if the specified path is offline; otherwise, <c>false</c>.</returns> public static bool IsPathOffline(string path) { + return IsPathOffline(path, LibraryManager.GetVirtualFolders().SelectMany(i => i.Locations).ToList()); + } + + public static bool IsPathOffline(string path, List<string> allLibraryPaths) + { if (FileSystem.FileExists(path)) { return false; @@ -618,31 +634,20 @@ namespace MediaBrowser.Controller.Entities return false; } - path = System.IO.Path.GetDirectoryName(path); - } + if (allLibraryPaths.Contains(path, StringComparer.OrdinalIgnoreCase)) + { + return true; + } - if (ContainsPath(LibraryManager.GetVirtualFolders(), originalPath)) - { - return true; + path = System.IO.Path.GetDirectoryName(path); } - return false; - } - - /// <summary> - /// Determines whether the specified folders contains path. - /// </summary> - /// <param name="folders">The folders.</param> - /// <param name="path">The path.</param> - /// <returns><c>true</c> if the specified folders contains path; otherwise, <c>false</c>.</returns> - private static bool ContainsPath(IEnumerable<VirtualFolderInfo> folders, string path) - { - return folders.SelectMany(i => i.Locations).Any(i => ContainsPath(i, path)); + return allLibraryPaths.Any(i => ContainsPath(i, originalPath)); } private static bool ContainsPath(string parent, string path) { - return string.Equals(parent, path, StringComparison.OrdinalIgnoreCase) || FileSystem.ContainsSubPath(parent, path); + return FileSystem.AreEqual(parent, path) || FileSystem.ContainsSubPath(parent, path); } /// <summary> @@ -1327,7 +1332,7 @@ namespace MediaBrowser.Controller.Entities if (!user.Configuration.DisplayMissingEpisodes || !user.Configuration.DisplayUnairedEpisodes) { - query.ExcludeLocationTypes = new[] { LocationType.Virtual }; + query.IsVirtualItem = false; } var itemsResult = await GetItems(query).ConfigureAwait(false); @@ -1366,7 +1371,7 @@ namespace MediaBrowser.Controller.Entities { Recursive = true, IsFolder = false, - ExcludeLocationTypes = new[] { LocationType.Virtual }, + IsVirtualItem = false, EnableTotalRecordCount = false }).Result; diff --git a/MediaBrowser.Controller/Entities/Genre.cs b/MediaBrowser.Controller/Entities/Genre.cs index da4ee352fa..1b746ae517 100644 --- a/MediaBrowser.Controller/Entities/Genre.cs +++ b/MediaBrowser.Controller/Entities/Genre.cs @@ -41,6 +41,15 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + + [IgnoreDataMember] public override bool SupportsAncestors { get diff --git a/MediaBrowser.Controller/Entities/ICollectionFolder.cs b/MediaBrowser.Controller/Entities/ICollectionFolder.cs index f4544f173e..d8b02034c7 100644 --- a/MediaBrowser.Controller/Entities/ICollectionFolder.cs +++ b/MediaBrowser.Controller/Entities/ICollectionFolder.cs @@ -20,17 +20,4 @@ namespace MediaBrowser.Controller.Entities { bool EnableUserSpecificView { get; } } - - public static class CollectionFolderExtensions - { - public static string GetViewType(this ICollectionFolder folder, User user) - { - if (user.Configuration.PlainFolderViews.Contains(folder.Id.ToString("N"), StringComparer.OrdinalIgnoreCase)) - { - return null; - } - - return folder.CollectionType; - } - } } diff --git a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs index 15af0888d5..9c5730d05c 100644 --- a/MediaBrowser.Controller/Entities/InternalItemsQuery.cs +++ b/MediaBrowser.Controller/Entities/InternalItemsQuery.cs @@ -130,7 +130,6 @@ namespace MediaBrowser.Controller.Entities public string[] TopParentIds { get; set; } public LocationType[] LocationTypes { get; set; } - public LocationType[] ExcludeLocationTypes { get; set; } public string[] PresetViews { get; set; } public SourceType[] SourceTypes { get; set; } public SourceType[] ExcludeSourceTypes { get; set; } @@ -160,6 +159,7 @@ namespace MediaBrowser.Controller.Entities public DateTime? MinDateLastSaved { get; set; } public DtoOptions DtoOptions { get; set; } + public int MinSimilarityScore { get; set; } public bool HasField(ItemFields name) { @@ -197,6 +197,8 @@ namespace MediaBrowser.Controller.Entities public InternalItemsQuery() { + MinSimilarityScore = 20; + GroupByPresentationUniqueKey = true; EnableTotalRecordCount = true; @@ -230,7 +232,6 @@ namespace MediaBrowser.Controller.Entities ExcludeTags = new string[] { }; ExcludeInheritedTags = new string[] { }; LocationTypes = new LocationType[] { }; - ExcludeLocationTypes = new LocationType[] { }; PresetViews = new string[] { }; SourceTypes = new SourceType[] { }; ExcludeSourceTypes = new SourceType[] { }; diff --git a/MediaBrowser.Controller/Entities/Studio.cs b/MediaBrowser.Controller/Entities/Studio.cs index c14dd70bf8..dbd9d1cef4 100644 --- a/MediaBrowser.Controller/Entities/Studio.cs +++ b/MediaBrowser.Controller/Entities/Studio.cs @@ -40,6 +40,15 @@ namespace MediaBrowser.Controller.Entities } [IgnoreDataMember] + public override bool IsDisplayedAsFolder + { + get + { + return true; + } + } + + [IgnoreDataMember] public override bool SupportsAncestors { get diff --git a/MediaBrowser.Controller/Entities/UserViewBuilder.cs b/MediaBrowser.Controller/Entities/UserViewBuilder.cs index 58d2cdc6c4..a880b6d778 100644 --- a/MediaBrowser.Controller/Entities/UserViewBuilder.cs +++ b/MediaBrowser.Controller/Entities/UserViewBuilder.cs @@ -647,7 +647,7 @@ namespace MediaBrowser.Controller.Entities query.SetUser(user); query.Limit = GetSpecialItemsLimit(); query.IncludeItemTypes = new[] { typeof(Episode).Name }; - query.ExcludeLocationTypes = new[] { LocationType.Virtual }; + query.IsVirtualItem = false; return ConvertToResult(_libraryManager.GetItemList(query)); } @@ -1199,7 +1199,7 @@ namespace MediaBrowser.Controller.Entities return false; } - if (query.ExcludeLocationTypes.Length > 0 && query.ExcludeLocationTypes.Contains(item.LocationType)) + if (query.IsVirtualItem.HasValue && item.IsVirtualItem != query.IsVirtualItem.Value) { return false; } diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index 47df12e1b6..fb9c3d2134 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -649,22 +649,8 @@ namespace MediaBrowser.Controller.Entities } } - try - { - var bitrate = i.TotalBitrate ?? - info.MediaStreams.Where(m => m.Type != MediaStreamType.Subtitle && !string.Equals(m.Codec, "mjpeg", StringComparison.OrdinalIgnoreCase)) - .Select(m => m.BitRate ?? 0) - .Sum(); - - if (bitrate > 0) - { - info.Bitrate = bitrate; - } - } - catch (OverflowException ex) - { - Logger.ErrorException("Error calculating total bitrate", ex); - } + info.Bitrate = i.TotalBitrate; + info.InferTotalBitrate(); return info; } diff --git a/MediaBrowser.Controller/IServerApplicationHost.cs b/MediaBrowser.Controller/IServerApplicationHost.cs index 44c0031974..86b52bd775 100644 --- a/MediaBrowser.Controller/IServerApplicationHost.cs +++ b/MediaBrowser.Controller/IServerApplicationHost.cs @@ -22,6 +22,12 @@ 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> diff --git a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs index ffb6a75556..5a139e09d5 100644 --- a/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs +++ b/MediaBrowser.Controller/LiveTv/LiveTvProgram.cs @@ -15,6 +15,11 @@ namespace MediaBrowser.Controller.LiveTv { public class LiveTvProgram : BaseItem, IHasLookupInfo<LiveTvProgramLookupInfo>, IHasStartDate, IHasProgramAttributes { + public LiveTvProgram() + { + IsVirtualItem = true; + } + public override List<string> GetUserDataKeys() { var list = base.GetUserDataKeys(); diff --git a/MediaBrowser.Controller/LiveTv/TimerInfo.cs b/MediaBrowser.Controller/LiveTv/TimerInfo.cs index 10ed95fe5e..3c935f924b 100644 --- a/MediaBrowser.Controller/LiveTv/TimerInfo.cs +++ b/MediaBrowser.Controller/LiveTv/TimerInfo.cs @@ -94,6 +94,7 @@ namespace MediaBrowser.Controller.LiveTv /// <value>The priority.</value> public int Priority { get; set; } + public int RetryCount { get; set; } // Program properties public int? SeasonNumber { get; set; } |
