@ -25,9 +25,6 @@ using System.IO;
using System.Linq ;
using System.Threading ;
using System.Threading.Tasks ;
using MediaBrowser.Controller.IO ;
using MediaBrowser.Model.IO ;
using MediaBrowser.Model.Globalization ;
namespace MediaBrowser.Providers.MediaInfo
@ -49,8 +46,6 @@ namespace MediaBrowser.Providers.MediaInfo
private readonly IChapterManager _chapterManager ;
private readonly ILibraryManager _libraryManager ;
private readonly CultureInfo _usCulture = new CultureInfo ( "en-US" ) ;
public FFProbeVideoInfo ( ILogger logger , IIsoManager isoManager , IMediaEncoder mediaEncoder , IItemRepository itemRepo , IBlurayExaminer blurayExaminer , ILocalizationManager localization , IApplicationPaths appPaths , IJsonSerializer json , IEncodingManager encodingManager , IFileSystem fileSystem , IServerConfigurationManager config , ISubtitleManager subtitleManager , IChapterManager chapterManager , ILibraryManager libraryManager )
{
_logger = logger ;
@ -565,8 +560,8 @@ namespace MediaBrowser.Providers.MediaInfo
titleNumber = primaryTitle . VideoTitleSetNumber ;
item . RunTimeTicks = GetRuntime ( primaryTitle ) ;
}
return GetPrimaryPlaylistVobFiles( item , mount , titleNumber )
return _mediaEncoder. GetPrimaryPlaylistVobFiles( item . Path , mount , titleNumber )
. Select ( Path . GetFileName )
. ToArray ( ) ;
}
@ -616,82 +611,5 @@ namespace MediaBrowser.Providers.MediaInfo
return null ;
}
private IEnumerable < string > GetPrimaryPlaylistVobFiles ( Video video , IIsoMount isoMount , uint? titleNumber )
{
// min size 300 mb
const long minPlayableSize = 314572800 ;
var root = isoMount ! = null ? isoMount . MountedPath : video . Path ;
// Try to eliminate menus and intros by skipping all files at the front of the list that are less than the minimum size
// Once we reach a file that is at least the minimum, return all subsequent ones
var allVobs = _fileSystem . GetFiles ( root , new [ ] { ".vob" } , false , true )
. OrderBy ( i = > i . FullName )
. ToList ( ) ;
// If we didn't find any satisfying the min length, just take them all
if ( allVobs . Count = = 0 )
{
_logger . Error ( "No vobs found in dvd structure." ) ;
return new List < string > ( ) ;
}
if ( titleNumber . HasValue )
{
var prefix = string . Format ( "VTS_0{0}_" , titleNumber . Value . ToString ( _usCulture ) ) ;
var vobs = allVobs . Where ( i = > i . Name . StartsWith ( prefix , StringComparison . OrdinalIgnoreCase ) ) . ToList ( ) ;
if ( vobs . Count > 0 )
{
var minSizeVobs = vobs
. SkipWhile ( f = > f . Length < minPlayableSize )
. ToList ( ) ;
return minSizeVobs . Count = = 0 ? vobs . Select ( i = > i . FullName ) : minSizeVobs . Select ( i = > i . FullName ) ;
}
_logger . Info ( "Could not determine vob file list for {0} using DvdLib. Will scan using file sizes." , video . Path ) ;
}
var files = allVobs
. SkipWhile ( f = > f . Length < minPlayableSize )
. ToList ( ) ;
// If we didn't find any satisfying the min length, just take them all
if ( files . Count = = 0 )
{
_logger . Warn ( "Vob size filter resulted in zero matches. Taking all vobs." ) ;
files = allVobs ;
}
// Assuming they're named "vts_05_01", take all files whose second part matches that of the first file
if ( files . Count > 0 )
{
var parts = _fileSystem . GetFileNameWithoutExtension ( files [ 0 ] ) . Split ( '_' ) ;
if ( parts . Length = = 3 )
{
var title = parts [ 1 ] ;
files = files . TakeWhile ( f = >
{
var fileParts = _fileSystem . GetFileNameWithoutExtension ( f ) . Split ( '_' ) ;
return fileParts . Length = = 3 & & string . Equals ( title , fileParts [ 1 ] , StringComparison . OrdinalIgnoreCase ) ;
} ) . ToList ( ) ;
// If this resulted in not getting any vobs, just take them all
if ( files . Count = = 0 )
{
_logger . Warn ( "Vob filename filter resulted in zero matches. Taking all vobs." ) ;
files = allVobs ;
}
}
}
return files . Select ( i = > i . FullName ) ;
}
}
}