added safeguards to GetDummyChapters

pull/702/head
Luke Pulverenti 11 years ago
parent 18131d2cbc
commit d14d2dee6f

@ -278,7 +278,7 @@ namespace MediaBrowser.Providers.MediaInfo
FetchWtvInfo(video, data); FetchWtvInfo(video, data);
if (chapters.Count == 0) if (chapters.Count == 0 && video.MediaStreams.Any(i => i.Type == MediaStreamType.Video))
{ {
AddDummyChapters(video, chapters); AddDummyChapters(video, chapters);
} }
@ -439,6 +439,11 @@ namespace MediaBrowser.Providers.MediaInfo
{ {
var runtime = video.RunTimeTicks ?? 0; var runtime = video.RunTimeTicks ?? 0;
if (runtime < 0)
{
throw new ArgumentException(string.Format("{0} has invalid runtime of {1}", video.Name, runtime));
}
if (runtime < _dummyChapterDuration) if (runtime < _dummyChapterDuration)
{ {
return; return;
@ -447,7 +452,8 @@ namespace MediaBrowser.Providers.MediaInfo
long currentChapterTicks = 0; long currentChapterTicks = 0;
var index = 1; var index = 1;
while (currentChapterTicks < runtime) // Limit to 100 chapters just in case there's some incorrect metadata here
while (currentChapterTicks < runtime && index < 100)
{ {
chapters.Add(new ChapterInfo chapters.Add(new ChapterInfo
{ {

Loading…
Cancel
Save