From 02d1d716fe2e5320cdc3b9b4d5972fc2e41951f5 Mon Sep 17 00:00:00 2001 From: da3dsoul Date: Thu, 21 Sep 2017 15:09:44 -0400 Subject: [PATCH] Minor Cleanup in AVDump --- Shoko.Server/Utilities/AVDumpHelper.cs | 38 +++++++++++++------------- 1 file changed, 19 insertions(+), 19 deletions(-) diff --git a/Shoko.Server/Utilities/AVDumpHelper.cs b/Shoko.Server/Utilities/AVDumpHelper.cs index ae70bc081..f89da88e6 100644 --- a/Shoko.Server/Utilities/AVDumpHelper.cs +++ b/Shoko.Server/Utilities/AVDumpHelper.cs @@ -12,14 +12,14 @@ using File = Pri.LongPath.File; using Path = Pri.LongPath.Path; -namespace Shoko.Server.Utilities +namespace Shoko.Server { - public class AVDumpHelper + public static class AVDumpHelper { public static readonly string destination = Path.Combine(ServerSettings.ApplicationPath, "Utilities"); public static readonly string avdumpRarDestination = Path.Combine(destination, "avdump2.rar"); - public static readonly string AVDump2URL = @"http://static.anidb.net/client/avdump2/avdump2_6714.rar"; + public const string AVDump2URL = @"http://static.anidb.net/client/avdump2/avdump2_6714.rar"; public static readonly string avdumpDestination = Path.Combine(destination, "AVDump2CL.exe"); public static bool GetAndExtractAVDump() @@ -36,13 +36,11 @@ private static bool ExtractAVDump() using (var archive = RarArchive.Open(avdumpRarDestination)) { foreach (var entry in archive.Entries.Where(entry => !entry.IsDirectory)) - { entry.WriteToDirectory(destination, new ExtractionOptions() { ExtractFullPath = true, Overwrite = true }); - } } File.Delete(avdumpRarDestination); } @@ -81,9 +79,7 @@ public static void CopyStream(Stream input, Stream output) byte[] buffer = new byte[8 * 1024]; int len; while ((len = input.Read(buffer, 0, buffer.Length)) > 0) - { output.Write(buffer, 0, len); - } } public static string DumpFile(int vid) @@ -107,22 +103,26 @@ public static string DumpFile(string file) if (!File.Exists(file)) return "Could not find Video File: " + file; - //Create process - Process pProcess = new Process(); - pProcess.StartInfo.FileName = avdumpDestination; - //strCommandParameters are parameters to pass to program string fileName = (char) 34 + file + (char) 34; - pProcess.StartInfo.Arguments = - $@" --Auth={ServerSettings.AniDB_Username}:{ServerSettings.AniDB_AVDumpKey} --LPort={ - ServerSettings.AniDB_AVDumpClientPort - } --PrintEd2kLink -t {fileName}"; + //Create process + Process pProcess = new Process + { + StartInfo = + { + FileName = avdumpDestination, + Arguments = + $@" --Auth={ServerSettings.AniDB_Username}:{ServerSettings.AniDB_AVDumpKey} --LPort={ + ServerSettings.AniDB_AVDumpClientPort + } --PrintEd2kLink -t {fileName}", + UseShellExecute = false, + WindowStyle = ProcessWindowStyle.Hidden, + RedirectStandardOutput = true, + CreateNoWindow = true + } + }; - pProcess.StartInfo.UseShellExecute = false; - pProcess.StartInfo.WindowStyle = ProcessWindowStyle.Hidden; - pProcess.StartInfo.RedirectStandardOutput = true; - pProcess.StartInfo.CreateNoWindow = true; pProcess.Start(); string strOutput = pProcess.StandardOutput.ReadToEnd();