private void WriteAudioFilesThread(object o) { CUESheet cueSheet = (CUESheet)o; CUEToolsScript script = _profile._script == null || !_profile._config.scripts.ContainsKey(_profile._script) ? null : _profile._config.scripts[_profile._script]; try { _startedAt = DateTime.Now; if (_batchPaths.Count != 0) { pathIn = _batchPaths[0]; } pathIn = Path.GetFullPath(pathIn); this.Invoke((MethodInvoker) delegate() { textBox1.Text += "Processing " + pathIn + ":\r\n"; textBox1.Select(0, 0); }); if (!File.Exists(pathIn) && !Directory.Exists(pathIn)) { throw new Exception("Input CUE Sheet not found."); } if (_profile._action == CUEAction.CorrectFilenames) { throw new Exception("CorrectFilenames action not yet supported in commandline mode."); } if (_profile._action == CUEAction.CreateDummyCUE) { throw new Exception("CreateDummyCUE action not yet supported in commandline mode."); } bool useAR = _profile._action == CUEAction.Verify || _profile._ARVerifyOnEncode; cueSheet.Action = _profile._action; cueSheet.OutputStyle = _profile._CUEStyle; cueSheet.WriteOffset = _profile._writeOffset; cueSheet.Open(pathIn); if (useAR) { cueSheet.UseAccurateRip(); } pathOut = CUESheet.GenerateUniqueOutputPath(_profile._config, _profile._outputTemplate, _profile._CUEStyle == CUEStyle.SingleFileWithCUE ? "." + _profile._outputAudioFormat : ".cue", _profile._action, new NameValueCollection(), pathIn, cueSheet); if (pathOut == "" || (_profile._action != CUEAction.Verify && File.Exists(pathOut))) { throw new Exception("Could not generate output path."); } cueSheet.GenerateFilenames(_profile._outputAudioType, _profile._outputAudioFormat, pathOut); cueSheet.UsePregapForFirstTrackInSingleFile = false; if (script == null) { cueSheet.Go(); } else { /* status = */ cueSheet.ExecuteScript(script); } this.Invoke((MethodInvoker) delegate() { if (_batchPaths.Count == 0) { Text = "Done."; } //TimeSpan span = DateTime.Now - _startedAt; progressBar2.Value = 0; if (cueSheet.IsCD) { textBox1.Text += cueSheet.LOGContents; textBox1.Show(); } else if (useAR) { textBox1.Text += CUESheetLogWriter.GetAccurateRipLog(cueSheet); textBox1.Show(); } textBox1.Text += "----------------------------------------------------------\r\n"; textBox1.Select(0, 0); }); } catch (StopException) { _batchPaths.Clear(); this.Invoke((MethodInvoker) delegate() { Text = "Aborted."; textBox1.Text += "Aborted."; progressBar2.Value = 0; }); } #if !DEBUG catch (Exception ex) { this.Invoke((MethodInvoker) delegate() { Text = "Error: " + ex.Message; textBox1.Show(); textBox1.Text += "Error"; for (Exception e = ex; e != null; e = e.InnerException) { textBox1.Text += ": " + e.Message; } textBox1.Text += "\r\n----------------------------------------------------------\r\n"; textBox1.Select(0, 0); }); } #endif if (_batchPaths.Count != 0) { _batchPaths.RemoveAt(0); this.BeginInvoke((MethodInvoker) delegate() { if (_batchPaths.Count == 0) { Text = "All done."; } else { StartConvert(); } }); } }
static int Main(string[] args) { bool ok = true; bool verbose = false; string pathIn = null; for (int arg = 0; arg < args.Length; arg++) { if (args[arg].Length == 0) { ok = false; } else if ((args[arg] == "-v" || args[arg] == "--verbose")) { verbose = true; } else if (args[arg][0] != '-' && pathIn == null) { pathIn = args[arg]; } else { ok = false; } if (!ok) { break; } } if (!ok || pathIn == null) { Console.SetOut(Console.Error); Console.WriteLine("Usage : CUETools.ARCUE.exe [options] <filename>"); Console.WriteLine(); Console.WriteLine("Options:"); Console.WriteLine(); Console.WriteLine(" -v --verbose Verbose mode"); return(1); } if (!File.Exists(pathIn)) { Console.SetOut(Console.Error); Console.WriteLine("Input CUE Sheet not found."); return(2); } CUEConfig config = new CUEConfig(); config.writeArLogOnVerify = false; config.writeArTagsOnVerify = false; config.autoCorrectFilenames = true; config.extractAlbumArt = false; config.embedAlbumArt = false; config.advanced.DetailedCTDBLog = verbose; string accurateRipLog; try { CUESheet cueSheet = new CUESheet(config); cueSheet.Action = CUEAction.Verify; //cueSheet.OutputStyle = CUEStyle.SingleFile; cueSheet.Open(pathIn); cueSheet.UseAccurateRip(); cueSheet.UseCUEToolsDB("ARCUE " + CUESheet.CUEToolsVersion, null, true, CTDBMetadataSearch.None); cueSheet.GenerateFilenames(AudioEncoderType.NoAudio, "dummy", pathIn); cueSheet.Go(); accurateRipLog = CUESheetLogWriter.GetAccurateRipLog(cueSheet); } catch (Exception ex) { Console.WriteLine("Error: " + ex.Message); return(3); } Console.Write(accurateRipLog); return(0); }