Move NeedsRefresh to async task and fix problem finding episode metadata
This commit is contained in:
parent
e5b5861abf
commit
0f078d8098
|
@ -36,5 +36,26 @@ namespace MediaBrowser.Common.Extensions
|
|||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
/// Helper method for Dictionaries since they throw on not-found keys
|
||||
/// </summary>
|
||||
/// <typeparam name="T"></typeparam>
|
||||
/// <typeparam name="U"></typeparam>
|
||||
/// <param name="dictionary"></param>
|
||||
/// <param name="key"></param>
|
||||
/// <param name="defaultValue"></param>
|
||||
/// <returns></returns>
|
||||
public static U GetValueOrDefault<T, U>(this Dictionary<T, U> dictionary, T key, U defaultValue)
|
||||
{
|
||||
U val;
|
||||
if (!dictionary.TryGetValue(key, out val))
|
||||
{
|
||||
val = defaultValue;
|
||||
}
|
||||
return val;
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
@ -153,9 +153,9 @@ namespace MediaBrowser.Controller.Entities
|
|||
//brand new item - needs to be added
|
||||
changed = true;
|
||||
changedArgs.ItemsAdded.Add(child);
|
||||
//Logger.LogInfo("New Item Added to Library: ("+child.GetType().Name+")"+ child.Name + "(" + child.Path + ")");
|
||||
//refresh it
|
||||
child.RefreshMetadata();
|
||||
//Logger.LogInfo("New Item Added to Library: ("+child.GetType().Name+") "+ child.Name + " (" + child.Path + ")");
|
||||
//save it in repo...
|
||||
|
||||
//and add it to our valid children
|
||||
|
@ -180,6 +180,7 @@ namespace MediaBrowser.Controller.Entities
|
|||
// will identify this item as the same one
|
||||
currentChild.ResolveArgs = child.ResolveArgs;
|
||||
currentChild.RefreshMetadata();
|
||||
Logger.LogInfo("Item Changed: ("+currentChild.GetType().Name+") "+ currentChild.Name + " (" + currentChild.Path + ")");
|
||||
//save it in repo...
|
||||
validChildren.Add(currentChild);
|
||||
}
|
||||
|
|
|
@ -198,8 +198,13 @@ namespace MediaBrowser.Controller
|
|||
//re-start the directory watchers
|
||||
DirectoryWatchers.Stop();
|
||||
DirectoryWatchers.Start();
|
||||
//Task.Delay(30000); //let's wait and see if more data gets filled in...
|
||||
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()));
|
||||
foreach (var child in allChildren)
|
||||
{
|
||||
Logger.LogDebugInfo("(" + child.GetType().Name + ") " + child.Name + " Overview " + (child.Overview != null ? child.Overview.Substring(0,Math.Min(25,child.Overview.Length)): "") + " (" + child.Path + ")");
|
||||
}
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -368,15 +373,9 @@ namespace MediaBrowser.Controller
|
|||
continue;
|
||||
}
|
||||
|
||||
// Skip if provider says we don't need to run
|
||||
if (!provider.NeedsRefresh(item))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
|
||||
try
|
||||
{
|
||||
await provider.FetchAsync(item, item.ResolveArgs).ConfigureAwait(false);
|
||||
await provider.FetchIfNeededAsync(item).ConfigureAwait(false);
|
||||
}
|
||||
catch (Exception ex)
|
||||
{
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
using MediaBrowser.Controller.Entities;
|
||||
using MediaBrowser.Controller.Xml;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.Common.Logging;
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Linq;
|
||||
|
|
|
@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// <returns></returns>
|
||||
protected virtual DateTime LastRefreshed(BaseEntity item)
|
||||
{
|
||||
return (item.ProviderData[this.Id] ?? new BaseProviderInfo()).LastRefreshed;
|
||||
return (item.ProviderData.GetValueOrDefault(this.Id, new BaseProviderInfo())).LastRefreshed;
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// <param name="value"></param>
|
||||
protected virtual void SetLastRefreshed(BaseEntity item, DateTime value)
|
||||
{
|
||||
var data = item.ProviderData[this.Id] ?? new BaseProviderInfo();
|
||||
var data = item.ProviderData.GetValueOrDefault(this.Id, new BaseProviderInfo());
|
||||
data.LastRefreshed = value;
|
||||
item.ProviderData[this.Id] = data;
|
||||
}
|
||||
|
@ -68,7 +68,15 @@ namespace MediaBrowser.Controller.Providers
|
|||
/// </summary>
|
||||
protected virtual DateTime CompareDate(BaseEntity item)
|
||||
{
|
||||
return DateTime.MinValue;
|
||||
return DateTime.MinValue.AddMinutes(1); // want this to be greater than mindate so new items will refresh
|
||||
}
|
||||
|
||||
public virtual Task FetchIfNeededAsync(BaseEntity item)
|
||||
{
|
||||
if (this.NeedsRefresh(item))
|
||||
return FetchAsync(item, item.ResolveArgs);
|
||||
else
|
||||
return new Task(() => { });
|
||||
}
|
||||
|
||||
public abstract Task FetchAsync(BaseEntity item, ItemResolveEventArgs args);
|
||||
|
|
|
@ -18,7 +18,6 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
public static List<string> IgnoreFolders = new List<string>()
|
||||
{
|
||||
"trailers",
|
||||
"metadata",
|
||||
"bdmv",
|
||||
"certificate",
|
||||
"backup",
|
||||
|
@ -61,6 +60,11 @@ namespace MediaBrowser.Controller.Resolvers
|
|||
// Ignore any folders containing a file called .ignore
|
||||
resolve = false;
|
||||
}
|
||||
else if (args.FileInfo.cFileName.Equals("metadata", StringComparison.OrdinalIgnoreCase))
|
||||
{
|
||||
// Ignore metadata folders
|
||||
resolve = false;
|
||||
}
|
||||
|
||||
return resolve;
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user