You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
68 lines
2.2 KiB
68 lines
2.2 KiB
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Providers;
|
|
using MediaBrowser.Model.Entities;
|
|
using MediaBrowser.Model.Logging;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
using MediaBrowser.Model.IO;
|
|
using MediaBrowser.Model.Xml;
|
|
|
|
namespace MediaBrowser.LocalMetadata.Parsers
|
|
{
|
|
public class GameSystemXmlParser : BaseItemXmlParser<GameSystem>
|
|
{
|
|
private readonly Task _cachedTask = Task.FromResult(true);
|
|
public Task FetchAsync(MetadataResult<GameSystem> item, string metadataFile, CancellationToken cancellationToken)
|
|
{
|
|
Fetch(item, metadataFile, cancellationToken);
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
return _cachedTask;
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches the data from XML node.
|
|
/// </summary>
|
|
/// <param name="reader">The reader.</param>
|
|
/// <param name="result">The result.</param>
|
|
protected override void FetchDataFromXmlNode(XmlReader reader, MetadataResult<GameSystem> result)
|
|
{
|
|
var item = result.Item;
|
|
|
|
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:
|
|
base.FetchDataFromXmlNode(reader, result);
|
|
break;
|
|
}
|
|
}
|
|
|
|
public GameSystemXmlParser(ILogger logger, IProviderManager providerManager, IXmlReaderSettingsFactory xmlReaderSettingsFactory, IFileSystem fileSystem) : base(logger, providerManager, xmlReaderSettingsFactory, fileSystem)
|
|
{
|
|
}
|
|
}
|
|
}
|