jellyfin/MediaBrowser.Providers/BoxSets/BoxSetXmlProvider.cs

63 lines
1.7 KiB
C#
Raw Normal View History

2014-01-30 21:23:54 +00:00
using MediaBrowser.Common.IO;
using MediaBrowser.Controller.Entities.Movies;
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Logging;
using System.IO;
using System.Threading;
using System.Threading.Tasks;
namespace MediaBrowser.Providers.BoxSets
{
/// <summary>
2014-02-03 20:51:28 +00:00
/// Class BoxSetXmlProvider.
2014-01-30 21:23:54 +00:00
/// </summary>
public class BoxSetXmlProvider : BaseXmlProvider, ILocalMetadataProvider<BoxSet>
{
private readonly ILogger _logger;
public BoxSetXmlProvider(IFileSystem fileSystem, ILogger logger)
: base(fileSystem)
{
_logger = logger;
}
public async Task<MetadataResult<BoxSet>> GetMetadata(string path, CancellationToken cancellationToken)
{
2014-02-02 13:36:31 +00:00
path = GetXmlFile(path).FullName;
2014-01-30 21:23:54 +00:00
var result = new MetadataResult<BoxSet>();
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
try
{
var item = new BoxSet();
new BaseItemXmlParser<BoxSet>(_logger).Fetch(item, path, cancellationToken);
result.HasMetadata = true;
result.Item = item;
}
catch (FileNotFoundException)
{
result.HasMetadata = false;
}
finally
{
XmlParsingResourcePool.Release();
}
return result;
}
public string Name
{
2014-02-03 05:35:43 +00:00
get { return "Media Browser Xml"; }
2014-01-30 21:23:54 +00:00
}
2014-02-02 13:36:31 +00:00
protected override FileInfo GetXmlFile(string path)
2014-01-30 21:23:54 +00:00
{
2014-02-02 13:36:31 +00:00
return new FileInfo(Path.Combine(path, "collection.xml"));
2014-01-30 21:23:54 +00:00
}
}
}