2014-01-30 23:50:09 -05:00
|
|
|
|
using MediaBrowser.Common.IO;
|
|
|
|
|
using MediaBrowser.Controller.Entities.Audio;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Logging;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Threading;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
|
|
|
|
|
namespace MediaBrowser.Providers.Music
|
|
|
|
|
{
|
|
|
|
|
class ArtistXmlProvider : BaseXmlProvider, ILocalMetadataProvider<MusicArtist>
|
|
|
|
|
{
|
|
|
|
|
private readonly ILogger _logger;
|
|
|
|
|
|
|
|
|
|
public ArtistXmlProvider(IFileSystem fileSystem, ILogger logger)
|
|
|
|
|
: base(fileSystem)
|
|
|
|
|
{
|
|
|
|
|
_logger = logger;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public async Task<MetadataResult<MusicArtist>> GetMetadata(string path, CancellationToken cancellationToken)
|
|
|
|
|
{
|
2014-02-02 08:36:31 -05:00
|
|
|
|
path = GetXmlFile(path).FullName;
|
2014-01-30 23:50:09 -05:00
|
|
|
|
|
|
|
|
|
var result = new MetadataResult<MusicArtist>();
|
|
|
|
|
|
|
|
|
|
await XmlParsingResourcePool.WaitAsync(cancellationToken).ConfigureAwait(false);
|
|
|
|
|
|
|
|
|
|
try
|
|
|
|
|
{
|
|
|
|
|
var item = new MusicArtist();
|
|
|
|
|
|
|
|
|
|
new BaseItemXmlParser<MusicArtist>(_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-02 08:36:31 -05:00
|
|
|
|
get { return "Media Browser xml"; }
|
2014-01-30 23:50:09 -05:00
|
|
|
|
}
|
|
|
|
|
|
2014-02-02 08:36:31 -05:00
|
|
|
|
protected override FileInfo GetXmlFile(string path)
|
2014-01-30 23:50:09 -05:00
|
|
|
|
{
|
2014-02-02 08:36:31 -05:00
|
|
|
|
return new FileInfo(Path.Combine(path, "artist.xml"));
|
2014-01-30 23:50:09 -05:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|