Made xml fetching task-based
This commit is contained in:
parent
c658ea7feb
commit
874469d476
|
@ -14,17 +14,14 @@ namespace MediaBrowser.Controller.Providers
|
|||
return item is Folder;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
public async override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
var metadataFile = args.GetFileByName("folder.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
new FolderXmlParser().Fetch(item as Folder, metadataFile.Value.Key);
|
||||
}
|
||||
});
|
||||
await new FolderXmlParser().Fetch(item as Folder, metadataFile.Value.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -4,6 +4,7 @@ using System.IO;
|
|||
using System.Linq;
|
||||
using System.Xml;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace MediaBrowser.Controller.Xml
|
||||
{
|
||||
|
@ -16,7 +17,10 @@ namespace MediaBrowser.Controller.Xml
|
|||
/// <summary>
|
||||
/// Fetches metadata for an item from one xml file
|
||||
/// </summary>
|
||||
public virtual void Fetch(T item, string metadataFile)
|
||||
public Task Fetch(T item, string metadataFile)
|
||||
{
|
||||
// Wrapping this for now until I have a chance to async the whole process
|
||||
return Task.Run(() =>
|
||||
{
|
||||
// Use XmlReader for best performance
|
||||
using (XmlReader reader = XmlReader.Create(metadataFile))
|
||||
|
@ -43,6 +47,7 @@ namespace MediaBrowser.Controller.Xml
|
|||
{
|
||||
item.DateModified = File.GetLastWriteTime(metadataFile);
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
/// <summary>
|
||||
|
|
|
@ -16,17 +16,14 @@ namespace MediaBrowser.Movies.Providers
|
|||
return item is Movie;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
public async override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
var metadataFile = args.GetFileByName("movie.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
new BaseItemXmlParser<Movie>().Fetch(item as Movie, metadataFile.Value.Key);
|
||||
}
|
||||
});
|
||||
await new BaseItemXmlParser<Movie>().Fetch(item as Movie, metadataFile.Value.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -19,9 +19,7 @@ namespace MediaBrowser.TV.Providers
|
|||
return item is Episode;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
public async override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
string metadataFolder = Path.Combine(args.Parent.Path, "metadata");
|
||||
|
||||
|
@ -29,11 +27,10 @@ namespace MediaBrowser.TV.Providers
|
|||
|
||||
string metadataFile = Path.Combine(metadataFolder, Path.ChangeExtension(episodeFileName, ".xml"));
|
||||
|
||||
FetchMetadata(item as Episode, args.Parent as Season, metadataFile);
|
||||
});
|
||||
await FetchMetadata(item as Episode, args.Parent as Season, metadataFile);
|
||||
}
|
||||
|
||||
private void FetchMetadata(Episode item, Season season, string metadataFile)
|
||||
private async Task FetchMetadata(Episode item, Season season, string metadataFile)
|
||||
{
|
||||
if (season == null)
|
||||
{
|
||||
|
@ -52,7 +49,7 @@ namespace MediaBrowser.TV.Providers
|
|||
}
|
||||
}
|
||||
|
||||
new EpisodeXmlParser().Fetch(item, metadataFile);
|
||||
await new EpisodeXmlParser().Fetch(item, metadataFile);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,9 +2,9 @@
|
|||
using System.Threading.Tasks;
|
||||
using MediaBrowser.Controller.Events;
|
||||
using MediaBrowser.Controller.Providers;
|
||||
using MediaBrowser.Controller.Xml;
|
||||
using MediaBrowser.Model.Entities;
|
||||
using MediaBrowser.TV.Entities;
|
||||
using MediaBrowser.TV.Metadata;
|
||||
|
||||
namespace MediaBrowser.TV.Providers
|
||||
{
|
||||
|
@ -16,17 +16,14 @@ namespace MediaBrowser.TV.Providers
|
|||
return item is Series;
|
||||
}
|
||||
|
||||
public override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
return Task.Run(() =>
|
||||
public async override Task Fetch(BaseItem item, ItemResolveEventArgs args)
|
||||
{
|
||||
var metadataFile = args.GetFileByName("series.xml");
|
||||
|
||||
if (metadataFile.HasValue)
|
||||
{
|
||||
new BaseItemXmlParser<Series>().Fetch(item as Series, metadataFile.Value.Key);
|
||||
}
|
||||
});
|
||||
await new SeriesXmlParser().Fetch(item as Series, metadataFile.Value.Key);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Reference in New Issue
Block a user