public static string GetVsPipePath(this IProcess process, out Exception exception) { exception = null; string vspipePath; try { vspipePath = RegistryStorage.Load(); if (vspipePath == null || !File.Exists(Path.Combine(vspipePath, "vspipe.exe"))) { vspipePath = Path.GetDirectoryName(ToolKits.GetFullPathFromWindows("vspipe.exe")) ?? ToolKits.GetVapourSynthPathViaRegistry(); if (vspipePath != null) { RegistryStorage.Save(vspipePath); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); vspipePath = string.Empty; exception = ex; } return(vspipePath); }
private void Form1_Load(object sender, EventArgs e) { Text = $@"Auto Torrent Inspection v{Assembly.GetExecutingAssembly().GetName().Version}"; RegistryStorage.Save(Application.ExecutablePath); RegistryStorage.RegistryAddCount(@"Software\AutoTorrentInspection\Statistics", @"count"); Updater.Utils.CheckUpdateWeekly("AutoTorrentInspection"); }
public MatroskaData() { var mkvToolnixPath = RegistryStorage.Load(@"Software\ChapterTool", "mkvToolnixPath"); // saved path not found. if (string.IsNullOrEmpty(mkvToolnixPath)) { try { mkvToolnixPath = GetMkvToolnixPathViaRegistry(); RegistryStorage.Save(mkvToolnixPath, @"Software\ChapterTool", "mkvToolnixPath"); } catch (Exception exception) { // no valid path found in Registry OnLog?.Invoke($"Warning: {exception.Message}"); } // Installed path not found. if (string.IsNullOrEmpty(mkvToolnixPath)) { mkvToolnixPath = Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location); } } if (mkvToolnixPath != null) { _mkvextractPath = Path.Combine(mkvToolnixPath, "mkvextract.exe"); } if (!File.Exists(_mkvextractPath)) { OnLog?.Invoke($"Mkvextract Path: {_mkvextractPath}"); throw new Exception("无可用 MkvExtract, 安装个呗~"); } }
public static string GetFFmpegPath(this IProcess process, out Exception exception) { exception = null; var ffmpegInReg = RegistryStorage.Load(name: "FFmpegPath"); try { var ffmpegInPath = Path.GetDirectoryName(ToolKits.GetFullPathFromWindows("ffmpeg.exe")); if (!string.IsNullOrEmpty(ffmpegInPath)) { if (ffmpegInReg != ffmpegInPath) { RegistryStorage.Save(ffmpegInPath, name: "FFmpegPath"); } return(ffmpegInPath); } if (ffmpegInReg == null || !File.Exists(Path.Combine(ffmpegInReg, "ffmpeg.exe"))) { ffmpegInReg = Notification.InputBox("请输入FFmpeg的地址", "注意不要带上多余的引号", "C:\\FFmpeg\\ffmpeg.exe"); if (!string.IsNullOrEmpty(ffmpegInReg)) { RegistryStorage.Save(Path.GetDirectoryName(ffmpegInReg), name: "FFmpegPath"); } } } catch (Exception ex) { Debug.WriteLine(ex.Message); exception = ex; } return(ffmpegInReg); }
private void FrmChart_FormClosing(object sender, FormClosingEventArgs e) { try { RegistryStorage.Save(Location.ToString(), @"Software\RPChecker", "ChartLocation"); } catch (Exception) { // ignored } }
public static async Task <KeyValuePair <string, BDMVGroup> > GetChapterAsync(string location) { var list = new BDMVGroup(); var bdmvTitle = string.Empty; var path = Path.Combine(location, "BDMV", "PLAYLIST"); if (!Directory.Exists(path)) { throw new FileNotFoundException("Blu-Ray disc structure not found."); } var metaPath = Path.Combine(location, "BDMV", "META", "DL"); if (Directory.Exists(metaPath)) { var xmlFile = Directory.GetFiles(metaPath).FirstOrDefault(file => file.ToLower().EndsWith(".xml")); if (xmlFile != null) { var xmlText = File.ReadAllText(xmlFile); var title = Regex.Match(xmlText, @"<di:name>(?<title>[^<]*)</di:name>"); if (title.Success) { bdmvTitle = title.Groups["title"].Value; OnLog?.Invoke($"Disc Title: {bdmvTitle}"); } } } var eac3toPath = RegistryStorage.Load(name: "eac3toPath"); if (string.IsNullOrEmpty(eac3toPath) || !File.Exists(eac3toPath)) { eac3toPath = Notification.InputBox("请输入eac3to的地址", "注意不要带上多余的引号", "C:\\eac3to\\eac3to.exe"); if (string.IsNullOrEmpty(eac3toPath)) { return(new KeyValuePair <string, BDMVGroup>(bdmvTitle, list)); } RegistryStorage.Save(name: "eac3toPath", value: eac3toPath); } var workingPath = Directory.GetParent(location).FullName; location = location.Substring(location.LastIndexOf('\\') + 1); var text = (await TaskAsync.RunProcessAsync(eac3toPath, $"\"{location}\"", workingPath)).ToString(); if (text.Contains("HD DVD / Blu-Ray disc structure not found.")) { OnLog?.Invoke(text); throw new Exception("May be the path is too complex or directory contains nonAscii characters"); } OnLog?.Invoke("\r\nDisc Info:\r\n" + text); foreach (Match match in RDiskInfo.Matches(text)) { var index = match.Groups["idx"].Value; var mpls = match.Groups["mpls"].Value; var time = match.Groups["dur"].Value; if (string.IsNullOrEmpty(time)) { time = match.Groups["dur2"].Value; } var file = match.Groups["fn"].Value; if (string.IsNullOrEmpty(file)) { file = match.Groups["fn2"].Value; } OnLog?.Invoke($"+ {index}) {mpls} -> [{file}] - [{time}]"); list.Add(new ChapterInfo { Duration = TimeSpan.Parse(time), SourceIndex = index, SourceName = file, }); } var toBeRemove = new List <ChapterInfo>(); var chapterPath = Path.Combine(workingPath, "chapters.txt"); var logPath = Path.Combine(workingPath, "chapters - Log.txt"); foreach (var current in list) { text = (await TaskAsync.RunProcessAsync(eac3toPath, $"\"{location}\" {current.SourceIndex})", workingPath)).ToString(); if (!text.Contains("Chapters")) { toBeRemove.Add(current); continue; } text = (await TaskAsync.RunProcessAsync(eac3toPath, $"\"{location}\" {current.SourceIndex}) chapters.txt", workingPath)).ToString(); if (!text.Contains("Creating file \"chapters.txt\"...") && !text.Contains("Done!")) { OnLog?.Invoke(text); throw new Exception("Error creating chapters file."); } current.Chapters = OgmData.GetChapterInfo(File.ReadAllBytes(chapterPath).GetUTFString()).Chapters; if (current.Chapters.First().Name != string.Empty) { continue; } var chapterName = ChapterName.GetChapterName(); current.Chapters.ForEach(chapter => chapter.Name = chapterName()); } toBeRemove.ForEach(item => list.Remove(item)); if (File.Exists(chapterPath)) { File.Delete(chapterPath); } if (File.Exists(logPath)) { File.Delete(logPath); } return(new KeyValuePair <string, BDMVGroup>(bdmvTitle, list)); }
private void FrmLoadFiles_FormClosing(object sender, FormClosingEventArgs e) { RegistryStorage.Save(Location.ToString(), @"Software\RPChecker", "LoadLocation"); }
static void Main(string[] args) { Application.EnableVisualStyles(); Application.SetCompatibleTextRenderingDefault(false); Updater.Utils.SoftwareName = "AutoTorrentInspection"; Updater.Utils.RepoName = "vcb-s/Auto-Torrent-Inspection"; Updater.Utils.CurrentVersion = Assembly.GetExecutingAssembly().GetName().Version; Logger.StoreLogMessages = true; Logger.LoggerHandlerManager.AddHandler(new DebugConsoleLoggerHandler()); if (!IsSupportedRuntimeVersion()) { var ret = Notification.ShowInfo("需要 .Net4.8 或以上版本以保证所有功能正常运作,是否不再提示?"); System.Diagnostics.Process.Start("https://dotnet.microsoft.com/download/dotnet-framework"); if (ret == DialogResult.Yes) { RegistryStorage.Save("False", name: "DoVersionCheck"); } } if (!File.Exists("config.json")) { Logger.Log("Extract default config file to current directory"); File.WriteAllText("config.json", new Configuration().ToString()); } else { try { var updateConfigFile = false; Configuration config, defaultConfig; using (var input = new StreamReader("config.json")) { config = JSON.Deserialize <Configuration>(input); defaultConfig = new Configuration(); if (defaultConfig.Version > config.Version) { updateConfigFile = true; } } if (updateConfigFile) { File.WriteAllText("config.json", config.ToString()); Logger.Log($"Update the config file version from {config.Version}->{defaultConfig.Version}"); } } catch (Exception e) { Logger.Log(e); Notification.ShowError("无法读取配置文件", e); } #if DEBUG File.WriteAllText("config.json", new Configuration().ToString()); Logger.Log("Config file is now up to date"); #endif } if (args.Length == 0) { Application.Run(new Form1()); } else { var argsFull = string.Join(" ", args); //argsFull = "\"" + argsFull + "\""; Application.Run(new Form1(argsFull)); } }
private void Form1_FormClosing(object sender, FormClosingEventArgs e) { _coreProcess.Kill(); RegistryStorage.Save(Location.ToString(), @"Software\RPChecker", "Location"); }