Initial metadata provider hook in. No refresh intelligence yet.
This commit is contained in:
parent
7186d66109
commit
946c0e8256
|
@ -1,4 +1,8 @@
|
||||||
using System;
|
using System;
|
||||||
|
using System.Collections.Generic;
|
||||||
|
using System.Linq;
|
||||||
|
using MediaBrowser.Controller.Library;
|
||||||
|
using MediaBrowser.Controller.IO;
|
||||||
|
|
||||||
namespace MediaBrowser.Controller.Entities
|
namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
|
@ -11,6 +15,10 @@ namespace MediaBrowser.Controller.Entities
|
||||||
|
|
||||||
public Guid Id { get; set; }
|
public Guid Id { get; set; }
|
||||||
|
|
||||||
|
public string Path { get; set; }
|
||||||
|
|
||||||
|
public Folder Parent { get; set; }
|
||||||
|
|
||||||
public string PrimaryImagePath { get; set; }
|
public string PrimaryImagePath { get; set; }
|
||||||
|
|
||||||
public DateTime DateCreated { get; set; }
|
public DateTime DateCreated { get; set; }
|
||||||
|
@ -21,5 +29,45 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
return Name;
|
return Name;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
protected ItemResolveEventArgs _resolveArgs;
|
||||||
|
/// <summary>
|
||||||
|
/// We attach these to the item so that we only ever have to hit the file system once
|
||||||
|
/// (this includes the children of the containing folder)
|
||||||
|
/// Use ResolveArgs.FileSystemChildren to check for the existence of files instead of File.Exists
|
||||||
|
/// </summary>
|
||||||
|
public ItemResolveEventArgs ResolveArgs
|
||||||
|
{
|
||||||
|
get
|
||||||
|
{
|
||||||
|
if (_resolveArgs == null)
|
||||||
|
{
|
||||||
|
_resolveArgs = new ItemResolveEventArgs()
|
||||||
|
{
|
||||||
|
FileInfo = FileData.GetFileData(this.Path),
|
||||||
|
Parent = this.Parent,
|
||||||
|
Cancel = false,
|
||||||
|
Path = this.Path
|
||||||
|
};
|
||||||
|
_resolveArgs = FileSystemHelper.FilterChildFileSystemEntries(_resolveArgs, (this.Parent != null && this.Parent.IsRoot));
|
||||||
|
}
|
||||||
|
return _resolveArgs;
|
||||||
|
}
|
||||||
|
set
|
||||||
|
{
|
||||||
|
_resolveArgs = value;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// Refresh metadata on us by execution our provider chain
|
||||||
|
/// </summary>
|
||||||
|
/// <returns>true if a provider reports we changed</returns>
|
||||||
|
public bool RefreshMetadata()
|
||||||
|
{
|
||||||
|
Kernel.Instance.ExecuteMetadataProviders(this).ConfigureAwait(false);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,35 +9,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
{
|
{
|
||||||
public abstract class BaseItem : BaseEntity, IHasProviderIds
|
public abstract class BaseItem : BaseEntity, IHasProviderIds
|
||||||
{
|
{
|
||||||
protected ItemResolveEventArgs _resolveArgs;
|
|
||||||
/// <summary>
|
|
||||||
/// We attach these to the item so that we only ever have to hit the file system once
|
|
||||||
/// (this includes the children of the containing folder)
|
|
||||||
/// Use ResolveArgs.FileSystemChildren to check for the existence of files instead of File.Exists
|
|
||||||
/// </summary>
|
|
||||||
public ItemResolveEventArgs ResolveArgs
|
|
||||||
{
|
|
||||||
get
|
|
||||||
{
|
|
||||||
if (_resolveArgs == null)
|
|
||||||
{
|
|
||||||
_resolveArgs = new ItemResolveEventArgs()
|
|
||||||
{
|
|
||||||
FileInfo = FileData.GetFileData(this.Path),
|
|
||||||
Parent = this.Parent,
|
|
||||||
Cancel = false,
|
|
||||||
Path = this.Path
|
|
||||||
};
|
|
||||||
_resolveArgs = FileSystemHelper.FilterChildFileSystemEntries(_resolveArgs, (this.Parent != null && this.Parent.IsRoot));
|
|
||||||
}
|
|
||||||
return _resolveArgs;
|
|
||||||
}
|
|
||||||
set
|
|
||||||
{
|
|
||||||
_resolveArgs = value;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
public string SortName { get; set; }
|
public string SortName { get; set; }
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -45,10 +16,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public DateTime? PremiereDate { get; set; }
|
public DateTime? PremiereDate { get; set; }
|
||||||
|
|
||||||
public string Path { get; set; }
|
|
||||||
|
|
||||||
public Folder Parent { get; set; }
|
|
||||||
|
|
||||||
public string LogoImagePath { get; set; }
|
public string LogoImagePath { get; set; }
|
||||||
|
|
||||||
public string ArtImagePath { get; set; }
|
public string ArtImagePath { get; set; }
|
||||||
|
@ -177,15 +144,6 @@ namespace MediaBrowser.Controller.Entities
|
||||||
return changed;
|
return changed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// Refresh metadata on us by execution our provider chain
|
|
||||||
/// </summary>
|
|
||||||
/// <returns>true if a provider reports we changed</returns>
|
|
||||||
public bool RefreshMetadata()
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Determines if the item is considered new based on user settings
|
/// Determines if the item is considered new based on user settings
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -118,9 +118,6 @@ namespace MediaBrowser.Controller
|
||||||
//watch the root folder children for changes
|
//watch the root folder children for changes
|
||||||
RootFolder.ChildrenChanged += RootFolder_ChildrenChanged;
|
RootFolder.ChildrenChanged += RootFolder_ChildrenChanged;
|
||||||
|
|
||||||
System.Threading.Thread.Sleep(25000);
|
|
||||||
var allChildren = RootFolder.RecursiveChildren;
|
|
||||||
Logger.LogInfo(string.Format("Loading complete. Movies: {0} Episodes: {1}", allChildren.OfType<Entities.Movies.Movie>().Count(), allChildren.OfType<Entities.TV.Episode>().Count()));
|
|
||||||
}
|
}
|
||||||
|
|
||||||
protected override void OnComposablePartsLoaded()
|
protected override void OnComposablePartsLoaded()
|
||||||
|
@ -180,6 +177,8 @@ namespace MediaBrowser.Controller
|
||||||
//re-start the directory watchers
|
//re-start the directory watchers
|
||||||
DirectoryWatchers.Stop();
|
DirectoryWatchers.Stop();
|
||||||
DirectoryWatchers.Start();
|
DirectoryWatchers.Start();
|
||||||
|
var allChildren = RootFolder.RecursiveChildren;
|
||||||
|
Logger.LogInfo(string.Format("Loading complete. Movies: {0} Episodes: {1}", allChildren.OfType<Entities.Movies.Movie>().Count(), allChildren.OfType<Entities.TV.Episode>().Count()));
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -328,7 +327,7 @@ namespace MediaBrowser.Controller
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Runs all metadata providers for an entity
|
/// Runs all metadata providers for an entity
|
||||||
/// </summary>
|
/// </summary>
|
||||||
internal async Task ExecuteMetadataProviders(BaseEntity item, ItemResolveEventArgs args, bool allowInternetProviders = true)
|
internal async Task ExecuteMetadataProviders(BaseEntity item, bool allowInternetProviders = true)
|
||||||
{
|
{
|
||||||
// Run them sequentially in order of priority
|
// Run them sequentially in order of priority
|
||||||
for (int i = 0; i < MetadataProviders.Length; i++)
|
for (int i = 0; i < MetadataProviders.Length; i++)
|
||||||
|
@ -349,7 +348,7 @@ namespace MediaBrowser.Controller
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await provider.FetchAsync(item, args).ConfigureAwait(false);
|
await provider.FetchAsync(item, item.ResolveArgs).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
|
|
@ -217,7 +217,7 @@ namespace MediaBrowser.Controller.Library
|
||||||
args.FileInfo = FileData.GetFileData(path);
|
args.FileInfo = FileData.GetFileData(path);
|
||||||
args.FileSystemChildren = FileData.GetFileSystemEntries(path, "*").ToArray();
|
args.FileSystemChildren = FileData.GetFileSystemEntries(path, "*").ToArray();
|
||||||
|
|
||||||
await Kernel.Instance.ExecuteMetadataProviders(item, args).ConfigureAwait(false);
|
await Kernel.Instance.ExecuteMetadataProviders(item).ConfigureAwait(false);
|
||||||
|
|
||||||
return item;
|
return item;
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user