mirror of
https://github.com/jellyfin/jellyfin.git
synced 2025-07-31 14:33:54 -04:00
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;
|
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
|
//brand new item - needs to be added
|
||||||
changed = true;
|
changed = true;
|
||||||
changedArgs.ItemsAdded.Add(child);
|
changedArgs.ItemsAdded.Add(child);
|
||||||
//Logger.LogInfo("New Item Added to Library: ("+child.GetType().Name+")"+ child.Name + "(" + child.Path + ")");
|
|
||||||
//refresh it
|
//refresh it
|
||||||
child.RefreshMetadata();
|
child.RefreshMetadata();
|
||||||
|
//Logger.LogInfo("New Item Added to Library: ("+child.GetType().Name+") "+ child.Name + " (" + child.Path + ")");
|
||||||
//save it in repo...
|
//save it in repo...
|
||||||
|
|
||||||
//and add it to our valid children
|
//and add it to our valid children
|
||||||
@ -180,6 +180,7 @@ namespace MediaBrowser.Controller.Entities
|
|||||||
// will identify this item as the same one
|
// will identify this item as the same one
|
||||||
currentChild.ResolveArgs = child.ResolveArgs;
|
currentChild.ResolveArgs = child.ResolveArgs;
|
||||||
currentChild.RefreshMetadata();
|
currentChild.RefreshMetadata();
|
||||||
|
Logger.LogInfo("Item Changed: ("+currentChild.GetType().Name+") "+ currentChild.Name + " (" + currentChild.Path + ")");
|
||||||
//save it in repo...
|
//save it in repo...
|
||||||
validChildren.Add(currentChild);
|
validChildren.Add(currentChild);
|
||||||
}
|
}
|
||||||
|
@ -198,8 +198,13 @@ namespace MediaBrowser.Controller
|
|||||||
//re-start the directory watchers
|
//re-start the directory watchers
|
||||||
DirectoryWatchers.Stop();
|
DirectoryWatchers.Stop();
|
||||||
DirectoryWatchers.Start();
|
DirectoryWatchers.Start();
|
||||||
|
//Task.Delay(30000); //let's wait and see if more data gets filled in...
|
||||||
var allChildren = RootFolder.RecursiveChildren;
|
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()));
|
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>
|
/// <summary>
|
||||||
@ -368,15 +373,9 @@ namespace MediaBrowser.Controller
|
|||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Skip if provider says we don't need to run
|
|
||||||
if (!provider.NeedsRefresh(item))
|
|
||||||
{
|
|
||||||
continue;
|
|
||||||
}
|
|
||||||
|
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
await provider.FetchAsync(item, item.ResolveArgs).ConfigureAwait(false);
|
await provider.FetchIfNeededAsync(item).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
catch (Exception ex)
|
catch (Exception ex)
|
||||||
{
|
{
|
||||||
|
@ -1,6 +1,7 @@
|
|||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
using MediaBrowser.Controller.Xml;
|
using MediaBrowser.Controller.Xml;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
using MediaBrowser.Common.Logging;
|
||||||
using System;
|
using System;
|
||||||
using System.Collections.Generic;
|
using System.Collections.Generic;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
|
@ -36,7 +36,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <returns></returns>
|
/// <returns></returns>
|
||||||
protected virtual DateTime LastRefreshed(BaseEntity item)
|
protected virtual DateTime LastRefreshed(BaseEntity item)
|
||||||
{
|
{
|
||||||
return (item.ProviderData[this.Id] ?? new BaseProviderInfo()).LastRefreshed;
|
return (item.ProviderData.GetValueOrDefault(this.Id, new BaseProviderInfo())).LastRefreshed;
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
@ -46,7 +46,7 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// <param name="value"></param>
|
/// <param name="value"></param>
|
||||||
protected virtual void SetLastRefreshed(BaseEntity item, DateTime value)
|
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;
|
data.LastRefreshed = value;
|
||||||
item.ProviderData[this.Id] = data;
|
item.ProviderData[this.Id] = data;
|
||||||
}
|
}
|
||||||
@ -68,7 +68,15 @@ namespace MediaBrowser.Controller.Providers
|
|||||||
/// </summary>
|
/// </summary>
|
||||||
protected virtual DateTime CompareDate(BaseEntity item)
|
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);
|
public abstract Task FetchAsync(BaseEntity item, ItemResolveEventArgs args);
|
||||||
|
@ -18,7 +18,6 @@ namespace MediaBrowser.Controller.Resolvers
|
|||||||
public static List<string> IgnoreFolders = new List<string>()
|
public static List<string> IgnoreFolders = new List<string>()
|
||||||
{
|
{
|
||||||
"trailers",
|
"trailers",
|
||||||
"metadata",
|
|
||||||
"bdmv",
|
"bdmv",
|
||||||
"certificate",
|
"certificate",
|
||||||
"backup",
|
"backup",
|
||||||
@ -61,6 +60,11 @@ namespace MediaBrowser.Controller.Resolvers
|
|||||||
// Ignore any folders containing a file called .ignore
|
// Ignore any folders containing a file called .ignore
|
||||||
resolve = false;
|
resolve = false;
|
||||||
}
|
}
|
||||||
|
else if (args.FileInfo.cFileName.Equals("metadata", StringComparison.OrdinalIgnoreCase))
|
||||||
|
{
|
||||||
|
// Ignore metadata folders
|
||||||
|
resolve = false;
|
||||||
|
}
|
||||||
|
|
||||||
return resolve;
|
return resolve;
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user