Browse Source

add password and ban prefix

HOME 2 months ago
parent
commit
35ca175789
2 changed files with 30 additions and 3 deletions
  1. 29 1
      SevenRepacker/Program.cs
  2. 1 2
      SevenRepacker/Properties/launchSettings.json

+ 29 - 1
SevenRepacker/Program.cs

@@ -18,8 +18,11 @@ namespace SevenRepacker
             SevenZipBase.SetLibraryPath(Path.Combine(AppDomain.CurrentDomain.BaseDirectory, "7z.dll"));
 #endif
             string outDir = null;
+            var banPrefix = new List<string>();
+            string password = null;
 
             var inputFiles = new List<string>();
+
             foreach (var arg in args)
             {
                 if (arg.StartsWith('/') && arg.Contains(':') && arg[^1] != ':')
@@ -35,6 +38,12 @@ namespace SevenRepacker
                                 return -1;
                             }
                             break;
+                        case "ban-prefix":
+                            banPrefix.Add(kv[1]);
+                            break;
+                        case "pass":
+                            password = kv[1];
+                            break;
                     }
                     continue;
                 }
@@ -67,7 +76,10 @@ namespace SevenRepacker
                 Console.WriteLine($"  In: {inputFilePath}");
                 Console.WriteLine($" Out: {outputFilePath}");
 
-                using var inputArchive = new SevenZipExtractor(inputFilePath);
+                using var inputArchive = password == null
+                    ? new SevenZipExtractor(inputFilePath)
+                    : new SevenZipExtractor(inputFilePath, password);
+
                 var inputItems = inputArchive.ArchiveFileData.OrderBy(p => p.Index).ToArray();
 
                 var streamDict = new Dictionary<string, Stream>();
@@ -75,6 +87,22 @@ namespace SevenRepacker
                 foreach (var item in inputItems)
                 {
                     if (item.IsDirectory) continue;
+                    var ban = false;
+
+                    foreach (var prefix in banPrefix)
+                    {
+                        if (item.FileName.StartsWith(prefix))
+                        {
+                            ban = true;
+                            break;
+                        }
+                    }
+
+                    if (ban)
+                    {
+                        Console.WriteLine($"Banned: {item.FileName}");
+                        continue;
+                    }
 
                     streamDict.Add(item.FileName, new BridgeStream(1, (long?)item.Size, inputArchive, item.Index));
                 }

+ 1 - 2
SevenRepacker/Properties/launchSettings.json

@@ -1,8 +1,7 @@
 {
   "profiles": {
     "SevenRepacker": {
-      "commandName": "Project",
-      "commandLineArgs": "\"L:\\Archive\\Anime\\202107-Isekai Cheat Magician 13 [OVA][1080P][MMSUB].7z\" \"L:\\Archive\\Anime\\202107-舍管.7z\" /out-dir:z:/"
+      "commandName": "Project"
     }
   }
 }