From 6efb78b8b2c023369d18097ba8d17c396faabce1 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Mon, 3 Mar 2014 00:11:03 -0500 Subject: fixes #697 - Support xbmc offline discs --- MediaBrowser.Controller/Entities/BaseItem.cs | 14 +------------- MediaBrowser.Controller/Entities/Folder.cs | 22 +++++++++++++++++++++- MediaBrowser.Controller/Entities/Game.cs | 8 ++++---- MediaBrowser.Controller/Entities/IHasMetadata.cs | 6 ++++++ .../Entities/ISupportsPlaceHolders.cs | 12 ++++++++++++ MediaBrowser.Controller/Entities/Video.cs | 4 +++- MediaBrowser.Controller/Library/TVUtils.cs | 7 +++++-- .../MediaBrowser.Controller.csproj | 1 + .../Resolvers/BaseVideoResolver.cs | 7 +++++-- .../Resolvers/EntityResolutionHelper.cs | 18 ++++++++++++++++++ 10 files changed, 76 insertions(+), 23 deletions(-) create mode 100644 MediaBrowser.Controller/Entities/ISupportsPlaceHolders.cs (limited to 'MediaBrowser.Controller') diff --git a/MediaBrowser.Controller/Entities/BaseItem.cs b/MediaBrowser.Controller/Entities/BaseItem.cs index f7f2346a8e..923673bd83 100644 --- a/MediaBrowser.Controller/Entities/BaseItem.cs +++ b/MediaBrowser.Controller/Entities/BaseItem.cs @@ -229,19 +229,7 @@ namespace MediaBrowser.Controller.Entities } } - [IgnoreDataMember] - public bool IsUnidentified - { - get - { - if (ProviderIds.Any()) - { - return false; - } - - return false; - } - } + public bool IsUnidentified { get; set; } /// /// Gets or sets the locked fields. diff --git a/MediaBrowser.Controller/Entities/Folder.cs b/MediaBrowser.Controller/Entities/Folder.cs index 522bc3a2d7..627f657ab3 100644 --- a/MediaBrowser.Controller/Entities/Folder.cs +++ b/MediaBrowser.Controller/Entities/Folder.cs @@ -352,6 +352,26 @@ namespace MediaBrowser.Controller.Entities return dictionary; } + private bool IsValidFromResolver(BaseItem current, BaseItem newItem) + { + var currentAsPlaceHolder = current as ISupportsPlaceHolders; + + if (currentAsPlaceHolder != null) + { + var newHasPlaceHolder = newItem as ISupportsPlaceHolders; + + if (newHasPlaceHolder != null) + { + if (currentAsPlaceHolder.IsPlaceHolder != newHasPlaceHolder.IsPlaceHolder) + { + return false; + } + } + } + + return current.IsInMixedFolder == newItem.IsInMixedFolder; + } + /// /// Validates the children internal. /// @@ -401,7 +421,7 @@ namespace MediaBrowser.Controller.Entities { BaseItem currentChild; - if (currentChildren.TryGetValue(child.Id, out currentChild) && child.IsInMixedFolder == currentChild.IsInMixedFolder) + if (currentChildren.TryGetValue(child.Id, out currentChild) && IsValidFromResolver(currentChild, child)) { var currentChildLocationType = currentChild.LocationType; if (currentChildLocationType != LocationType.Remote && diff --git a/MediaBrowser.Controller/Entities/Game.cs b/MediaBrowser.Controller/Entities/Game.cs index e490a59cd0..062bdfa88a 100644 --- a/MediaBrowser.Controller/Entities/Game.cs +++ b/MediaBrowser.Controller/Entities/Game.cs @@ -7,7 +7,7 @@ using System.Linq; namespace MediaBrowser.Controller.Entities { - public class Game : BaseItem, IHasSoundtracks, IHasTrailers, IHasThemeMedia, IHasTags, IHasScreenshots, IHasPreferredMetadataLanguage, IHasLookupInfo + public class Game : BaseItem, IHasSoundtracks, IHasTrailers, IHasThemeMedia, IHasTags, IHasScreenshots, ISupportsPlaceHolders, IHasPreferredMetadataLanguage, IHasLookupInfo { public List SoundtrackIds { get; set; } @@ -63,10 +63,10 @@ namespace MediaBrowser.Controller.Entities public int? PlayersSupported { get; set; } /// - /// Gets or sets a value indicating whether this instance is installed on client. + /// Gets a value indicating whether this instance is place holder. /// - /// true if this instance is installed on client; otherwise, false. - public bool IsInstalledOnClient { get; set; } + /// true if this instance is place holder; otherwise, false. + public bool IsPlaceHolder { get; set; } /// /// Gets or sets the game system. diff --git a/MediaBrowser.Controller/Entities/IHasMetadata.cs b/MediaBrowser.Controller/Entities/IHasMetadata.cs index 095db08157..91f37135f1 100644 --- a/MediaBrowser.Controller/Entities/IHasMetadata.cs +++ b/MediaBrowser.Controller/Entities/IHasMetadata.cs @@ -49,5 +49,11 @@ namespace MediaBrowser.Controller.Entities /// /// true if XXXX, false otherwise. bool BeforeMetadataRefresh(); + + /// + /// Gets or sets a value indicating whether this instance is unidentified. + /// + /// true if this instance is unidentified; otherwise, false. + bool IsUnidentified { get; set; } } } diff --git a/MediaBrowser.Controller/Entities/ISupportsPlaceHolders.cs b/MediaBrowser.Controller/Entities/ISupportsPlaceHolders.cs new file mode 100644 index 0000000000..2507c8ee65 --- /dev/null +++ b/MediaBrowser.Controller/Entities/ISupportsPlaceHolders.cs @@ -0,0 +1,12 @@ + +namespace MediaBrowser.Controller.Entities +{ + public interface ISupportsPlaceHolders + { + /// + /// Gets a value indicating whether this instance is place holder. + /// + /// true if this instance is place holder; otherwise, false. + bool IsPlaceHolder { get; } + } +} diff --git a/MediaBrowser.Controller/Entities/Video.cs b/MediaBrowser.Controller/Entities/Video.cs index fa85f0edce..e61e958f5e 100644 --- a/MediaBrowser.Controller/Entities/Video.cs +++ b/MediaBrowser.Controller/Entities/Video.cs @@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entities /// /// Class Video /// - public class Video : BaseItem, IHasMediaStreams, IHasAspectRatio, IHasTags + public class Video : BaseItem, IHasMediaStreams, IHasAspectRatio, IHasTags, ISupportsPlaceHolders { public bool IsMultiPart { get; set; } @@ -42,6 +42,8 @@ namespace MediaBrowser.Controller.Entities /// true if this instance has subtitles; otherwise, false. public bool HasSubtitles { get; set; } + public bool IsPlaceHolder { get; set; } + /// /// Gets or sets the tags. /// diff --git a/MediaBrowser.Controller/Library/TVUtils.cs b/MediaBrowser.Controller/Library/TVUtils.cs index 82911117f3..c64e4fa0ca 100644 --- a/MediaBrowser.Controller/Library/TVUtils.cs +++ b/MediaBrowser.Controller/Library/TVUtils.cs @@ -234,9 +234,12 @@ namespace MediaBrowser.Controller.Library { var fullName = child.FullName; - if (EntityResolutionHelper.IsVideoFile(fullName) && GetEpisodeNumberFromFile(fullName, false).HasValue) + if (EntityResolutionHelper.IsVideoFile(fullName) || EntityResolutionHelper.IsVideoPlaceHolder(fullName)) { - return true; + if (GetEpisodeNumberFromFile(fullName, false).HasValue) + { + return true; + } } } } diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj index c07693b36b..ff446f2ef8 100644 --- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj +++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj @@ -105,6 +105,7 @@ + diff --git a/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs b/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs index aadaf54231..9e5d68c489 100644 --- a/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs +++ b/MediaBrowser.Controller/Resolvers/BaseVideoResolver.cs @@ -35,7 +35,9 @@ namespace MediaBrowser.Controller.Resolvers // If the path is a file check for a matching extensions if (!args.IsDirectory) { - if (EntityResolutionHelper.IsVideoFile(args.Path)) + var isPlaceHolder = EntityResolutionHelper.IsVideoPlaceHolder(args.Path); + + if (EntityResolutionHelper.IsVideoFile(args.Path) || isPlaceHolder) { var extension = Path.GetExtension(args.Path); @@ -46,7 +48,8 @@ namespace MediaBrowser.Controller.Resolvers { VideoType = type, Path = args.Path, - IsInMixedFolder = true + IsInMixedFolder = true, + IsPlaceHolder = isPlaceHolder }; } } diff --git a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs index 42b637140f..0f93e8e8a1 100644 --- a/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs +++ b/MediaBrowser.Controller/Resolvers/EntityResolutionHelper.cs @@ -139,6 +139,24 @@ namespace MediaBrowser.Controller.Resolvers return VideoFileExtensionsDictionary.ContainsKey(extension); } + /// + /// Determines whether [is place holder] [the specified path]. + /// + /// The path. + /// true if [is place holder] [the specified path]; otherwise, false. + /// path + public static bool IsVideoPlaceHolder(string path) + { + if (string.IsNullOrEmpty(path)) + { + throw new ArgumentNullException("path"); + } + + var extension = Path.GetExtension(path); + + return string.Equals(extension, ".disc", StringComparison.OrdinalIgnoreCase); + } + /// /// Ensures DateCreated and DateModified have values /// -- cgit v1.2.3