fixes #697 - Support xbmc offline discs

This commit is contained in:
Luke Pulverenti
2014-03-03 00:11:03 -05:00
parent 2db452f68f
commit 6efb78b8b2
27 changed files with 154 additions and 45 deletions

View File

@@ -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; }
/// <summary>
/// Gets or sets the locked fields.

View File

@@ -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;
}
/// <summary>
/// Validates the children internal.
/// </summary>
@@ -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 &&

View File

@@ -7,7 +7,7 @@ using System.Linq;
namespace MediaBrowser.Controller.Entities
{
public class Game : BaseItem, IHasSoundtracks, IHasTrailers, IHasThemeMedia, IHasTags, IHasScreenshots, IHasPreferredMetadataLanguage, IHasLookupInfo<GameInfo>
public class Game : BaseItem, IHasSoundtracks, IHasTrailers, IHasThemeMedia, IHasTags, IHasScreenshots, ISupportsPlaceHolders, IHasPreferredMetadataLanguage, IHasLookupInfo<GameInfo>
{
public List<Guid> SoundtrackIds { get; set; }
@@ -63,10 +63,10 @@ namespace MediaBrowser.Controller.Entities
public int? PlayersSupported { get; set; }
/// <summary>
/// Gets or sets a value indicating whether this instance is installed on client.
/// Gets a value indicating whether this instance is place holder.
/// </summary>
/// <value><c>true</c> if this instance is installed on client; otherwise, <c>false</c>.</value>
public bool IsInstalledOnClient { get; set; }
/// <value><c>true</c> if this instance is place holder; otherwise, <c>false</c>.</value>
public bool IsPlaceHolder { get; set; }
/// <summary>
/// Gets or sets the game system.

View File

@@ -49,5 +49,11 @@ namespace MediaBrowser.Controller.Entities
/// </summary>
/// <returns><c>true</c> if XXXX, <c>false</c> otherwise.</returns>
bool BeforeMetadataRefresh();
/// <summary>
/// Gets or sets a value indicating whether this instance is unidentified.
/// </summary>
/// <value><c>true</c> if this instance is unidentified; otherwise, <c>false</c>.</value>
bool IsUnidentified { get; set; }
}
}

View File

@@ -0,0 +1,12 @@

namespace MediaBrowser.Controller.Entities
{
public interface ISupportsPlaceHolders
{
/// <summary>
/// Gets a value indicating whether this instance is place holder.
/// </summary>
/// <value><c>true</c> if this instance is place holder; otherwise, <c>false</c>.</value>
bool IsPlaceHolder { get; }
}
}

View File

@@ -16,7 +16,7 @@ namespace MediaBrowser.Controller.Entities
/// <summary>
/// Class Video
/// </summary>
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
/// <value><c>true</c> if this instance has subtitles; otherwise, <c>false</c>.</value>
public bool HasSubtitles { get; set; }
public bool IsPlaceHolder { get; set; }
/// <summary>
/// Gets or sets the tags.
/// </summary>

View File

@@ -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;
}
}
}
}

View File

@@ -105,6 +105,7 @@
<Compile Include="Entities\ILibraryItem.cs" />
<Compile Include="Entities\ImageSourceInfo.cs" />
<Compile Include="Entities\IMetadataContainer.cs" />
<Compile Include="Entities\ISupportsPlaceHolders.cs" />
<Compile Include="Entities\ItemImageInfo.cs" />
<Compile Include="Entities\LinkedChild.cs" />
<Compile Include="Entities\MusicVideo.cs" />

View File

@@ -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
};
}
}

View File

@@ -139,6 +139,24 @@ namespace MediaBrowser.Controller.Resolvers
return VideoFileExtensionsDictionary.ContainsKey(extension);
}
/// <summary>
/// Determines whether [is place holder] [the specified path].
/// </summary>
/// <param name="path">The path.</param>
/// <returns><c>true</c> if [is place holder] [the specified path]; otherwise, <c>false</c>.</returns>
/// <exception cref="System.ArgumentNullException">path</exception>
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);
}
/// <summary>
/// Ensures DateCreated and DateModified have values
/// </summary>