public Title(Title title) { Number = title.Number; Name = title.Name; Length = title.Length; FrameRate = title.FrameRate; Files = title.Files; Chapters = title.Chapters; }
public static List<Title> GetTitles(string path) { string output; using (var process = new Process { StartInfo = GetStartInfo() }) { process.StartInfo.Arguments = "\"" + path + "\""; process.StartInfo.WorkingDirectory = string.Empty; process.Start(); output = process.StandardOutput.ReadToEnd(); process.WaitForExit(); } var titles = new List<Title>(); MatchCollection titleMatches = Regex.Matches(output, @"(\d+)\) (?:\d+\.mpls.*?, )?(.+?(?:\n[\s\b]*\n|.$))", RegexOptions.Singleline); foreach (Match titleMatch in titleMatches) { var title = new Title(); Match lengthMatch = Regex.Match(titleMatch.Groups[2].Value, @"(?:\d+\:){2}\d+"); Match nameMatch = Regex.Match(titleMatch.Groups[2].Value, @"""(\w+)"""); Match filesMatch = Regex.Match(titleMatch.Groups[2].Value, @"\S+(\.\w+)"); Match frameRateMatch = Regex.Match(titleMatch.Groups[2].Value, @"([pi])(\d+)(?: \/(\d+\.\d+))?"); title.Number = int.Parse(titleMatch.Groups[1].Value); title.Name = !nameMatch.Success ? null : Regex.Replace(nameMatch.Groups[1].Value, @"([a-z])([A-Z0-9])", "$1 $2"); title.Length = lengthMatch.Value; if (!frameRateMatch.Success) frameRateMatch = GetFrameRateMatch(path, title.Number); title.FrameRate = int.Parse(frameRateMatch.Groups[2].Value); if (frameRateMatch.Groups[3].Success) { title.FrameRate /= double.Parse(frameRateMatch.Groups[3].Value, NumberStyles.AllowDecimalPoint, CultureInfo.InvariantCulture); if (frameRateMatch.Groups[1].Value == "i") title.FrameRate /= 2; } string ext = filesMatch.Groups[1].Value; string files = filesMatch.Value.Replace(ext, string.Empty).Trim(new[] { '[', ']' }); foreach (string file in files.Split('+')) title.Files.Add(Path.Combine(path, Utilities.IsBluray(path) ? Path.Combine("BDMV", "STREAM", int.Parse(file).ToString("D5")) : Path.Combine("HVDVD_TS", file)) + ext); titles.Add(title); } return titles; }
private void removeButton_Click(object sender, RoutedEventArgs e) { var titles = new Title[selectedTitlesListView.SelectedItems.Count]; selectedTitlesListView.SelectedItems.CopyTo(titles, 0); for (int i = titles.Length - 1; i >= 0; i--) SelectedTitles.Remove(titles[i]); }