2019-01-13 19:25:45 +00:00
|
|
|
|
using System.Threading;
|
2015-08-02 17:31:08 +00:00
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Xml;
|
2019-01-13 19:25:45 +00:00
|
|
|
|
using MediaBrowser.Controller.Entities;
|
|
|
|
|
using MediaBrowser.Controller.Providers;
|
|
|
|
|
using MediaBrowser.Model.Entities;
|
2016-10-30 07:02:23 +00:00
|
|
|
|
using MediaBrowser.Model.IO;
|
|
|
|
|
using MediaBrowser.Model.Xml;
|
2019-01-13 19:25:45 +00:00
|
|
|
|
using Microsoft.Extensions.Logging;
|
2014-02-02 13:36:31 +00:00
|
|
|
|
|
2014-06-30 03:04:50 +00:00
|
|
|
|
namespace MediaBrowser.LocalMetadata.Parsers
|
2014-02-02 13:36:31 +00:00
|
|
|
|
{
|
|
|
|
|
public class GameSystemXmlParser : BaseItemXmlParser<GameSystem>
|
|
|
|
|
{
|
2015-06-29 01:10:45 +00:00
|
|
|
|
public Task FetchAsync(MetadataResult<GameSystem> item, string metadataFile, CancellationToken cancellationToken)
|
2014-02-02 13:36:31 +00:00
|
|
|
|
{
|
|
|
|
|
Fetch(item, metadataFile, cancellationToken);
|
|
|
|
|
|
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
|
|
2018-09-12 17:26:21 +00:00
|
|
|
|
return Task.CompletedTask;
|
2014-02-02 13:36:31 +00:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
/// <summary>
|
|
|
|
|
/// Fetches the data from XML node.
|
|
|
|
|
/// </summary>
|
|
|
|
|
/// <param name="reader">The reader.</param>
|
2015-06-29 01:10:45 +00:00
|
|
|
|
/// <param name="result">The result.</param>
|
|
|
|
|
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<GameSystem> result)
|
2014-02-02 13:36:31 +00:00
|
|
|
|
{
|
2015-06-29 01:10:45 +00:00
|
|
|
|
var item = result.Item;
|
|
|
|
|
|
2014-02-02 13:36:31 +00:00
|
|
|
|
switch (reader.Name)
|
|
|
|
|
{
|
|
|
|
|
case "GameSystem":
|
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
item.GameSystemName = val;
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
case "GamesDbId":
|
|
|
|
|
{
|
|
|
|
|
var val = reader.ReadElementContentAsString();
|
|
|
|
|
if (!string.IsNullOrWhiteSpace(val))
|
|
|
|
|
{
|
|
|
|
|
item.SetProviderId(MetadataProviders.Gamesdb, val);
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
default:
|
2015-06-29 01:10:45 +00:00
|
|
|
|
base.FetchDataFromXmlNode(reader, result);
|
2014-02-02 13:36:31 +00:00
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
2016-10-30 07:02:23 +00:00
|
|
|
|
|
|
|
|
|
public GameSystemXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem)
|
|
|
|
|
{
|
|
|
|
|
}
|
2014-02-02 13:36:31 +00:00
|
|
|
|
}
|
|
|
|
|
}
|