More comments and cleanup. Added special feature provider for movies
This commit is contained in:
parent
8d693fd2ab
commit
f218e6b583
|
@ -13,12 +13,15 @@ namespace MediaBrowser.Controller.FFMpeg
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public static class FFProbe
|
public static class FFProbe
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Runs FFProbe against an Audio file, caches the result and returns the output
|
||||||
|
/// </summary>
|
||||||
public static FFProbeResult Run(Audio item)
|
public static FFProbeResult Run(Audio item)
|
||||||
{
|
{
|
||||||
// Use try catch to avoid having to use File.Exists
|
// Use try catch to avoid having to use File.Exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return GetCachedResult(GetFFProbeAudioCachePath(item));
|
return GetCachedResult(GetFFProbeCachePath(item));
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
catch (FileNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -31,16 +34,22 @@ namespace MediaBrowser.Controller.FFMpeg
|
||||||
FFProbeResult result = Run(item.Path);
|
FFProbeResult result = Run(item.Path);
|
||||||
|
|
||||||
// Fire and forget
|
// Fire and forget
|
||||||
CacheResult(result, GetFFProbeAudioCachePath(item));
|
CacheResult(result, GetFFProbeCachePath(item));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets the cached result of an FFProbe operation
|
||||||
|
/// </summary>
|
||||||
private static FFProbeResult GetCachedResult(string path)
|
private static FFProbeResult GetCachedResult(string path)
|
||||||
{
|
{
|
||||||
return ProtobufSerializer.DeserializeFromFile<FFProbeResult>(path);
|
return ProtobufSerializer.DeserializeFromFile<FFProbeResult>(path);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Caches the result of an FFProbe operation
|
||||||
|
/// </summary>
|
||||||
private static async void CacheResult(FFProbeResult result, string outputCachePath)
|
private static async void CacheResult(FFProbeResult result, string outputCachePath)
|
||||||
{
|
{
|
||||||
await Task.Run(() =>
|
await Task.Run(() =>
|
||||||
|
@ -56,12 +65,15 @@ namespace MediaBrowser.Controller.FFMpeg
|
||||||
}).ConfigureAwait(false);
|
}).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Runs FFProbe against a Video file, caches the result and returns the output
|
||||||
|
/// </summary>
|
||||||
public static FFProbeResult Run(Video item)
|
public static FFProbeResult Run(Video item)
|
||||||
{
|
{
|
||||||
// Use try catch to avoid having to use File.Exists
|
// Use try catch to avoid having to use File.Exists
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
return GetCachedResult(GetFFProbeVideoCachePath(item));
|
return GetCachedResult(GetFFProbeCachePath(item));
|
||||||
}
|
}
|
||||||
catch (FileNotFoundException)
|
catch (FileNotFoundException)
|
||||||
{
|
{
|
||||||
|
@ -74,7 +86,7 @@ namespace MediaBrowser.Controller.FFMpeg
|
||||||
FFProbeResult result = Run(item.Path);
|
FFProbeResult result = Run(item.Path);
|
||||||
|
|
||||||
// Fire and forget
|
// Fire and forget
|
||||||
CacheResult(result, GetFFProbeVideoCachePath(item));
|
CacheResult(result, GetFFProbeCachePath(item));
|
||||||
|
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
@ -131,14 +143,14 @@ namespace MediaBrowser.Controller.FFMpeg
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetFFProbeAudioCachePath(BaseEntity item)
|
private static string GetFFProbeCachePath(Audio item)
|
||||||
{
|
{
|
||||||
string outputDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.FFProbeAudioCacheDirectory, item.Id.ToString().Substring(0, 1));
|
string outputDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.FFProbeAudioCacheDirectory, item.Id.ToString().Substring(0, 1));
|
||||||
|
|
||||||
return Path.Combine(outputDirectory, item.Id + "-" + item.DateModified.Ticks + ".pb");
|
return Path.Combine(outputDirectory, item.Id + "-" + item.DateModified.Ticks + ".pb");
|
||||||
}
|
}
|
||||||
|
|
||||||
private static string GetFFProbeVideoCachePath(BaseEntity item)
|
private static string GetFFProbeCachePath(Video item)
|
||||||
{
|
{
|
||||||
string outputDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.FFProbeVideoCacheDirectory, item.Id.ToString().Substring(0, 1));
|
string outputDirectory = Path.Combine(Kernel.Instance.ApplicationPaths.FFProbeVideoCacheDirectory, item.Id.ToString().Substring(0, 1));
|
||||||
|
|
||||||
|
|
|
@ -1,32 +1,61 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Runtime.InteropServices;
|
using System.Runtime.InteropServices;
|
||||||
|
|
||||||
using System.Runtime.ConstrainedExecution;
|
|
||||||
using Microsoft.Win32.SafeHandles;
|
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.IO
|
namespace MediaBrowser.Controller.IO
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides low level File access that is much faster than the File/Directory api's
|
||||||
|
/// </summary>
|
||||||
public static class FileData
|
public static class FileData
|
||||||
{
|
{
|
||||||
public const int MAX_PATH = 260;
|
public const int MAX_PATH = 260;
|
||||||
public const int MAX_ALTERNATE = 14;
|
public const int MAX_ALTERNATE = 14;
|
||||||
|
|
||||||
public static WIN32_FIND_DATA GetFileData(string fileName)
|
/// <summary>
|
||||||
|
/// Gets information about a path
|
||||||
|
/// </summary>
|
||||||
|
public static WIN32_FIND_DATA GetFileData(string path)
|
||||||
{
|
{
|
||||||
WIN32_FIND_DATA data;
|
WIN32_FIND_DATA data;
|
||||||
IntPtr handle = FindFirstFile(fileName, out data);
|
IntPtr handle = FindFirstFile(path, out data);
|
||||||
if (handle == IntPtr.Zero)
|
if (handle == IntPtr.Zero)
|
||||||
throw new IOException("FindFirstFile failed");
|
throw new IOException("FindFirstFile failed");
|
||||||
FindClose(handle);
|
FindClose(handle);
|
||||||
|
|
||||||
data.Path = fileName;
|
data.Path = path;
|
||||||
return data;
|
return data;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all file system entries within a foler
|
||||||
|
/// </summary>
|
||||||
public static IEnumerable<WIN32_FIND_DATA> GetFileSystemEntries(string path, string searchPattern)
|
public static IEnumerable<WIN32_FIND_DATA> GetFileSystemEntries(string path, string searchPattern)
|
||||||
|
{
|
||||||
|
return GetFileSystemEntries(path, searchPattern, true, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all files within a folder
|
||||||
|
/// </summary>
|
||||||
|
public static IEnumerable<WIN32_FIND_DATA> GetFiles(string path, string searchPattern)
|
||||||
|
{
|
||||||
|
return GetFileSystemEntries(path, searchPattern, true, false);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all sub-directories within a folder
|
||||||
|
/// </summary>
|
||||||
|
public static IEnumerable<WIN32_FIND_DATA> GetDirectories(string path, string searchPattern)
|
||||||
|
{
|
||||||
|
return GetFileSystemEntries(path, searchPattern, false, true);
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Gets all file system entries within a foler
|
||||||
|
/// </summary>
|
||||||
|
public static IEnumerable<WIN32_FIND_DATA> GetFileSystemEntries(string path, string searchPattern, bool includeFiles, bool includeDirectories)
|
||||||
{
|
{
|
||||||
string lpFileName = Path.Combine(path, searchPattern);
|
string lpFileName = Path.Combine(path, searchPattern);
|
||||||
|
|
||||||
|
@ -43,14 +72,14 @@ namespace MediaBrowser.Controller.IO
|
||||||
yield break;
|
yield break;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (IsValid(lpFindFileData.cFileName))
|
if (IncludeInOutput(lpFindFileData.cFileName, lpFindFileData.dwFileAttributes, includeFiles, includeDirectories))
|
||||||
{
|
{
|
||||||
yield return lpFindFileData;
|
yield return lpFindFileData;
|
||||||
}
|
}
|
||||||
|
|
||||||
while (FindNextFile(handle, out lpFindFileData) != IntPtr.Zero)
|
while (FindNextFile(handle, out lpFindFileData) != IntPtr.Zero)
|
||||||
{
|
{
|
||||||
if (IsValid(lpFindFileData.cFileName))
|
if (IncludeInOutput(lpFindFileData.cFileName, lpFindFileData.dwFileAttributes, includeFiles, includeDirectories))
|
||||||
{
|
{
|
||||||
lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName);
|
lpFindFileData.Path = Path.Combine(path, lpFindFileData.cFileName);
|
||||||
yield return lpFindFileData;
|
yield return lpFindFileData;
|
||||||
|
@ -60,7 +89,7 @@ namespace MediaBrowser.Controller.IO
|
||||||
FindClose(handle);
|
FindClose(handle);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static bool IsValid(string cFileName)
|
private static bool IncludeInOutput(string cFileName, FileAttributes attributes, bool includeFiles, bool includeDirectories)
|
||||||
{
|
{
|
||||||
if (cFileName.Equals(".", StringComparison.OrdinalIgnoreCase))
|
if (cFileName.Equals(".", StringComparison.OrdinalIgnoreCase))
|
||||||
{
|
{
|
||||||
|
@ -71,6 +100,16 @@ namespace MediaBrowser.Controller.IO
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (!includeFiles && !attributes.HasFlag(FileAttributes.Directory))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (!includeDirectories && attributes.HasFlag(FileAttributes.Directory))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -9,7 +9,6 @@ using System.Text;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Kernel;
|
using MediaBrowser.Common.Kernel;
|
||||||
using MediaBrowser.Controller.Configuration;
|
using MediaBrowser.Controller.Configuration;
|
||||||
using MediaBrowser.Controller.Events;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
|
|
|
@ -4,7 +4,6 @@ using System.Collections.Generic;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
|
|
|
@ -3,7 +3,7 @@ using System.IO;
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Events
|
namespace MediaBrowser.Controller.Library
|
||||||
{
|
{
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// This is an EventArgs object used when resolving a Path into a BaseItem
|
/// This is an EventArgs object used when resolving a Path into a BaseItem
|
|
@ -55,7 +55,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Configuration\ServerApplicationPaths.cs" />
|
<Compile Include="Configuration\ServerApplicationPaths.cs" />
|
||||||
<Compile Include="Configuration\ServerConfiguration.cs" />
|
<Compile Include="Configuration\ServerConfiguration.cs" />
|
||||||
<Compile Include="Events\ItemResolveEventArgs.cs" />
|
<Compile Include="Library\ItemResolveEventArgs.cs" />
|
||||||
<Compile Include="FFMpeg\FFProbe.cs" />
|
<Compile Include="FFMpeg\FFProbe.cs" />
|
||||||
<Compile Include="FFMpeg\FFProbeResult.cs" />
|
<Compile Include="FFMpeg\FFProbeResult.cs" />
|
||||||
<Compile Include="IO\DirectoryWatchers.cs" />
|
<Compile Include="IO\DirectoryWatchers.cs" />
|
||||||
|
|
|
@ -5,8 +5,8 @@ using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Logging;
|
using MediaBrowser.Common.Logging;
|
||||||
using MediaBrowser.Controller.Events;
|
|
||||||
using MediaBrowser.Controller.FFMpeg;
|
using MediaBrowser.Controller.FFMpeg;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Controller.Providers
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System;
|
using System;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Controller.Providers
|
||||||
|
|
|
@ -1,12 +1,15 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Xml;
|
using MediaBrowser.Controller.Xml;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Controller.Providers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides metadata for Folders and all subclasses by parsing folder.xml
|
||||||
|
/// </summary>
|
||||||
[Export(typeof(BaseMetadataProvider))]
|
[Export(typeof(BaseMetadataProvider))]
|
||||||
public class FolderProviderFromXml : BaseMetadataProvider
|
public class FolderProviderFromXml : BaseMetadataProvider
|
||||||
{
|
{
|
||||||
|
@ -21,16 +24,16 @@ namespace MediaBrowser.Controller.Providers
|
||||||
}
|
}
|
||||||
|
|
||||||
public async override Task FetchAsync(BaseEntity item, ItemResolveEventArgs args)
|
public async override Task FetchAsync(BaseEntity item, ItemResolveEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.ContainsFile("folder.xml"))
|
||||||
{
|
{
|
||||||
await Task.Run(() => { Fetch(item, args); }).ConfigureAwait(false);
|
await Task.Run(() => { Fetch(item, args); }).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private void Fetch(BaseEntity item, ItemResolveEventArgs args)
|
private void Fetch(BaseEntity item, ItemResolveEventArgs args)
|
||||||
{
|
|
||||||
if (args.ContainsFile("folder.xml"))
|
|
||||||
{
|
{
|
||||||
new BaseItemXmlParser<Folder>().Fetch(item as Folder, Path.Combine(args.Path, "folder.xml"));
|
new BaseItemXmlParser<Folder>().Fetch(item as Folder, Path.Combine(args.Path, "folder.xml"));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -3,11 +3,14 @@ using System.Collections.Generic;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Controller.Providers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides images for all types by looking for standard images - folder, backdrop, logo, etc.
|
||||||
|
/// </summary>
|
||||||
[Export(typeof(BaseMetadataProvider))]
|
[Export(typeof(BaseMetadataProvider))]
|
||||||
public class ImageFromMediaLocationProvider : BaseMetadataProvider
|
public class ImageFromMediaLocationProvider : BaseMetadataProvider
|
||||||
{
|
{
|
||||||
|
|
|
@ -2,12 +2,15 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Controller.Providers
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Provides local trailers by checking the trailers subfolder
|
||||||
|
/// </summary>
|
||||||
[Export(typeof(BaseMetadataProvider))]
|
[Export(typeof(BaseMetadataProvider))]
|
||||||
public class LocalTrailerProvider : BaseMetadataProvider
|
public class LocalTrailerProvider : BaseMetadataProvider
|
||||||
{
|
{
|
||||||
|
|
|
@ -4,10 +4,9 @@ using System.ComponentModel.Composition;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Common.Logging;
|
using MediaBrowser.Common.Logging;
|
||||||
using MediaBrowser.Controller.Events;
|
|
||||||
using MediaBrowser.Controller.FFMpeg;
|
using MediaBrowser.Controller.FFMpeg;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Providers
|
namespace MediaBrowser.Controller.Providers
|
||||||
{
|
{
|
||||||
|
@ -38,12 +37,6 @@ namespace MediaBrowser.Controller.Providers
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
|
|
||||||
// For now
|
|
||||||
if (Path.GetExtension(video.Path).EndsWith("iso", StringComparison.OrdinalIgnoreCase))
|
|
||||||
{
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (CanSkip(video))
|
if (CanSkip(video))
|
||||||
{
|
{
|
||||||
return;
|
return;
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Resolvers
|
namespace MediaBrowser.Controller.Resolvers
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Events;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Resolvers
|
namespace MediaBrowser.Controller.Resolvers
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Resolvers
|
namespace MediaBrowser.Controller.Resolvers
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Resolvers
|
namespace MediaBrowser.Controller.Resolvers
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Resolvers
|
namespace MediaBrowser.Controller.Resolvers
|
||||||
|
|
|
@ -43,6 +43,7 @@
|
||||||
<ItemGroup>
|
<ItemGroup>
|
||||||
<Compile Include="Entities\BoxSet.cs" />
|
<Compile Include="Entities\BoxSet.cs" />
|
||||||
<Compile Include="Providers\MovieProviderFromXml.cs" />
|
<Compile Include="Providers\MovieProviderFromXml.cs" />
|
||||||
|
<Compile Include="Providers\MovieSpecialFeaturesProvider.cs" />
|
||||||
<Compile Include="Resolvers\BoxSetResolver.cs" />
|
<Compile Include="Resolvers\BoxSetResolver.cs" />
|
||||||
<Compile Include="Entities\Movie.cs" />
|
<Compile Include="Entities\Movie.cs" />
|
||||||
<Compile Include="Resolvers\MovieResolver.cs" />
|
<Compile Include="Resolvers\MovieResolver.cs" />
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Controller.Xml;
|
using MediaBrowser.Controller.Xml;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
|
|
@ -0,0 +1,47 @@
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.ComponentModel.Composition;
|
||||||
|
using System.IO;
|
||||||
|
using System.Threading.Tasks;
|
||||||
|
using MediaBrowser.Controller;
|
||||||
|
using MediaBrowser.Controller.IO;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.Providers;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Movies.Entities;
|
||||||
|
|
||||||
|
namespace MediaBrowser.Movies.Providers
|
||||||
|
{
|
||||||
|
[Export(typeof(BaseMetadataProvider))]
|
||||||
|
public class MovieSpecialFeaturesProvider : BaseMetadataProvider
|
||||||
|
{
|
||||||
|
public override bool Supports(BaseEntity item)
|
||||||
|
{
|
||||||
|
return item is Movie;
|
||||||
|
}
|
||||||
|
|
||||||
|
public override MetadataProviderPriority Priority
|
||||||
|
{
|
||||||
|
get { return MetadataProviderPriority.First; }
|
||||||
|
}
|
||||||
|
|
||||||
|
public async override Task FetchAsync(BaseEntity item, ItemResolveEventArgs args)
|
||||||
|
{
|
||||||
|
if (args.ContainsFolder("specials"))
|
||||||
|
{
|
||||||
|
List<Video> items = new List<Video>();
|
||||||
|
|
||||||
|
foreach (WIN32_FIND_DATA file in FileData.GetFileSystemEntries(Path.Combine(args.Path, "specials"), "*"))
|
||||||
|
{
|
||||||
|
Video video = await Kernel.Instance.ItemController.GetItem(file.Path, fileInfo: file).ConfigureAwait(false) as Video;
|
||||||
|
|
||||||
|
if (video != null)
|
||||||
|
{
|
||||||
|
items.Add(video);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
(item as Movie).SpecialFeatures = items;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -1,7 +1,7 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.Movies.Entities;
|
using MediaBrowser.Movies.Entities;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using MediaBrowser.Controller.Events;
|
|
||||||
using MediaBrowser.Controller.IO;
|
using MediaBrowser.Controller.IO;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.Movies.Entities;
|
using MediaBrowser.Movies.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.Movies.Resolvers
|
namespace MediaBrowser.Movies.Resolvers
|
||||||
|
@ -22,6 +23,28 @@ namespace MediaBrowser.Movies.Resolvers
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void SetInitialItemValues(Movie item, ItemResolveEventArgs args)
|
||||||
|
{
|
||||||
|
base.SetInitialItemValues(item, args);
|
||||||
|
|
||||||
|
SetProviderIdFromPath(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetProviderIdFromPath(Movie item)
|
||||||
|
{
|
||||||
|
string srch = "[tmdbid=";
|
||||||
|
int index = item.Path.IndexOf(srch, System.StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
string id = item.Path.Substring(index + srch.Length);
|
||||||
|
|
||||||
|
id = id.Substring(0, id.IndexOf(']'));
|
||||||
|
|
||||||
|
item.SetProviderId(MetadataProviders.Tmdb, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
private Movie GetMovie(ItemResolveEventArgs args)
|
private Movie GetMovie(ItemResolveEventArgs args)
|
||||||
{
|
{
|
||||||
// Loop through each child file/folder and see if we find a video
|
// Loop through each child file/folder and see if we find a video
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using MediaBrowser.Common.Plugins;
|
using MediaBrowser.Common.Plugins;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Model.Plugins;
|
using MediaBrowser.Model.Plugins;
|
||||||
using MediaBrowser.TV.Entities;
|
using MediaBrowser.TV.Entities;
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,7 @@
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.TV.Entities;
|
using MediaBrowser.TV.Entities;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.TV.Entities;
|
using MediaBrowser.TV.Entities;
|
||||||
|
|
|
@ -1,7 +1,7 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Threading.Tasks;
|
using System.Threading.Tasks;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers;
|
using MediaBrowser.Controller.Providers;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.TV.Entities;
|
using MediaBrowser.TV.Entities;
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.TV.Entities;
|
using MediaBrowser.TV.Entities;
|
||||||
|
|
||||||
|
|
|
@ -1,6 +1,6 @@
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
using MediaBrowser.TV.Entities;
|
using MediaBrowser.TV.Entities;
|
||||||
|
|
||||||
|
|
|
@ -1,8 +1,9 @@
|
||||||
using System;
|
using System;
|
||||||
using System.ComponentModel.Composition;
|
using System.ComponentModel.Composition;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using MediaBrowser.Controller.Events;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Resolvers;
|
using MediaBrowser.Controller.Resolvers;
|
||||||
|
using MediaBrowser.Model.Entities;
|
||||||
using MediaBrowser.TV.Entities;
|
using MediaBrowser.TV.Entities;
|
||||||
|
|
||||||
namespace MediaBrowser.TV.Resolvers
|
namespace MediaBrowser.TV.Resolvers
|
||||||
|
@ -32,5 +33,27 @@ namespace MediaBrowser.TV.Resolvers
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected override void SetInitialItemValues(Series item, ItemResolveEventArgs args)
|
||||||
|
{
|
||||||
|
base.SetInitialItemValues(item, args);
|
||||||
|
|
||||||
|
SetProviderIdFromPath(item);
|
||||||
|
}
|
||||||
|
|
||||||
|
private void SetProviderIdFromPath(Series item)
|
||||||
|
{
|
||||||
|
string srch = "[tvdbid=";
|
||||||
|
int index = item.Path.IndexOf(srch, System.StringComparison.OrdinalIgnoreCase);
|
||||||
|
|
||||||
|
if (index != -1)
|
||||||
|
{
|
||||||
|
string id = item.Path.Substring(index + srch.Length);
|
||||||
|
|
||||||
|
id = id.Substring(0, id.IndexOf(']'));
|
||||||
|
|
||||||
|
item.SetProviderId(MetadataProviders.Tvdb, id);
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user