diff options
author | sr55 <[email protected]> | 2008-08-27 23:45:44 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2008-08-27 23:45:44 +0000 |
commit | c1f31822b78859305328750ca0adcd0b1699f690 (patch) | |
tree | 9751e09ecee8a9199e5f49ae0af351f71a8be794 /win/C#/Parsing/Title.cs | |
parent | 1833f566d3f9c7fbe0ef61b4f9304b6e0f7fddb5 (diff) |
WinGui:
- Code Refactoring and optimization to numerous files
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@1655 b64f7644-9d1e-0410-96f1-a4d463321fa5
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();
}
}
|