diff options
Diffstat (limited to 'win/C#/Parsing/Title.cs')
-rw-r--r-- | win/C#/Parsing/Title.cs | 69 |
1 files changed, 29 insertions, 40 deletions
diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index 5d21d89cb..14eacf165 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -142,44 +142,38 @@ namespace Handbrake.Parsing public static Title Parse(StringReader output)
{
Title thisTitle = new Title();
- try
- {
- Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");
- // Match track number for this title
- if (m.Success)
- thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString());
- output.ReadLine();
+ Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");
+ // Match track number for this title
+ if (m.Success)
+ thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value.Trim().ToString());
- // Get duration for this title
+ output.ReadLine();
- m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");
- if (m.Success)
- thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);
+ // Get duration for this title
- // Get resolution, aspect ratio and FPS for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
- if (m.Success)
- {
- thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
- thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value, Functions.Encode.Culture);
- }
+ m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");
+ if (m.Success)
+ thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);
- // Get autocrop region for this title
- m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
- if (m.Success)
- thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };
+ // Get resolution, aspect ratio and FPS for this title
+ m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");
+ if (m.Success)
+ {
+ thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
+ thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value, Functions.Encode.Culture);
+ }
- thisTitle.m_chapters.AddRange(Chapter.ParseList(output));
+ // Get autocrop region for this title
+ m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");
+ if (m.Success)
+ thisTitle.m_autoCrop = new int[4] { int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value), int.Parse(m.Groups[3].Value), int.Parse(m.Groups[4].Value) };
- thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));
+ thisTitle.m_chapters.AddRange(Chapter.ParseList(output));
- thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));
- }
- catch (Exception exc)
- {
- MessageBox.Show("Title.cs - Parse " + exc.ToString());
- }
+ thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));
+
+ thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));
return thisTitle;
}
@@ -187,18 +181,13 @@ namespace Handbrake.Parsing public static Title[] ParseList(string output)
{
List<Title> titles = new List<Title>();
- try
- {
- StringReader sr = new StringReader(output);
- while ((char)sr.Peek() == '+')
- {
- titles.Add(Title.Parse(sr));
- }
- }
- catch (Exception exc)
+
+ StringReader sr = new StringReader(output);
+ while ((char)sr.Peek() == '+')
{
- MessageBox.Show("Title.cs - ParseList " + exc.ToString());
+ titles.Add(Title.Parse(sr));
}
+
return titles.ToArray();
}
}
|