aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorLukePulverenti <luke.pulverenti@gmail.com>2013-02-21 12:51:17 -0500
committerLukePulverenti <luke.pulverenti@gmail.com>2013-02-21 12:51:26 -0500
commitc5fd7c3bd6a75e75ac411997cd12e91cb80bb25f (patch)
treed206c00dc08017f1a29b52a526cade8062bf5cba
parentec621df5f6ced7339873652197eb77ac1c386419 (diff)
removed ISupportsSpecialFeatures
-rw-r--r--MediaBrowser.Controller/Entities/ISupportsSpecialFeatures.cs105
-rw-r--r--MediaBrowser.Controller/Entities/Movies/Movie.cs62
-rw-r--r--MediaBrowser.Controller/MediaBrowser.Controller.csproj1
3 files changed, 60 insertions, 108 deletions
diff --git a/MediaBrowser.Controller/Entities/ISupportsSpecialFeatures.cs b/MediaBrowser.Controller/Entities/ISupportsSpecialFeatures.cs
deleted file mode 100644
index 9b52c2f7f..000000000
--- a/MediaBrowser.Controller/Entities/ISupportsSpecialFeatures.cs
+++ /dev/null
@@ -1,105 +0,0 @@
-using MediaBrowser.Common.IO;
-using MediaBrowser.Common.Logging;
-using MediaBrowser.Common.Win32;
-using MediaBrowser.Controller.Library;
-using System;
-using System.Collections.Generic;
-using System.IO;
-using System.Linq;
-
-namespace MediaBrowser.Controller.Entities
-{
- /// <summary>
- /// Allows some code sharing between entities that support special features
- /// </summary>
- public interface ISupportsSpecialFeatures
- {
- /// <summary>
- /// Gets the path.
- /// </summary>
- /// <value>The path.</value>
- string Path { get; }
-
- /// <summary>
- /// Gets the name.
- /// </summary>
- /// <value>The name.</value>
- string Name { get; }
-
- /// <summary>
- /// Gets the resolve args.
- /// </summary>
- /// <value>The resolve args.</value>
- ItemResolveArgs ResolveArgs { get; }
-
- /// <summary>
- /// Gets the special features.
- /// </summary>
- /// <value>The special features.</value>
- List<Video> SpecialFeatures { get; }
- }
-
- /// <summary>
- /// Class SpecialFeatures
- /// </summary>
- public static class SpecialFeatures
- {
- /// <summary>
- /// Loads special features from the file system
- /// </summary>
- /// <param name="entity">The entity.</param>
- /// <returns>List{Video}.</returns>
- /// <exception cref="System.ArgumentNullException"></exception>
- public static IEnumerable<Video> LoadSpecialFeatures(ISupportsSpecialFeatures entity)
- {
- if (entity == null)
- {
- throw new ArgumentNullException();
- }
-
- WIN32_FIND_DATA? folder;
-
- try
- {
- folder = entity.ResolveArgs.GetFileSystemEntryByName("specials");
- }
- catch (IOException ex)
- {
- Logger.LogException("Error getting ResolveArgs for {0}", ex, entity.Path);
- return new List<Video> { };
- }
-
- // Path doesn't exist. No biggie
- if (folder == null)
- {
- return new List<Video> {};
- }
-
- IEnumerable<WIN32_FIND_DATA> files;
-
- try
- {
- files = FileSystem.GetFiles(folder.Value.Path);
- }
- catch (IOException ex)
- {
- Logger.LogException("Error loading trailers for {0}", ex, entity.Name);
- return new List<Video> { };
- }
-
- return Kernel.Instance.LibraryManager.GetItems<Video>(files, null).Select(video =>
- {
- // Try to retrieve it from the db. If we don't find it, use the resolved version
- var dbItem = Kernel.Instance.ItemRepository.RetrieveItem(video.Id) as Video;
-
- if (dbItem != null)
- {
- dbItem.ResolveArgs = video.ResolveArgs;
- video = dbItem;
- }
-
- return video;
- });
- }
- }
-}
diff --git a/MediaBrowser.Controller/Entities/Movies/Movie.cs b/MediaBrowser.Controller/Entities/Movies/Movie.cs
index 114e10d37..cc9bcb8d5 100644
--- a/MediaBrowser.Controller/Entities/Movies/Movie.cs
+++ b/MediaBrowser.Controller/Entities/Movies/Movie.cs
@@ -1,7 +1,11 @@
using MediaBrowser.Common.Extensions;
+using MediaBrowser.Common.IO;
+using MediaBrowser.Common.Logging;
+using MediaBrowser.Common.Win32;
using MediaBrowser.Model.Entities;
using System;
using System.Collections.Generic;
+using System.IO;
using System.Linq;
using System.Runtime.Serialization;
using System.Threading;
@@ -12,7 +16,7 @@ namespace MediaBrowser.Controller.Entities.Movies
/// <summary>
/// Class Movie
/// </summary>
- public class Movie : Video, ISupportsSpecialFeatures
+ public class Movie : Video
{
/// <summary>
/// Should be overridden to return the proper folder where metadata lives
@@ -66,7 +70,7 @@ namespace MediaBrowser.Controller.Entities.Movies
{
get
{
- LazyInitializer.EnsureInitialized(ref _specialFeatures, ref _specialFeaturesInitialized, ref _specialFeaturesSyncLock, () => Entities.SpecialFeatures.LoadSpecialFeatures(this).ToList());
+ LazyInitializer.EnsureInitialized(ref _specialFeatures, ref _specialFeaturesInitialized, ref _specialFeaturesSyncLock, () => LoadSpecialFeatures().ToList());
return _specialFeatures;
}
private set
@@ -139,6 +143,60 @@ namespace MediaBrowser.Controller.Entities.Movies
}
return null;
+ }
+
+ /// <summary>
+ /// Loads special features from the file system
+ /// </summary>
+ /// <param name="entity">The entity.</param>
+ /// <returns>List{Video}.</returns>
+ /// <exception cref="System.ArgumentNullException"></exception>
+ private IEnumerable<Video> LoadSpecialFeatures()
+ {
+ WIN32_FIND_DATA? folder;
+
+ try
+ {
+ folder = ResolveArgs.GetFileSystemEntryByName("specials");
+ }
+ catch (IOException ex)
+ {
+ Logger.LogException("Error getting ResolveArgs for {0}", ex, Path);
+ return new List<Video> { };
+ }
+
+ // Path doesn't exist. No biggie
+ if (folder == null)
+ {
+ return new List<Video> { };
+ }
+
+ IEnumerable<WIN32_FIND_DATA> files;
+
+ try
+ {
+ files = FileSystem.GetFiles(folder.Value.Path);
+ }
+ catch (IOException ex)
+ {
+ Logger.LogException("Error loading trailers for {0}", ex, Name);
+ return new List<Video> { };
+ }
+
+ return Kernel.Instance.LibraryManager.GetItems<Video>(files, null).Select(video =>
+ {
+ // Try to retrieve it from the db. If we don't find it, use the resolved version
+ var dbItem = Kernel.Instance.ItemRepository.RetrieveItem(video.Id) as Video;
+
+ if (dbItem != null)
+ {
+ dbItem.ResolveArgs = video.ResolveArgs;
+ video = dbItem;
+ }
+
+ return video;
+ });
}
+
}
}
diff --git a/MediaBrowser.Controller/MediaBrowser.Controller.csproj b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
index 0db617335..f592466a6 100644
--- a/MediaBrowser.Controller/MediaBrowser.Controller.csproj
+++ b/MediaBrowser.Controller/MediaBrowser.Controller.csproj
@@ -90,7 +90,6 @@
<Compile Include="Entities\ICollectionFolder.cs" />
<Compile Include="Entities\IndexFolder.cs" />
<Compile Include="Entities\Movies\BoxSet.cs" />
- <Compile Include="Entities\ISupportsSpecialFeatures.cs" />
<Compile Include="Entities\Movies\Movie.cs" />
<Compile Include="Entities\Person.cs" />
<Compile Include="Entities\PlaybackProgressEventArgs.cs" />