Added some resolver improvements

This commit is contained in:
LukePulverenti Luke Pulverenti luke pulverenti 2012-07-12 13:09:35 -04:00
parent b50f78e5da
commit 4c9f77eead
9 changed files with 51 additions and 54 deletions

View File

@ -26,7 +26,6 @@ namespace MediaBrowser.Controller
public string DataPath { get; private set; }
public HttpServer HttpServer { get; private set; }
public ItemDataCache ItemDataCache { get; private set; }
public ItemController ItemController { get; private set; }
public UserController UserController { get; private set; }
public PluginController PluginController { get; private set; }
@ -61,7 +60,6 @@ namespace MediaBrowser.Controller
UserController = new UserController(Path.Combine(DataPath, "Users"));
PluginController = new PluginController(Path.Combine(DataPath, "Plugins"));
DirectoryWatchers = new DirectoryWatchers();
ItemDataCache = new ItemDataCache();
ItemController.PreBeginResolvePath += ItemController_PreBeginResolvePath;
ItemController.BeginResolvePath += ItemController_BeginResolvePath;
@ -86,7 +84,6 @@ namespace MediaBrowser.Controller
// Get users from users folder
// Load root media folder
Parallel.Invoke(ReloadUsers, ReloadRoot);
var b = true;
}
private void ReloadConfiguration()

View File

@ -1,32 +0,0 @@
using System.Collections.Generic;
using MediaBrowser.Model.Entities;
namespace MediaBrowser.Controller.Library
{
public class ItemDataCache
{
private Dictionary<string, object> Data = new Dictionary<string, object>();
public void SetValue<T>(BaseItem item, string propertyName, T value)
{
Data[GetKey(item, propertyName)] = value;
}
public T GetValue<T>(BaseItem item, string propertyName)
{
string key = GetKey(item, propertyName);
if (Data.ContainsKey(key))
{
return (T)Data[key];
}
return default(T);
}
private string GetKey(BaseItem item, string propertyName)
{
return item.Id.ToString() + "-" + propertyName;
}
}
}

View File

@ -51,7 +51,6 @@
<Compile Include="IO\Shortcut.cs" />
<Compile Include="Library\ItemController.cs" />
<Compile Include="Kernel.cs" />
<Compile Include="Library\ItemDataCache.cs" />
<Compile Include="Net\CollectionExtensions.cs" />
<Compile Include="Net\HttpServer.cs" />
<Compile Include="Net\Request.cs" />

View File

