comments and don't run internet providers on startup
This commit is contained in:
parent
c80c8c1cfd
commit
ef03988442
|
@ -1,12 +1,11 @@
|
||||||
using System;
|
using System.IO;
|
||||||
using System.Collections.Generic;
|
|
||||||
using System.Linq;
|
|
||||||
using System.Text;
|
|
||||||
using System.Threading.Tasks;
|
|
||||||
using System.IO;
|
|
||||||
|
|
||||||
namespace MediaBrowser.Common.Serialization
|
namespace MediaBrowser.Common.Serialization
|
||||||
{
|
{
|
||||||
|
/// <summary>
|
||||||
|
/// Protocol buffers is google's binary serialization format. This is a .NET implementation of it.
|
||||||
|
/// You have to tag your classes with some annoying attributes, but in return you get the fastest serialization around with the smallest possible output.
|
||||||
|
/// </summary>
|
||||||
public static class ProtobufSerializer
|
public static class ProtobufSerializer
|
||||||
{
|
{
|
||||||
public static void SerializeToStream<T>(T obj, Stream stream)
|
public static void SerializeToStream<T>(T obj, Stream stream)
|
||||||
|
|
|
@ -76,7 +76,7 @@ namespace MediaBrowser.Controller
|
||||||
ReloadUsers();
|
ReloadUsers();
|
||||||
|
|
||||||
progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 25 });
|
progress.Report(new TaskProgress() { Description = "Loading Media Library", PercentComplete = 25 });
|
||||||
await ReloadRoot().ConfigureAwait(false);
|
await ReloadRoot(allowInternetProviders: false).ConfigureAwait(false);
|
||||||
|
|
||||||
progress.Report(new TaskProgress() { Description = "Loading Complete", PercentComplete = 100 });
|
progress.Report(new TaskProgress() { Description = "Loading Complete", PercentComplete = 100 });
|
||||||
}
|
}
|
||||||
|
@ -140,7 +140,7 @@ namespace MediaBrowser.Controller
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Reloads the root media folder
|
/// Reloads the root media folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task ReloadRoot()
|
public async Task ReloadRoot(bool allowInternetProviders = true)
|
||||||
{
|
{
|
||||||
if (!Directory.Exists(MediaRootFolderPath))
|
if (!Directory.Exists(MediaRootFolderPath))
|
||||||
{
|
{
|
||||||
|
@ -149,7 +149,7 @@ namespace MediaBrowser.Controller
|
||||||
|
|
||||||
DirectoryWatchers.Stop();
|
DirectoryWatchers.Stop();
|
||||||
|
|
||||||
RootFolder = await ItemController.GetItem(MediaRootFolderPath).ConfigureAwait(false) as Folder;
|
RootFolder = await ItemController.GetItem(MediaRootFolderPath, allowInternetProviders: allowInternetProviders).ConfigureAwait(false) as Folder;
|
||||||
|
|
||||||
DirectoryWatchers.Start();
|
DirectoryWatchers.Start();
|
||||||
}
|
}
|
||||||
|
@ -226,7 +226,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)
|
internal async Task ExecuteMetadataProviders(BaseEntity item, ItemResolveEventArgs args, bool allowInternetProviders = true)
|
||||||
{
|
{
|
||||||
// Get all supported providers
|
// Get all supported providers
|
||||||
BaseMetadataProvider[] supportedProviders = Kernel.Instance.MetadataProviders.Where(i => i.Supports(item)).ToArray();
|
BaseMetadataProvider[] supportedProviders = Kernel.Instance.MetadataProviders.Where(i => i.Supports(item)).ToArray();
|
||||||
|
@ -236,7 +236,7 @@ namespace MediaBrowser.Controller
|
||||||
{
|
{
|
||||||
var provider = supportedProviders[i];
|
var provider = supportedProviders[i];
|
||||||
|
|
||||||
if (provider.RequiresInternet && !Configuration.EnableInternetProviders)
|
if (provider.RequiresInternet && (!Configuration.EnableInternetProviders || !allowInternetProviders))
|
||||||
{
|
{
|
||||||
continue;
|
continue;
|
||||||
}
|
}
|
||||||
|
|
|
@ -67,7 +67,7 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Resolves a path into a BaseItem
|
/// Resolves a path into a BaseItem
|
||||||
/// </summary>
|
/// </summary>
|
||||||
public async Task<BaseItem> GetItem(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null)
|
public async Task<BaseItem> GetItem(string path, Folder parent = null, WIN32_FIND_DATA? fileInfo = null, bool allowInternetProviders = true)
|
||||||
{
|
{
|
||||||
ItemResolveEventArgs args = new ItemResolveEventArgs()
|
ItemResolveEventArgs args = new ItemResolveEventArgs()
|
||||||
{
|
{
|
||||||
|
@ -109,12 +109,12 @@ namespace MediaBrowser.Controller.Library
|
||||||
|
|
||||||
if (item != null)
|
if (item != null)
|
||||||
{
|
{
|
||||||
await Kernel.Instance.ExecuteMetadataProviders(item, args).ConfigureAwait(false);
|
await Kernel.Instance.ExecuteMetadataProviders(item, args, allowInternetProviders: allowInternetProviders).ConfigureAwait(false);
|
||||||
|
|
||||||
if (item.IsFolder)
|
if (item.IsFolder)
|
||||||
{
|
{
|
||||||
// If it's a folder look for child entities
|
// If it's a folder look for child entities
|
||||||
(item as Folder).Children = (await Task.WhenAll<BaseItem>(GetChildren(item as Folder, fileSystemChildren)).ConfigureAwait(false))
|
(item as Folder).Children = (await Task.WhenAll<BaseItem>(GetChildren(item as Folder, fileSystemChildren, allowInternetProviders)).ConfigureAwait(false))
|
||||||
.Where(i => i != null).OrderBy(f =>
|
.Where(i => i != null).OrderBy(f =>
|
||||||
{
|
{
|
||||||
return string.IsNullOrEmpty(f.SortName) ? f.Name : f.SortName;
|
return string.IsNullOrEmpty(f.SortName) ? f.Name : f.SortName;
|
||||||
|
@ -129,7 +129,7 @@ namespace MediaBrowser.Controller.Library
|
||||||
/// <summary>
|
/// <summary>
|
||||||
/// Finds child BaseItems for a given Folder
|
/// Finds child BaseItems for a given Folder
|
||||||
/// </summary>
|
/// </summary>
|
||||||
private Task<BaseItem>[] GetChildren(Folder folder, WIN32_FIND_DATA[] fileSystemChildren)
|
private Task<BaseItem>[] GetChildren(Folder folder, WIN32_FIND_DATA[] fileSystemChildren, bool allowInternetProviders)
|
||||||
{
|
{
|
||||||
Task<BaseItem>[] tasks = new Task<BaseItem>[fileSystemChildren.Length];
|
Task<BaseItem>[] tasks = new Task<BaseItem>[fileSystemChildren.Length];
|
||||||
|
|
||||||
|
@ -137,7 +137,7 @@ namespace MediaBrowser.Controller.Library
|
||||||
{
|
{
|
||||||
var child = fileSystemChildren[i];
|
var child = fileSystemChildren[i];
|
||||||
|
|
||||||
tasks[i] = GetItem(child.Path, folder, child);
|
tasks[i] = GetItem(child.Path, folder, child, allowInternetProviders: allowInternetProviders);
|
||||||
}
|
}
|
||||||
|
|
||||||
return tasks;
|
return tasks;
|
||||||
|
|
|
@ -184,6 +184,7 @@ namespace MediaBrowser.Controller.Providers
|
||||||
|
|
||||||
AudioInfoProvider.EnsureCacheSubFolders(Kernel.Instance.ApplicationPaths.FFProbeVideoCacheDirectory);
|
AudioInfoProvider.EnsureCacheSubFolders(Kernel.Instance.ApplicationPaths.FFProbeVideoCacheDirectory);
|
||||||
|
|
||||||
|
// This is an optimzation. Do this now so that it doesn't have to be done upon first serialization.
|
||||||
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(FFProbeResult), true);
|
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(FFProbeResult), true);
|
||||||
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaStream), true);
|
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaStream), true);
|
||||||
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaFormat), true);
|
ProtoBuf.Meta.RuntimeTypeModel.Default.Add(typeof(MediaFormat), true);
|
||||||
|
|
|
@ -36,7 +36,7 @@ namespace MediaBrowser.TV.Providers
|
||||||
return FetchMetadata(item as Episode, args.Parent as Season, metadataFile);
|
return FetchMetadata(item as Episode, args.Parent as Season, metadataFile);
|
||||||
}
|
}
|
||||||
|
|
||||||
private Task FetchMetadata(Episode item, Season season, string metadataFile)
|
private async Task FetchMetadata(Episode item, Season season, string metadataFile)
|
||||||
{
|
{
|
||||||
if (season == null)
|
if (season == null)
|
||||||
{
|
{
|
||||||
|
@ -44,18 +44,18 @@ namespace MediaBrowser.TV.Providers
|
||||||
// Need to validate it the slow way
|
// Need to validate it the slow way
|
||||||
if (!File.Exists(metadataFile))
|
if (!File.Exists(metadataFile))
|
||||||
{
|
{
|
||||||
return Task.FromResult<object>(null);
|
await Task.FromResult<object>(null).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
if (!season.ContainsMetadataFile(metadataFile))
|
if (!season.ContainsMetadataFile(metadataFile))
|
||||||
{
|
{
|
||||||
return Task.FromResult<object>(null);
|
await Task.FromResult<object>(null).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
return Task.Run(() => { new EpisodeXmlParser().Fetch(item, metadataFile); });
|
await Task.Run(() => { new EpisodeXmlParser().Fetch(item, metadataFile); }).ConfigureAwait(false);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in New Issue
Block a user