From 18a9720857ec9e6cdd580b3812bb72cf864d2f20 Mon Sep 17 00:00:00 2001 From: Luke Pulverenti Date: Sat, 18 Jan 2014 23:24:50 -0500 Subject: [PATCH] improve dvd vob file scan --- .../MediaInfo/FFProbeVideoInfoProvider.cs | 37 ++++++++++++++----- 1 file changed, 28 insertions(+), 9 deletions(-) diff --git a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs index 640dbd3fa4..afbea7f8bf 100644 --- a/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs +++ b/MediaBrowser.Providers/MediaInfo/FFProbeVideoInfoProvider.cs @@ -145,7 +145,18 @@ namespace MediaBrowser.Providers.MediaInfo item.RunTimeTicks = dvd.Titles.Select(GetRuntime).Max(); - PopulateDvdStreamFiles(item, mount); + var primaryTitle = dvd.Titles.OrderByDescending(GetRuntime).FirstOrDefault(); + + uint? titleNumber = null; + + if (primaryTitle != null) + { + titleNumber = primaryTitle.TitleNumber; + } + + item.PlayableStreamFileNames = GetPrimaryPlaylistVobFiles(item, mount, titleNumber) + .Select(Path.GetFileName) + .ToList(); } private long GetRuntime(Title title) @@ -237,12 +248,7 @@ namespace MediaBrowser.Providers.MediaInfo return null; } - /// - /// Finds vob files and populates the dvd stream file properties - /// - /// The video. - /// The iso mount. - private void PopulateDvdStreamFiles(Video video, IIsoMount isoMount) + private IEnumerable GetPrimaryPlaylistVobFiles(Video video, IIsoMount isoMount, uint? titleNumber) { // min size 300 mb const long minPlayableSize = 314572800; @@ -259,7 +265,20 @@ namespace MediaBrowser.Providers.MediaInfo if (allVobs.Count == 0) { Logger.Error("No vobs found in dvd structure."); - return; + return new List(); + } + + if (titleNumber.HasValue) + { + var prefix = string.Format("VTS_0{0}_", titleNumber.Value.ToString(UsCulture)); + var vobs = allVobs.Where(i => Path.GetFileName(i).StartsWith(prefix, StringComparison.OrdinalIgnoreCase)).ToList(); + + if (vobs.Count > 0) + { + return vobs; + } + + Logger.Debug("Could not determine vob file list for {0} using DvdLib. Will scan using file sizes.", video.Path); } var files = allVobs @@ -299,7 +318,7 @@ namespace MediaBrowser.Providers.MediaInfo } } - video.PlayableStreamFileNames = files.Select(Path.GetFileName).ToList(); + return files; } ///