using System;\r
using System.Collections.Generic;\r
+using System.ComponentModel;\r
+using System.Data;\r
+using System.Drawing;\r
using System.Text;\r
-using System.IO;\r
-using System.Text.RegularExpressions;\r
using System.Windows.Forms;\r
+using System.IO;\r
+using System.Threading;\r
+using System.Diagnostics;\r
\r
namespace Handbrake.Parsing\r
{\r
+ \r
/// <summary>\r
/// An object representing a scanned DVD\r
/// </summary>\r
public class DVD\r
{\r
+\r
private List<Title> m_titles;\r
/// <summary>\r
/// Collection of Titles associated with this DVD\r
{\r
if ((char)output.Peek() == '+')\r
{\r
- thisDVD.m_titles.AddRange(Title.ParseList(output.ReadToEnd()));\r
+ string testb = output.ReadToEnd();\r
+ thisDVD.m_titles.AddRange(Title.ParseList(testb));\r
}\r
else\r
{\r
- output.ReadLine();\r
+ string test = output.ReadLine();\r
}\r
}\r
return thisDVD;\r
}\r
}\r
\r
- private float m_aspectRatio;\r
+ private string m_aspectRatio;\r
/// <summary>\r
/// The aspect ratio of this Title\r
/// </summary>\r
- public float AspectRatio\r
+ public string AspectRatio\r
{\r
get\r
{\r
Title thisTitle = new Title();\r
\r
// Match track number for this title\r
- Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");\r
- if (m.Success)\r
+ try\r
{\r
- thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value);\r
- }\r
-\r
- output.ReadLine();\r
- /*\r
- // Match vts, ttn, cell range and block count\r
- m = Regex.Match(output.ReadLine(), @"^ \+ vts ([0-9]*), ttn ([0-9]*), cells ([0-9]*)->([0-9]*) \(([0-9]*) blocks\)");\r
- if (m.Success)\r
- {\r
- // We don't need any of those values right now, so we'll just ignore them\r
- // and read a line from the buffer to get it out of the way.\r
- }\r
- */\r
\r
- // Get duration for this title\r
- m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
- if (m.Success)\r
- {\r
- thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);\r
+ Match m = Regex.Match(output.ReadLine(), @"^\+ title ([0-9]*):");\r
+ if (m.Success)\r
+ {\r
+ thisTitle.m_titleNumber = int.Parse(m.Groups[1].Value);\r
+ }\r
+ output.ReadLine();\r
+\r
+ // Get duration for this title\r
+ m = Regex.Match(output.ReadLine(), @"^ \+ duration: ([0-9]{2}:[0-9]{2}:[0-9]{2})");\r
+ if (m.Success)\r
+ {\r
+ thisTitle.m_duration = TimeSpan.Parse(m.Groups[1].Value);\r
+ }\r
+\r
+ // Get resolution, aspect ratio and FPS for this title\r
+ m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
+ if (m.Success)\r
+ {\r
+ thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
+ thisTitle.m_aspectRatio = m.Groups[3].ToString(); // Converted to a String for French Lanuage based systems. Some weird exception thrown\r
+ // when trying to parse it as a float\r
+ // we don't need FPS right now\r
+ }\r
+\r
+ // Get autocrop region for this title\r
+ m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");\r
+ if (m.Success)\r
+ {\r
+ 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) };\r
+ }\r
+\r
+ thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
+ thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));\r
+ thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));\r
}\r
-\r
- // Get resolution, aspect ratio and FPS for this title\r
- m = Regex.Match(output.ReadLine(), @"^ \+ size: ([0-9]*)x([0-9]*), aspect: ([0-9]*\.[0-9]*), ([0-9]*\.[0-9]*) fps");\r
- if (m.Success)\r
+ catch (Exception exc)\r
{\r
- thisTitle.m_resolution = new Size(int.Parse(m.Groups[1].Value), int.Parse(m.Groups[2].Value));\r
- thisTitle.m_aspectRatio = float.Parse(m.Groups[3].Value);\r
- // we don't need FPS right now\r
+ MessageBox.Show(exc.ToString());\r
}\r
-\r
- // Get autocrop region for this title\r
- m = Regex.Match(output.ReadLine(), @"^ \+ autocrop: ([0-9]*)/([0-9]*)/([0-9]*)/([0-9]*)");\r
- if (m.Success)\r
- {\r
- 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) };\r
- }\r
-\r
- /* \r
- * \r
- * A Few Bugs that need fixed.\r
- * \r
- * \r
- * Problem 1\r
- * There is a small problem here... What happens if the DVD has no Subtitles? or Handbrake misses the Audio or Chapter track \r
- * data due to an error.\r
- * \r
- * hbcli will sit in a suspended state until it is forcefully closed.\r
- * \r
- * Problem 2\r
- * See AudioTrack.cs Line 80 for details\r
- * \r
- * Problem 3\r
- * Doesn't seem to support DVD's where the first track is 0 instead of 1, and only includes 1 title (TS/MPG files)\r
- * Simply Doesn't list any titles.\r
- * \r
- * \r
- */\r
-\r
- thisTitle.m_chapters.AddRange(Chapter.ParseList(output));\r
- thisTitle.m_audioTracks.AddRange(AudioTrack.ParseList(output));\r
- thisTitle.m_subtitles.AddRange(Subtitle.ParseList(output));\r
-\r
return thisTitle;\r
}\r
\r
private Parsing.DVD thisDvd;\r
private Process hbProc;\r
private delegate void UpdateUIHandler();\r
- private int cancel = 0;\r
+ //private int cancel = 0;\r
\r
public frmReadDVD(string inputFile, frmMain parent, frmDvdInfo dvdInfoWindow)\r
{\r
\r
private void btn_ok_Click(object sender, EventArgs e)\r
{\r
- \r
+ \r
try\r
{\r
btn_ok.Enabled = false;\r
string strCmdLine = "cmd /c " + '"' + '"' + appPath + "\\hbcli.exe" + '"' + " -i" + '"' + inputFile + '"' + " -t0 >" + '"'+ appPath + "\\dvdinfo.dat" + '"' + " 2>&1" + '"';\r
Process hbproc = Process.Start("CMD.exe", strCmdLine);\r
hbproc.WaitForExit();\r
+ hbproc.Dispose();\r
+ hbproc.Close();\r
\r
\r
StreamReader sr = new StreamReader(appPath + "dvdinfo.dat");\r
- \r
thisDvd = Parsing.DVD.Parse(sr);\r
\r
sr.Close();\r
+\r
Console.ReadLine();\r
+\r
updateUIElements();\r
}\r
catch (Exception exc)\r
{\r
MessageBox.Show(exc.ToString());\r
}\r
- //*********************************************************************************************************************************************\r
\r
+ }\r
+\r
+ //*********************************************************************************************************************************************\r
/*\r
* This has been temporily disabled due to the stderr issue\r
* \r
process.closeCLI();\r
}\r
*/\r
- }\r
+ //*********************************************************************************************************************************************\r
+\r
\r
/*private void Parser_OnScanProgress(object Sender, int CurrentTitle, int TitleCount)\r
{\r
try\r
{\r
this.Close();\r
- cancel = 1;\r
+ //cancel = 1;\r
}\r
catch (Exception exc)\r
{\r