From 3481d0d8e7a31ef911cb6a65aec32e7831e48df4 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Tue, 13 Aug 2013 10:43:51 -0400 Subject: [PATCH] validate chapters coming from xml --- MediaBrowser.Controller/Providers/BaseItemXmlParser.cs | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs index 89bc9f2c2..59307f4e7 100644 --- a/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs +++ b/MediaBrowser.Controller/Providers/BaseItemXmlParser.cs @@ -871,13 +871,16 @@ namespace MediaBrowser.Controller.Providers } } - protected async Task FetchChaptersFromXmlNode(Guid itemId, XmlReader reader, IItemRepository repository, CancellationToken cancellationToken) + protected async Task FetchChaptersFromXmlNode(BaseItem item, XmlReader reader, IItemRepository repository, CancellationToken cancellationToken) { + var runtime = item.RunTimeTicks ?? 0; + using (reader) { - var chapters = GetChaptersFromXmlNode(reader); + var chapters = GetChaptersFromXmlNode(reader) + .Where(i => i.StartPositionTicks >= 0 && i.StartPositionTicks < runtime); - await repository.SaveChapters(itemId, chapters, cancellationToken).ConfigureAwait(false); + await repository.SaveChapters(item.Id, chapters, cancellationToken).ConfigureAwait(false); } }