Merge branch 'master' of https://github.com/MediaBrowser/MediaBrowser
This commit is contained in:
commit
c37825aa12
|
@ -54,7 +54,6 @@ namespace MediaBrowser.Controller.Providers
|
||||||
CheckCharacters = false,
|
CheckCharacters = false,
|
||||||
IgnoreProcessingInstructions = true,
|
IgnoreProcessingInstructions = true,
|
||||||
IgnoreComments = true,
|
IgnoreComments = true,
|
||||||
IgnoreWhitespace = true,
|
|
||||||
ValidationType = ValidationType.None
|
ValidationType = ValidationType.None
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -31,6 +31,12 @@ namespace MediaBrowser.Controller.Providers
|
||||||
/// </summary>
|
/// </summary>
|
||||||
protected readonly Guid Id;
|
protected readonly Guid Id;
|
||||||
|
|
||||||
|
/// <summary>
|
||||||
|
/// The true task result
|
||||||
|
/// </summary>
|
||||||
|
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
||||||
|
protected static readonly Task<bool> FalseTaskResult = Task.FromResult(false);
|
||||||
|
|
||||||
protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(5, 5);
|
protected static readonly SemaphoreSlim XmlParsingResourcePool = new SemaphoreSlim(5, 5);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
@ -207,7 +213,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
if (RefreshOnVersionChange && !string.Equals(ProviderVersion, providerInfo.ProviderVersion))
|
if (RefreshOnVersionChange && !String.Equals(ProviderVersion, providerInfo.ProviderVersion))
|
||||||
{
|
{
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
@ -223,7 +229,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
/// <returns><c>true</c> if [has file system stamp changed] [the specified item]; otherwise, <c>false</c>.</returns>
|
/// <returns><c>true</c> if [has file system stamp changed] [the specified item]; otherwise, <c>false</c>.</returns>
|
||||||
protected bool HasFileSystemStampChanged(BaseItem item, BaseProviderInfo providerInfo)
|
protected bool HasFileSystemStampChanged(BaseItem item, BaseProviderInfo providerInfo)
|
||||||
{
|
{
|
||||||
return !string.Equals(GetCurrentFileSystemStamp(item), providerInfo.FileSystemStamp);
|
return !String.Equals(GetCurrentFileSystemStamp(item), providerInfo.FileSystemStamp);
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -52,11 +52,6 @@ namespace MediaBrowser.Controller.Providers
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
|
||||||
/// The true task result
|
|
||||||
/// </summary>
|
|
||||||
protected static readonly Task<bool> TrueTaskResult = Task.FromResult(true);
|
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
/// Fetches metadata and returns true or false indicating if any work that requires persistence was done
|
||||||
/// </summary>
|
/// </summary>
|
||||||
|
|
|
@ -81,26 +81,22 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
// Since we don't have anything truly async, and since deserializing can be expensive, create a task to force parallelism
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
return Task.Run(() =>
|
|
||||||
|
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME));
|
||||||
|
if (entry.HasValue)
|
||||||
{
|
{
|
||||||
|
// read in our saved meta and pass to processing function
|
||||||
|
var movieData = JsonSerializer.DeserializeFromFile<CompleteMovieData>(entry.Value.Path);
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LOCAL_META_FILE_NAME));
|
|
||||||
if (entry.HasValue)
|
|
||||||
{
|
|
||||||
// read in our saved meta and pass to processing function
|
|
||||||
var movieData = JsonSerializer.DeserializeFromFile<CompleteMovieData>(entry.Value.Path);
|
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
ProcessMainInfo(item, movieData);
|
||||||
|
|
||||||
ProcessMainInfo(item, movieData);
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
|
return TrueTaskResult;
|
||||||
SetLastRefreshed(item, DateTime.UtcNow);
|
}
|
||||||
return true;
|
return FalseTaskResult;
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -92,28 +92,24 @@ namespace MediaBrowser.Controller.Providers.Movies
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() =>
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
try
|
||||||
{
|
{
|
||||||
|
var personInfo = JsonSerializer.DeserializeFromFile<PersonResult>(Path.Combine(item.MetaLocation, MetaFileName));
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
try
|
ProcessInfo((Person)item, personInfo);
|
||||||
{
|
|
||||||
var personInfo = JsonSerializer.DeserializeFromFile<PersonResult>(Path.Combine(item.MetaLocation, MetaFileName));
|
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
|
return TrueTaskResult;
|
||||||
ProcessInfo((Person)item, personInfo);
|
}
|
||||||
|
catch (FileNotFoundException)
|
||||||
SetLastRefreshed(item, DateTime.UtcNow);
|
{
|
||||||
return true;
|
// This is okay - just means we force refreshed and there isn't a json file
|
||||||
}
|
return FalseTaskResult;
|
||||||
catch (FileNotFoundException)
|
}
|
||||||
{
|
|
||||||
// This is okay - just means we force refreshed and there isn't a json file
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -32,27 +32,24 @@ namespace MediaBrowser.Controller.Providers.Music
|
||||||
|
|
||||||
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
public override Task<bool> FetchAsync(BaseItem item, bool force, CancellationToken cancellationToken)
|
||||||
{
|
{
|
||||||
return Task.Run(() =>
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
|
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName));
|
||||||
|
if (entry.HasValue)
|
||||||
{
|
{
|
||||||
|
// read in our saved meta and pass to processing function
|
||||||
|
var data = JsonSerializer.DeserializeFromFile<LastfmArtist>(entry.Value.Path);
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
cancellationToken.ThrowIfCancellationRequested();
|
||||||
|
|
||||||
var entry = item.ResolveArgs.GetMetaFileByPath(Path.Combine(item.MetaLocation, LastfmHelper.LocalArtistMetaFileName));
|
LastfmHelper.ProcessArtistData(item, data);
|
||||||
if (entry.HasValue)
|
|
||||||
{
|
|
||||||
// read in our saved meta and pass to processing function
|
|
||||||
var data = JsonSerializer.DeserializeFromFile<LastfmArtist>(entry.Value.Path);
|
|
||||||
|
|
||||||
cancellationToken.ThrowIfCancellationRequested();
|
item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid);
|
||||||
|
|
||||||
LastfmHelper.ProcessArtistData(item, data);
|
SetLastRefreshed(item, DateTime.UtcNow);
|
||||||
|
return TrueTaskResult;
|
||||||
item.SetProviderId(MetadataProviders.Musicbrainz, data.mbid);
|
}
|
||||||
|
return FalseTaskResult;
|
||||||
SetLastRefreshed(item, DateTime.UtcNow);
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
return false;
|
|
||||||
});
|
|
||||||
}
|
}
|
||||||
|
|
||||||
public override MetadataProviderPriority Priority
|
public override MetadataProviderPriority Priority
|
||||||
|
|
|
@ -574,7 +574,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// The images by name item cache
|
/// The images by name item cache
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private readonly ConcurrentDictionary<string, object> _imagesByNameItemCache = new ConcurrentDictionary<string, object>(StringComparer.OrdinalIgnoreCase);
|
private readonly ConcurrentDictionary<string, BaseItem> _imagesByNameItemCache = new ConcurrentDictionary<string, BaseItem>(StringComparer.OrdinalIgnoreCase);
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Generically retrieves an IBN item
|
/// Generically retrieves an IBN item
|
||||||
|
@ -588,7 +588,7 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
/// <returns>Task{``0}.</returns>
|
/// <returns>Task{``0}.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">
|
/// <exception cref="System.ArgumentNullException">
|
||||||
/// </exception>
|
/// </exception>
|
||||||
private Task<T> GetImagesByNameItem<T>(string path, string name, CancellationToken cancellationToken, bool allowSlowProviders = true, bool forceCreation = false)
|
private async Task<T> GetImagesByNameItem<T>(string path, string name, CancellationToken cancellationToken, bool allowSlowProviders = true, bool forceCreation = false)
|
||||||
where T : BaseItem, new()
|
where T : BaseItem, new()
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(path))
|
if (string.IsNullOrEmpty(path))
|
||||||
|
@ -603,18 +603,16 @@ namespace MediaBrowser.Server.Implementations.Library
|
||||||
|
|
||||||
var key = Path.Combine(path, FileSystem.GetValidFilename(name));
|
var key = Path.Combine(path, FileSystem.GetValidFilename(name));
|
||||||
|
|
||||||
if (forceCreation)
|
BaseItem obj;
|
||||||
|
|
||||||
|
if (forceCreation || !_imagesByNameItemCache.TryGetValue(key, out obj))
|
||||||
{
|
{
|
||||||
var task = CreateImagesByNameItem<T>(path, name, cancellationToken, allowSlowProviders);
|
obj = await CreateImagesByNameItem<T>(path, name, cancellationToken, allowSlowProviders).ConfigureAwait(false);
|
||||||
|
|
||||||
_imagesByNameItemCache.AddOrUpdate(key, task, (keyName, oldValue) => task);
|
_imagesByNameItemCache.AddOrUpdate(key, obj, (keyName, oldValue) => obj);
|
||||||
|
|
||||||
return task;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
var obj = _imagesByNameItemCache.GetOrAdd(key, keyname => CreateImagesByNameItem<T>(path, name, cancellationToken, allowSlowProviders));
|
return obj as T;
|
||||||
|
|
||||||
return obj as Task<T>;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/// <summary>
|
/// <summary>
|
||||||
|
|
|
@ -3,6 +3,7 @@ using MediaBrowser.Common.MediaInfo;
|
||||||
using MediaBrowser.Common.ScheduledTasks;
|
using MediaBrowser.Common.ScheduledTasks;
|
||||||
using MediaBrowser.Controller;
|
using MediaBrowser.Controller;
|
||||||
using MediaBrowser.Controller.Entities;
|
using MediaBrowser.Controller.Entities;
|
||||||
|
using MediaBrowser.Controller.Entities.Movies;
|
||||||
using MediaBrowser.Controller.Library;
|
using MediaBrowser.Controller.Library;
|
||||||
using MediaBrowser.Controller.Providers.MediaInfo;
|
using MediaBrowser.Controller.Providers.MediaInfo;
|
||||||
using MediaBrowser.Model.Entities;
|
using MediaBrowser.Model.Entities;
|
||||||
|
@ -95,33 +96,40 @@ namespace MediaBrowser.Server.Implementations.ScheduledTasks
|
||||||
/// <returns>Task.</returns>
|
/// <returns>Task.</returns>
|
||||||
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
public async Task Execute(CancellationToken cancellationToken, IProgress<double> progress)
|
||||||
{
|
{
|
||||||
var items = _libraryManager.RootFolder.RecursiveChildren
|
var allItems = _libraryManager.RootFolder.RecursiveChildren.ToList();
|
||||||
.OfType<Video>()
|
|
||||||
.Where(i =>
|
|
||||||
{
|
|
||||||
if (!string.IsNullOrEmpty(i.PrimaryImagePath))
|
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.LocationType != LocationType.FileSystem)
|
var localTrailers = allItems.SelectMany(i => i.LocalTrailers);
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.VideoType == VideoType.HdDvd)
|
var videos = allItems.OfType<Video>().ToList();
|
||||||
{
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (i.VideoType == VideoType.Iso && !i.IsoType.HasValue)
|
var items = videos;
|
||||||
{
|
items.AddRange(localTrailers);
|
||||||
return false;
|
items.AddRange(videos.OfType<Movie>().SelectMany(i => i.SpecialFeatures).ToList());
|
||||||
}
|
|
||||||
|
|
||||||
return i.MediaStreams != null && i.MediaStreams.Any(m => m.Type == MediaStreamType.Video);
|
items = items.Where(i =>
|
||||||
})
|
{
|
||||||
.ToList();
|
if (!string.IsNullOrEmpty(i.PrimaryImagePath))
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.LocationType != LocationType.FileSystem)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.VideoType == VideoType.HdDvd)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
if (i.VideoType == VideoType.Iso && !i.IsoType.HasValue)
|
||||||
|
{
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
return i.MediaStreams != null && i.MediaStreams.Any(m => m.Type == MediaStreamType.Video);
|
||||||
|
}).ToList();
|
||||||
|
|
||||||
progress.Report(0);
|
progress.Report(0);
|
||||||
|
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||||
{
|
{
|
||||||
var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db");
|
var dbFile = Path.Combine(_appPaths.DataPath, "displaypreferences.db");
|
||||||
|
|
||||||
await ConnectToDB(dbFile).ConfigureAwait(false);
|
await ConnectToDb(dbFile).ConfigureAwait(false);
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
|
|
|
@ -82,7 +82,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||||
{
|
{
|
||||||
var dbFile = Path.Combine(_appPaths.DataPath, "library.db");
|
var dbFile = Path.Combine(_appPaths.DataPath, "library.db");
|
||||||
|
|
||||||
await ConnectToDB(dbFile).ConfigureAwait(false);
|
await ConnectToDb(dbFile).ConfigureAwait(false);
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||||
/// <param name="dbPath">The db path.</param>
|
/// <param name="dbPath">The db path.</param>
|
||||||
/// <returns>Task{System.Boolean}.</returns>
|
/// <returns>Task{System.Boolean}.</returns>
|
||||||
/// <exception cref="System.ArgumentNullException">dbPath</exception>
|
/// <exception cref="System.ArgumentNullException">dbPath</exception>
|
||||||
protected async Task ConnectToDB(string dbPath)
|
protected async Task ConnectToDb(string dbPath)
|
||||||
{
|
{
|
||||||
if (string.IsNullOrEmpty(dbPath))
|
if (string.IsNullOrEmpty(dbPath))
|
||||||
{
|
{
|
||||||
|
|
|
@ -86,7 +86,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||||
{
|
{
|
||||||
var dbFile = Path.Combine(_appPaths.DataPath, "userdata.db");
|
var dbFile = Path.Combine(_appPaths.DataPath, "userdata.db");
|
||||||
|
|
||||||
await ConnectToDB(dbFile).ConfigureAwait(false);
|
await ConnectToDb(dbFile).ConfigureAwait(false);
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
|
|
|
@ -88,7 +88,7 @@ namespace MediaBrowser.Server.Implementations.Sqlite
|
||||||
{
|
{
|
||||||
var dbFile = Path.Combine(_appPaths.DataPath, "users.db");
|
var dbFile = Path.Combine(_appPaths.DataPath, "users.db");
|
||||||
|
|
||||||
await ConnectToDB(dbFile).ConfigureAwait(false);
|
await ConnectToDb(dbFile).ConfigureAwait(false);
|
||||||
|
|
||||||
string[] queries = {
|
string[] queries = {
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue
Block a user