Moved the http server to it's own assembly. added comments and made other minor re-organizations.
This commit is contained in:
parent
6fbd5cf464
commit
80b3ad7bd2
@@ -8,6 +8,8 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
{
|
||||
protected override Audio Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
// Return audio if the path is a file and has a matching extension
|
||||
|
||||
if (!args.IsFolder)
|
||||
{
|
||||
if (IsAudioFile(args.Path))
|
||||
|
||||
@@ -15,6 +15,9 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
return null;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Sets initial values on the newly resolved item
|
||||
/// </summary>
|
||||
protected virtual void SetItemValues(T item, ItemResolveEventArgs args)
|
||||
{
|
||||
// If the subclass didn't specify this
|
||||
@@ -23,6 +26,7 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
item.Path = args.Path;
|
||||
}
|
||||
|
||||
// If the subclass didn't specify this
|
||||
if (args.Parent != null)
|
||||
{
|
||||
item.Parent = args.Parent;
|
||||
@@ -40,9 +44,14 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
|
||||
if (item != null)
|
||||
{
|
||||
// Set initial values on the newly resolved item
|
||||
|
||||
SetItemValues(item, args);
|
||||
|
||||
// Make sure the item has a name
|
||||
EnsureName(item);
|
||||
|
||||
// Make sure DateCreated and DateModified have values
|
||||
EnsureDates(item);
|
||||
}
|
||||
|
||||
@@ -59,6 +68,9 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Ensures DateCreated and DateModified have values
|
||||
/// </summary>
|
||||
private void EnsureDates(T item)
|
||||
{
|
||||
// If the subclass didn't supply dates, add them here
|
||||
@@ -73,6 +85,9 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Fills in image paths based on files win the folder
|
||||
/// </summary>
|
||||
protected virtual void PopulateImages(T item, ItemResolveEventArgs args)
|
||||
{
|
||||
List<string> backdropFiles = new List<string>();
|
||||
@@ -88,6 +103,7 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
|
||||
string ext = Path.GetExtension(filePath);
|
||||
|
||||
// Only support png and jpg files
|
||||
if (!ext.EndsWith("png", StringComparison.OrdinalIgnoreCase) && !ext.EndsWith("jpg", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
continue;
|
||||
@@ -137,6 +153,9 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Weed this to keep a list of resolvers, since Resolvers are built with generics
|
||||
/// </summary>
|
||||
public interface IBaseItemResolver
|
||||
{
|
||||
BaseItem ResolvePath(ItemResolveEventArgs args);
|
||||
|
||||
@@ -29,6 +29,7 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
|
||||
item.IsRoot = args.Parent == null;
|
||||
|
||||
// Read data from folder.xml, if it exists
|
||||
PopulateFolderMetadata(item, args);
|
||||
}
|
||||
|
||||
|
||||
@@ -1,20 +1,26 @@
|
||||
using System.IO;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Linq;
|
||||
using System.Collections.Generic;
|
||||
|
||||
namespace MediaBrowser.Controller.Resolvers
|
||||
{
|
||||
/// <summary>
|
||||
/// Resolves a Path into a Video
|
||||
/// </summary>
|
||||
public class VideoResolver : BaseVideoResolver<Video>
|
||||
{
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Resolves a Path into a Video or Video subclass
|
||||
/// </summary>
|
||||
public abstract class BaseVideoResolver<T> : BaseItemResolver<T>
|
||||
where T : Video, new()
|
||||
{
|
||||
protected override T Resolve(ItemResolveEventArgs args)
|
||||
{
|
||||
// If the path is a file check for a matching extensions
|
||||
if (!args.IsFolder)
|
||||
{
|
||||
if (IsVideoFile(args.Path))
|
||||
@@ -29,6 +35,7 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
|
||||
else
|
||||
{
|
||||
// If the path is a folder, check if it's bluray or dvd
|
||||
T item = ResolveFromFolderName(args.Path);
|
||||
|
||||
if (item != null)
|
||||
@@ -36,6 +43,7 @@ namespace MediaBrowser.Controller.Resolvers
|
||||
return item;
|
||||
}
|
||||
|
||||
// Also check the subfolders for bluray or dvd
|
||||
foreach (KeyValuePair<string, FileAttributes> folder in args.FileSystemChildren)
|
||||
{
|
||||
if (!folder.Value.HasFlag(FileAttributes.Directory))
|
||||
|
||||
Reference in New Issue
Block a user