/// <param name="query">The query that will be passed to the HandBrake CLI.</param>\r
/// <param name="source">The location of the source video.</param>\r
/// <param name="destination">The location where the encoded video will be.</param>\r
- public void AddJob(string query, string source, string destination)\r
+ /// <param name="customJob"></param>\r
+ public void AddJob(string query, string source, string destination, bool customJob)\r
{\r
- Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination };\r
+ Job newJob = new Job { Id = nextJobId++, Query = query, Source = source, Destination = destination, CustomQuery = customJob };\r
\r
queue.Add(newJob);\r
WriteQueueStateToFile("hb_queue_recovery.xml");\r
// Run through each item on the queue\r
while (this.Count != 0)\r
{\r
- string query = GetNextJob().Query;\r
+ Job encJob = GetNextJob();\r
+ string query = encJob.Query;\r
WriteQueueStateToFile("hb_queue_recovery.xml"); // Update the queue recovery file\r
\r
RunCli(query);\r
\r
hbProcess.WaitForExit();\r
\r
- AddCLIQueryToLog(query);\r
+ AddCLIQueryToLog(encJob);\r
CopyLog(LastEncode.Destination);\r
\r
hbProcess.Close();\r
Thread.Sleep(5000);\r
}\r
}\r
+ LastEncode = new Job();\r
\r
if (QueueCompleted != null)\r
QueueCompleted(this, new EventArgs());\r
{\r
try\r
{\r
+ isEncoding = true;\r
+\r
string handbrakeCLIPath = Path.Combine(Application.StartupPath, "HandBrakeCLI.exe");\r
string logPath = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs", "last_encode_log.txt");\r
string strCmdLine = String.Format(@" /C """"{0}"" {1} 2>""{2}"" """, handbrakeCLIPath, query, logPath);\r
\r
Process[] before = Process.GetProcesses(); // Get a list of running processes before starting.\r
hbProcess = Process.Start(cliStart);\r
- processID = Main.getCliProcess(before);\r
- isEncoding = true;\r
+ processID = Main.getCliProcess(before); \r
currentQuery = query;\r
if (hbProcess != null)\r
processHandle = hbProcess.MainWindowHandle; // Set the process Handle\r
{\r
MessageBox.Show("It would appear that HandBrakeCLI has not started correctly. You should take a look at the Activity log as it may indicate the reason why.\n\n Detailed Error Information: error occured in runCli()\n\n" + exc, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);\r
}\r
-\r
}\r
\r
/// <summary>\r
/// Append the CLI query to the start of the log file.\r
/// </summary>\r
/// <param name="query"></param>\r
- private static void AddCLIQueryToLog(string query)\r
+ private static void AddCLIQueryToLog(Job encJob)\r
{\r
string logDir = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\HandBrake\\logs";\r
string logPath = Path.Combine(logDir, "last_encode_log.txt");\r
\r
StreamWriter writer = new StreamWriter(File.Create(logPath));\r
\r
- writer.Write("### CLI Query: " + query + "\n\n");\r
+ writer.Write("### CLI Query: " + encJob.Query + "\n\n");\r
+ writer.Write("### User Query: " + encJob.CustomQuery + "\n\n");\r
writer.Write("#########################################\n\n");\r
writer.WriteLine(log);\r
writer.Flush();\r