jellyfin/MediaBrowser.LocalMetadata/Parsers/GameSystemXmlParser.cs

67 lines
2.0 KiB
C#
Raw Normal View History

2015-08-02 10:31:08 -07:00
using MediaBrowser.Controller.Entities;
2014-02-02 06:36:31 -07:00
using MediaBrowser.Controller.Providers;
using MediaBrowser.Model.Entities;
using MediaBrowser.Model.Logging;
2015-08-02 10:31:08 -07:00
using System.Threading;
using System.Threading.Tasks;
using System.Xml;
2014-02-02 06:36:31 -07:00
namespace MediaBrowser.LocalMetadata.Parsers
2014-02-02 06:36:31 -07:00
{
public class GameSystemXmlParser : BaseItemXmlParser<GameSystem>
{
public GameSystemXmlParser(ILogger logger)
: base(logger)
{
}
2014-02-03 10:44:13 -07:00
private readonly Task _cachedTask = Task.FromResult(true);
2015-06-28 18:10:45 -07:00
public Task FetchAsync(MetadataResult<GameSystem> item, string metadataFile, CancellationToken cancellationToken)
2014-02-02 06:36:31 -07:00
{
Fetch(item, metadataFile, cancellationToken);
cancellationToken.ThrowIfCancellationRequested();
2014-02-03 10:44:13 -07:00
return _cachedTask;
2014-02-02 06:36:31 -07:00
}
/// <summary>
/// Fetches the data from XML node.
/// </summary>
/// <param name="reader">The reader.</param>
2015-06-28 18:10:45 -07:00
/// <param name="result">The result.</param>
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<GameSystem> result)
2014-02-02 06:36:31 -07:00
{
2015-06-28 18:10:45 -07:00
var item = result.Item;
2014-02-02 06:36:31 -07: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-28 18:10:45 -07:00
base.FetchDataFromXmlNode(reader, result);
2014-02-02 06:36:31 -07:00
break;
}
}
}
}