}\r
\r
/// <summary>\r
+ /// Import a CSV file which contains Chapter Names\r
+ /// </summary>\r
+ /// <param name="dataChpt"></param>\r
+ /// <param name="filename"></param>\r
+ /// <returns></returns>\r
+ public static DataGridView importChapterNames(DataGridView dataChpt, string filename)\r
+ {\r
+ IDictionary<int, string> chapterMap = new Dictionary<int, string>();\r
+ try\r
+ {\r
+ StreamReader sr = new StreamReader(filename);\r
+ string csv = sr.ReadLine();\r
+ while (csv != null)\r
+ {\r
+ if (csv.Trim() != "")\r
+ {\r
+ string[] contents = csv.Split(',');\r
+ int chapter;\r
+ int.TryParse(contents[0], out chapter);\r
+ chapterMap.Add(chapter, contents[1]);\r
+ }\r
+ csv = sr.ReadLine();\r
+ }\r
+ }\r
+ catch (Exception)\r
+ {\r
+ return null;\r
+ }\r
+\r
+ foreach (DataGridViewRow item in dataChpt.Rows)\r
+ {\r
+ string name;\r
+ chapterMap.TryGetValue((int)item.Cells[0].Value, out name);\r
+ item.Cells[1].Value = name ?? "Chapter " + item.Cells[0].Value;\r
+ }\r
+\r
+ return dataChpt;\r
+ }\r
+\r
+ /// <summary>\r
/// Function which generates the filename and path automatically based on \r
/// the Source Name, DVD title and DVD Chapters\r
/// </summary>\r
- public static string autoName(ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format)\r
+ public static string autoName(frmMain mainWindow) //ComboBox drpDvdtitle, string chapter_start, string chatper_end, string source, string dest, int format, Boolean chapters)\r
{\r
string AutoNamePath = string.Empty;\r
- if (drpDvdtitle.Text != "Automatic")\r
+ if (mainWindow.drp_dvdtitle.Text != "Automatic")\r
{\r
// Get the Source Name \r
- string sourceName = Path.GetFileNameWithoutExtension(source);\r
+ string sourceName = mainWindow.SourceName;\r
\r
// Get the Selected Title Number\r
- string[] titlesplit = drpDvdtitle.Text.Split(' ');\r
+ string[] titlesplit = mainWindow.drp_dvdtitle.Text.Split(' ');\r
string dvdTitle = titlesplit[0].Replace("Automatic", "");\r
\r
// Get the Chapter Start and Chapter End Numbers\r
- string chapterStart = chapter_start.Replace("Auto", "");\r
- string chapterFinish = chatper_end.Replace("Auto", "");\r
+ string chapterStart = mainWindow.drop_chapterStart.Text.Replace("Auto", "");\r
+ string chapterFinish = mainWindow.drop_chapterFinish.Text.Replace("Auto", "");\r
string combinedChapterTag = chapterStart;\r
if (chapterFinish != chapterStart && chapterFinish != "")\r
combinedChapterTag = chapterStart + "-" + chapterFinish;\r
destinationFilename = sourceName + "_T" + dvdTitle + "_C" + combinedChapterTag;\r
\r
// Add the appropriate file extension\r
- if (format == 0)\r
+ if (mainWindow.drop_format.SelectedIndex == 0)\r
{\r
- if (Properties.Settings.Default.useM4v)\r
+ if (Properties.Settings.Default.useM4v || mainWindow.Check_ChapterMarkers.Checked || mainWindow.AudioSettings.RequiresM4V() || mainWindow.Subtitles.RequiresM4V())\r
destinationFilename += ".m4v";\r
else\r
destinationFilename += ".mp4";\r
}\r
- else if (format == 1)\r
+ else if (mainWindow.drop_format.SelectedIndex == 1)\r
destinationFilename += ".mkv";\r
\r
// Now work out the path where the file will be stored.\r
// First case: If the destination box doesn't already contain a path, make one.\r
- if (!dest.Contains(Path.DirectorySeparatorChar.ToString()))\r
+ if (!mainWindow.text_destination.Text.Contains(Path.DirectorySeparatorChar.ToString()))\r
{\r
// If there is an auto name path, use it...\r
if (Properties.Settings.Default.autoNamePath.Trim() != "" && Properties.Settings.Default.autoNamePath.Trim() != "Click 'Browse' to set the default location")\r
else // Otherwise, use the path that is already there.\r
{\r
// Use the path and change the file extension to match the previous destination\r
- AutoNamePath = Path.Combine(Path.GetDirectoryName(dest), destinationFilename);\r
- AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(dest));\r
+ AutoNamePath = Path.Combine(Path.GetDirectoryName(mainWindow.text_destination.Text), destinationFilename);\r
+\r
+ if (Path.HasExtension(mainWindow.text_destination.Text))\r
+ AutoNamePath = Path.ChangeExtension(AutoNamePath, Path.GetExtension(mainWindow.text_destination.Text));\r
}\r
}\r
\r
\r
// 0 = SVN Build / Version\r
// 1 = Build Date\r
+\r
+ DateTime lastModified = File.GetLastWriteTime("HandBrakeCLI.exe");\r
+\r
+\r
+ if (Properties.Settings.Default.cliLastModified == lastModified && Properties.Settings.Default.hb_build != 0)\r
+ return;\r
+\r
+ Properties.Settings.Default.cliLastModified = lastModified;\r
+ \r
Process cliProcess = new Process();\r
- ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u")\r
+ ProcessStartInfo handBrakeCLI = new ProcessStartInfo("HandBrakeCLI.exe", " -u -v0")\r
{\r
UseShellExecute = false,\r
RedirectStandardError = true,\r
while (!cliProcess.HasExited)\r
{\r
line = stdOutput.ReadLine() ?? "";\r
- Match m = Regex.Match(line, @"HandBrake ([0-9.]*)(svn[0-9M]*) \([0-9]*\)");\r
+ Match m = Regex.Match(line, @"HandBrake ([svnM0-9.]*) \([0-9]*\)");\r
Match platform = Regex.Match(line, @"- ([A-Za-z0-9\s ]*) -");\r
\r
if (m.Success)\r
cli.Kill();\r
}\r
}\r
+ Properties.Settings.Default.Save();\r
}\r
catch (Exception e)\r
{\r
/// If it does, it means the last queue did not complete before HandBrake closed.\r
/// So, return a boolean if true. \r
/// </summary>\r
- public static Boolean check_queue_recovery()\r
+ public static Boolean checkQueueRecovery()\r
{\r
try\r
{\r
- string tempPath = Path.Combine(Path.GetTempPath(), "hb_queue_recovery.xml");\r
+ string tempPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), @"HandBrake\hb_queue_recovery.xml");\r
if (File.Exists(tempPath))\r
{\r
using (FileStream strm = new FileStream(tempPath, FileMode.Open, FileAccess.Read))\r