diff options
author | sr55 <[email protected]> | 2007-08-25 20:34:42 +0000 |
---|---|---|
committer | sr55 <[email protected]> | 2007-08-25 20:34:42 +0000 |
commit | 370ca4bd5162411684a524fdceba9a6967b8c64e (patch) | |
tree | f13b0f85e60be2a958318472f37f03c8dcef85dd /win/C#/Parsing | |
parent | 2548077aee301044b45aca605f6949fec78903a9 (diff) |
WinGui:
- PSP Preset Fix
- Cleaned up Exception handling a bit.
git-svn-id: svn://svn.handbrake.fr/HandBrake/trunk@866 b64f7644-9d1e-0410-96f1-a4d463321fa5
Diffstat (limited to 'win/C#/Parsing')
-rw-r--r-- | win/C#/Parsing/DVD.cs | 22 | ||||
-rw-r--r-- | win/C#/Parsing/Parser.cs | 65 | ||||
-rw-r--r-- | win/C#/Parsing/Title.cs | 28 |
3 files changed, 73 insertions, 42 deletions
diff --git a/win/C#/Parsing/DVD.cs b/win/C#/Parsing/DVD.cs index d2d211538..62a40d81b 100644 --- a/win/C#/Parsing/DVD.cs +++ b/win/C#/Parsing/DVD.cs @@ -42,18 +42,24 @@ namespace Handbrake.Parsing public static DVD Parse(StreamReader output)
{
DVD thisDVD = new DVD();
- while (!output.EndOfStream)
+ try
{
- if ((char)output.Peek() == '+')
+ while (!output.EndOfStream)
{
- string testb = output.ReadToEnd();
- thisDVD.m_titles.AddRange(Title.ParseList(testb));
- }
- else
- {
- output.ReadLine();
+ if ((char)output.Peek() == '+')
+ {
+ thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));
+ }
+ else
+ {
+ output.ReadLine();
+ }
}
}
+ catch (Exception exc)
+ {
+ MessageBox.Show("DVD.CS - Parse" + exc.ToString());
+ }
return thisDVD;
}
}
diff --git a/win/C#/Parsing/Parser.cs b/win/C#/Parsing/Parser.cs index f56999a0d..ea2ae57fd 100644 --- a/win/C#/Parsing/Parser.cs +++ b/win/C#/Parsing/Parser.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Text;
using System.IO;
using System.Text.RegularExpressions;
+using System.Windows.Forms;
namespace Handbrake.Parsing
{
@@ -79,30 +80,38 @@ namespace Handbrake.Parsing public override string ReadLine()
{
string tmp = base.ReadLine();
- this.m_buffer += tmp;
- Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");
- if (OnReadLine != null)
+ try
{
- OnReadLine(this, tmp);
- }
- if (m.Success && OnScanProgress != null)
- {
- OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
- }
- m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?");
- if (m.Success && OnEncodeProgress != null)
- {
- int currentTask = int.Parse(m.Groups[1].Value);
- int totalTasks = int.Parse(m.Groups[2].Value);
- float percent = float.Parse(m.Groups[3].Value);
- float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value);
- float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value);
- TimeSpan remaining = TimeSpan.Zero;
- if (m.Groups[7].Value != string.Empty)
+
+ this.m_buffer += tmp;
+ Match m = Regex.Match(tmp, "^Scanning title ([0-9]*) of ([0-9]*)");
+ if (OnReadLine != null)
+ {
+ OnReadLine(this, tmp);
+ }
+ if (m.Success && OnScanProgress != null)
+ {
+ OnScanProgress(this, int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));
+ }
+ m = Regex.Match(tmp, @"^Encoding: task ([0-9]*) of ([0-9]*), ([0-9]*\.[0-9]*) %( \(([0-9]*\.[0-9]*) fps, avg ([0-9]*\.[0-9]*) fps, ETA ([0-9]{2})h([0-9]{2})m([0-9]{2})s\))?");
+ if (m.Success && OnEncodeProgress != null)
{
- remaining = TimeSpan.Parse(m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value);
+ int currentTask = int.Parse(m.Groups[1].Value);
+ int totalTasks = int.Parse(m.Groups[2].Value);
+ float percent = float.Parse(m.Groups[3].Value);
+ float currentFps = m.Groups[5].Value == string.Empty ? 0.0F : float.Parse(m.Groups[5].Value);
+ float avgFps = m.Groups[6].Value == string.Empty ? 0.0F : float.Parse(m.Groups[6].Value);
+ TimeSpan remaining = TimeSpan.Zero;
+ if (m.Groups[7].Value != string.Empty)
+ {
+ remaining = TimeSpan.Parse(m.Groups[7].Value + ":" + m.Groups[8].Value + ":" + m.Groups[9].Value);
+ }
+ OnEncodeProgress(this, currentTask, totalTasks, percent, currentFps, avgFps, remaining);
}
- OnEncodeProgress(this, currentTask, totalTasks, percent, currentFps, avgFps, remaining);
+ }
+ catch (Exception exc)
+ {
+ MessageBox.Show("Parser.cs - ReadLine " + exc.ToString());
}
return tmp;
}
@@ -110,10 +119,18 @@ namespace Handbrake.Parsing public override string ReadToEnd()
{
string tmp = base.ReadToEnd();
- this.m_buffer += tmp;
- if (OnReadToEnd != null)
+ try
+ {
+
+ this.m_buffer += tmp;
+ if (OnReadToEnd != null)
+ {
+ OnReadToEnd(this, tmp);
+ }
+ }
+ catch (Exception exc)
{
- OnReadToEnd(this, tmp);
+ MessageBox.Show("Parser.cs - ReadToEnd " + exc.ToString());
}
return tmp;
}
diff --git a/win/C#/Parsing/Title.cs b/win/C#/Parsing/Title.cs index a78fef78a..3c3aaca74 100644 --- a/win/C#/Parsing/Title.cs +++ b/win/C#/Parsing/Title.cs @@ -137,11 +137,9 @@ namespace Handbrake.Parsing public static Title Parse(StringReader output)
{
Title thisTitle = new Title();
-
- // Match track number for this title
try
{
-
+ // Match track number for this title
Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");
if (m.Success)
{
@@ -150,20 +148,21 @@ namespace Handbrake.Parsing output.ReadLine();
// Get duration for this title
+
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 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 = m.Groups[3].ToString(); // Converted to a String for French Lanuage based systems. Some weird exception thrown
- // when trying to parse it as a float
- // we don't need FPS right now
+ thisTitle.m_aspectRatio = m.Groups[3].ToString(); // Converted to a String from float. Caused issue on french systems
+ // French system floats are 1,78 not 1.78 and the CLI always outputs a .
}
// Get autocrop region for this title
@@ -179,18 +178,27 @@ namespace Handbrake.Parsing }
catch (Exception exc)
{
- MessageBox.Show(exc.ToString());
+ MessageBox.Show("Title.cs - Parse " + exc.ToString());
}
+
+
return thisTitle;
}
public static Title[] ParseList(string output)
{
List<Title> titles = new List<Title>();
- StringReader sr = new StringReader(output);
- while ((char)sr.Peek() == '+')
+ try
+ {
+ StringReader sr = new StringReader(output);
+ while ((char)sr.Peek() == '+')
+ {
+ titles.Add(Title.Parse(sr));
+ }
+ }
+ catch (Exception exc)
{
- titles.Add(Title.Parse(sr));
+ MessageBox.Show("Title.cs - ParseList " + exc.ToString());
}
return titles.ToArray();
}
|