Update IBN types to use providers

pull/702/head
LukePulverenti Luke Pulverenti luke pulverenti 12 years ago
parent ab01b49f64
commit 1187222842

@ -295,21 +295,12 @@ namespace MediaBrowser.Controller.Library
item.DateCreated = Directory.GetCreationTime(path);
item.DateModified = Directory.GetLastAccessTime(path);
if (File.Exists(Path.Combine(path, "folder.jpg")))
{
item.PrimaryImagePath = Path.Combine(path, "folder.jpg");
}
else if (File.Exists(Path.Combine(path, "folder.png")))
{
item.PrimaryImagePath = Path.Combine(path, "folder.png");
}
ItemResolveEventArgs args = new ItemResolveEventArgs();
args.Path = path;
args.FileAttributes = File.GetAttributes(path);
args.FileSystemChildren = Directory.GetFileSystemEntries(path, "*", SearchOption.TopDirectoryOnly).Select(f => new KeyValuePair<string, FileAttributes>(f, File.GetAttributes(f)));
var b = false;
if (b)
{
await Kernel.Instance.ExecuteMetadataProviders(item, null);
}
await Kernel.Instance.ExecuteMetadataProviders(item, args);
return item;
}

@ -14,7 +14,7 @@ namespace MediaBrowser.Controller.Providers
{
public override bool Supports(BaseEntity item)
{
return item is BaseItem;
return true;
}
public override Task Fetch(BaseEntity item, ItemResolveEventArgs args)
@ -23,11 +23,51 @@ namespace MediaBrowser.Controller.Providers
{
if (args.IsFolder)
{
PopulateImages(item as BaseItem, args);
var baseItem = item as BaseItem;
if (baseItem != null)
{
PopulateImages(baseItem, args);
}
else
{
PopulateImages(item, args);
}
}
});
}
/// <summary>
/// Fills in image paths based on files win the folder
/// </summary>
private void PopulateImages(BaseEntity item, ItemResolveEventArgs args)
{
foreach (KeyValuePair<string, FileAttributes> file in args.FileSystemChildren)
{
if (file.Value.HasFlag(FileAttributes.Directory))
{
continue;
}
string filePath = file.Key;
string ext = Path.GetExtension(filePath);
// Only support png and jpg files
if (!ext.EndsWith("png", StringComparison.OrdinalIgnoreCase) && !ext.EndsWith("jpg", StringComparison.OrdinalIgnoreCase))
{
continue;
}
string name = Path.GetFileNameWithoutExtension(filePath);
if (name.Equals("folder", StringComparison.OrdinalIgnoreCase))
{
item.PrimaryImagePath = filePath;
}
}
}
/// <summary>
/// Fills in image paths based on files win the folder
/// </summary>

Loading…
Cancel
Save