updated comic nodes to look for unrar variable

This commit is contained in:
John Andrews
2022-08-09 17:59:22 +12:00
parent 351b4bf120
commit 07ce21d3bf
3 changed files with 11 additions and 9 deletions

View File

@@ -50,7 +50,7 @@ public class ComicConverter: Node
var metadata = new Dictionary<string, object>();
int pageCount = GetPageCount(currentFormat, args.WorkingFile);
int pageCount = GetPageCount(args, currentFormat, args.WorkingFile);
metadata.Add("Format", currentFormat);
metadata.Add("Pages", pageCount);
args.RecordStatistic("COMIC_FORMAT", currentFormat);
@@ -83,7 +83,7 @@ public class ComicConverter: Node
return base.Cancel();
}
private int GetPageCount(string format, string workingFile)
private int GetPageCount(NodeParameters args, string format, string workingFile)
{
if (format == null)
return 0;
@@ -93,7 +93,7 @@ public class ComicConverter: Node
case "PDF":
return Helpers.PdfHelper.GetPageCount(workingFile);
default:
return Helpers.GenericExtractor.GetImageCount(workingFile);
return Helpers.GenericExtractor.GetImageCount(args, workingFile);
}
}
@@ -116,7 +116,7 @@ public class ComicConverter: Node
var metadata = new Dictionary<string, object>();
metadata.Add("Format", format);
metadata.Add("Pages", GetPageCount(format, file));
metadata.Add("Pages", GetPageCount(args, format, file));
args.SetMetadata(metadata);
args.Logger?.ILog("Setting metadata: " + format);

View File

@@ -35,7 +35,7 @@ internal class GenericExtractor
args?.PartPercentageUpdate(halfProgress ? 50 : 100);
}
internal static int GetImageCount(string workingFile)
internal static int GetImageCount(NodeParameters args, string workingFile)
{
bool isRar = workingFile.ToLowerInvariant().EndsWith(".cbr");
try
@@ -47,7 +47,7 @@ internal class GenericExtractor
}
catch(Exception ex) when (isRar && ex.Message.Contains("Unknown Rar Header"))
{
return UnrarCommandLine.GetImageCount(workingFile);
return UnrarCommandLine.GetImageCount(args, workingFile);
}
}
}

View File

@@ -17,7 +17,8 @@ internal class UnrarCommandLine
args?.PartPercentageUpdate(halfProgress ? 50 : 0);
var process = new Process();
process.StartInfo.FileName = "unrar";
string unrar = args.GetToolPath("unrar")?.EmptyAsNull() ?? "unrar";
process.StartInfo.FileName = unrar;
process.StartInfo.ArgumentList.Add("x");
process.StartInfo.ArgumentList.Add("-o+");
process.StartInfo.ArgumentList.Add(workingFile);
@@ -44,12 +45,13 @@ internal class UnrarCommandLine
args?.PartPercentageUpdate(halfProgress ? 50 : 100);
}
internal static int GetImageCount(string workingFile)
internal static int GetImageCount(NodeParameters args, string workingFile)
{
var rgxImages = new Regex(@"\.(jpeg|jpg|jpe|png|bmp|tiff|webp|gif)$", RegexOptions.IgnoreCase);
var process = new Process();
process.StartInfo.FileName = "unrar";
string unrar = args.GetToolPath("unrar")?.EmptyAsNull() ?? "unrar";
process.StartInfo.FileName = unrar;
process.StartInfo.ArgumentList.Add("list");
process.StartInfo.ArgumentList.Add(workingFile);
process.StartInfo.UseShellExecute = false;