public static bool GetChapterFromMPLS(TaskDetail task) { if (!task.InputFile.EndsWith(".m2ts")) { Logger.Warn($"{ task.InputFile }不是蓝光原盘文件。"); return(false); } FileInfo inputFile = new FileInfo(task.InputFile); string folder = inputFile.DirectoryName; if (!folder.EndsWith(@"\BDMV\STREAM")) { Logger.Warn($"{ task.InputFile }不在BDMV文件夹结构内。"); return(false); } folder = folder.Remove(folder.Length - 6); folder += "PLAYLIST"; DirectoryInfo playlist = new DirectoryInfo(folder); if (!playlist.Exists) { Logger.Warn($"{ task.InputFile }没有上级的PLAYLIST文件夹"); return(false); } FileInfo[] allPlaylists = playlist.GetFiles(); MPLSParser parser = new MPLSParser(); foreach (FileInfo mplsFile in allPlaylists) { IChapterData allChapters = parser.Parse(mplsFile.FullName); for (int i = 0; i < allChapters.Count; i++) { ChapterInfo chapter = allChapters[i]; if (chapter.SourceName + ".m2ts" == inputFile.Name) { //save chapter file string chapterFileName = Path.ChangeExtension(task.InputFile, ".txt"); allChapters.Save(ChapterTypeEnum.OGM, chapterFileName, i); return(true); } } } return(false); }
private static ChapterInfo GetChapterFromMPLS(IEnumerable <FileInfo> playlists, FileInfo inputFile) { MPLSParser parser = new MPLSParser(); foreach (FileInfo playlistFile in playlists) { IChapterData allChapters = parser.Parse(playlistFile.FullName); foreach (ChapterInfo chapter in allChapters) { if (chapter.SourceName + ".m2ts" == inputFile.Name) { return(chapter); } } } return(null); }