mirror of
https://github.com/jellyfin/jellyfin.git
synced 2024-09-08 20:38:24 +02:00
60 lines
1.7 KiB
C#
60 lines
1.7 KiB
C#
using MediaBrowser.Controller.Entities;
|
|
using MediaBrowser.Controller.Persistence;
|
|
using MediaBrowser.Controller.Providers;
|
|
using MediaBrowser.Model.Logging;
|
|
using System.Threading;
|
|
using System.Threading.Tasks;
|
|
using System.Xml;
|
|
|
|
namespace MediaBrowser.Providers.Movies
|
|
{
|
|
/// <summary>
|
|
/// Class EpisodeXmlParser
|
|
/// </summary>
|
|
public class MovieXmlParser : BaseItemXmlParser<Video>
|
|
{
|
|
private readonly IItemRepository _itemRepo;
|
|
|
|
private Task _chaptersTask = null;
|
|
|
|
public MovieXmlParser(ILogger logger, IItemRepository itemRepo)
|
|
: base(logger)
|
|
{
|
|
_itemRepo = itemRepo;
|
|
}
|
|
|
|
public async Task FetchAsync(Video item, string metadataFile, CancellationToken cancellationToken)
|
|
{
|
|
_chaptersTask = null;
|
|
|
|
Fetch(item, metadataFile, cancellationToken);
|
|
|
|
cancellationToken.ThrowIfCancellationRequested();
|
|
|
|
if (_chaptersTask != null)
|
|
{
|
|
await _chaptersTask.ConfigureAwait(false);
|
|
}
|
|
}
|
|
|
|
/// <summary>
|
|
/// Fetches the data from XML node.
|
|
/// </summary>
|
|
/// <param name="reader">The reader.</param>
|
|
/// <param name="item">The item.</param>
|
|
protected override void FetchDataFromXmlNode(XmlReader reader, Video item)
|
|
{
|
|
switch (reader.Name)
|
|
{
|
|
case "Chapters":
|
|
|
|
_chaptersTask = FetchChaptersFromXmlNode(item, reader.ReadSubtree(), _itemRepo, CancellationToken.None);
|
|
break;
|
|
|
|
default:
|
|
base.FetchDataFromXmlNode(reader, item);
|
|
break;
|
|
}
|
|
}
|
|
}
|
|
}
|