@ -146,16 +146,16 @@ namespace MediaBrowser.Controller.Xml
case "Director":
{
var list = (item.People ?? new Person[]{}).ToList();
list.AddRange(GetSplitValues(node.InnerText, '|').Select(v => new Person() { Name = v, PersonType = PersonType.Director }));
var list = (item.People ?? new PersonInfo[]{}).ToList();
list.AddRange(GetSplitValues(node.InnerText, '|').Select(v => new PersonInfo() { Name = v, PersonType = PersonType.Director }));
item.People = list;
break;
}
case "Writer":
{
var list = (item.People ?? new Person[] { }).ToList();
list.AddRange(GetSplitValues(node.InnerText, '|').Select(v => new Person() { Name = v, PersonType = PersonType.Writer }));
var list = (item.People ?? new PersonInfo[] { }).ToList();
list.AddRange(GetSplitValues(node.InnerText, '|').Select(v => new PersonInfo() { Name = v, PersonType = PersonType.Writer }));
item.People = list;
break;
@ -164,8 +164,8 @@ namespace MediaBrowser.Controller.Xml
case "Actors":
case "GuestStars":
{
var list = (item.People ?? new Person[] { }).ToList();
list.AddRange(GetSplitValues(node.InnerText, '|').Select(v => new Person() { Name = v, PersonType = PersonType.Actor }));
var list = (item.People ?? new PersonInfo[] { }).ToList();
list.AddRange(GetSplitValues(node.InnerText, '|').Select(v => new PersonInfo() { Name = v, PersonType = PersonType.Actor }));
item.People = list;
break;
@ -450,7 +450,7 @@ namespace MediaBrowser.Controller.Xml
protected virtual void FetchDataFromPersonsNode(XmlNode node, T item)
{
List<Person> list = (item.People ?? new Person[] { }).ToList();
List<PersonInfo> list = (item.People ?? new PersonInfo[] { }).ToList();
foreach (XmlNode childNode in node.ChildNodes)
{
@ -542,9 +542,9 @@ namespace MediaBrowser.Controller.Xml
}
}
private Person GetPersonFromXmlNode(XmlNode node)
private PersonInfo GetPersonFromXmlNode(XmlNode node)
{
Person person = new Person();
PersonInfo person = new PersonInfo();
foreach (XmlNode childNode in node.ChildNodes)
{
@ -570,7 +570,7 @@ namespace MediaBrowser.Controller.Xml
}
case "Role":
person.Description = childNode.InnerText ?? string.Empty;
person.Overview = childNode.InnerText ?? string.Empty;
break;
default:

View File

@ -38,7 +38,8 @@ namespace MediaBrowser.Model.Entities
public string Overview { get; set; }
public string Tagline { get; set; }
public IEnumerable<Person> People { get; set; }
[JsonIgnore]
public IEnumerable<PersonInfo> People { get; set; }
public IEnumerable<string> Studios { get; set; }

View File

@ -6,10 +6,21 @@ using System.Threading.Tasks;
namespace MediaBrowser.Model.Entities
{
public class Person
/// <summary>
/// This is the full Person object that can be retrieved with all of it's data.
/// </summary>
public class Person : BaseItem
{
public PersonType PersonType { get; set; }
}
/// <summary>
/// This is the small Person stub that is attached to BaseItems
/// </summary>
public class PersonInfo
{
public string Name { get; set; }
public string Description { get; set; }
public string Overview { get; set; }
public PersonType PersonType { get; set; }
}

View File

@ -23,6 +23,8 @@ namespace MediaBrowser.Movies.Resolvers
{
return GetMovie(args);
}
// There's no metadata or [tmdb in the path, now we will have to work some magic to see if this is a Movie
}
return null;

View File

@ -14,9 +14,15 @@ namespace MediaBrowser.TV.Resolvers
{
if (args.IsFolder)
{
// Optimization to avoid running these tests against Seasons
if (args.Parent is Series)
{
return null;
}
var metadataFile = args.GetFileByName("series.xml");
if (metadataFile.HasValue || Path.GetFileName(args.Path).IndexOf("[tvdbid=", StringComparison.OrdinalIgnoreCase) != -1)
if (metadataFile.HasValue || Path.GetFileName(args.Path).IndexOf("[tvdbid=", StringComparison.OrdinalIgnoreCase) != -1 || TVUtils.IsSeriesFolder(args.Path, args.FileSystemChildren))
{
return new Series();
}

View File

@ -52,14 +52,27 @@ namespace MediaBrowser.TV
return seasonPathExpressions.Any(r => r.IsMatch(path));
}
public static bool IsSeriesFolder(string path, IEnumerable<string> files, IEnumerable<string> folders)
public static bool IsSeriesFolder(string path, IEnumerable<KeyValuePair<string, FileAttributes>> fileSystemChildren)
{
if (folders.Any(f => IsSeasonFolder(f)))
foreach (var child in fileSystemChildren)
{
return true;
if (child.Value.HasFlag(FileAttributes.Directory))
{
if (IsSeasonFolder(child.Key))
{
return true;
}
}
else
{
if (!string.IsNullOrEmpty(EpisodeNumberFromFile(child.Key, false)))
{
return true;
}
}
}
return files.Any(f => !string.IsNullOrEmpty(EpisodeNumberFromFile(f, false)));
return false;
}
public static bool IsEpisode(string fullPath)