Skip to content

Commit

Permalink
Minor Cleanup in AVDump
Browse files Browse the repository at this point in the history
  • Loading branch information
da3dsoul committed Sep 21, 2017
1 parent d5e2dee commit 02d1d71
Showing 1 changed file with 19 additions and 19 deletions.
38 changes: 19 additions & 19 deletions Shoko.Server/Utilities/AVDumpHelper.cs
Original file line number Diff line number Diff line change
Expand Up @@ -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()
Expand All @@ -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);
}
Expand Down Expand Up @@ -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)
Expand All @@ -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();

Expand Down

0 comments on commit 02d1d71

Please sign in to comment.