mirror of
https://github.com/revenz/FileFlowsPlugins.git
synced 2025-12-30 22:30:16 -06:00
FF-1524: Added more comic options
This commit is contained in:
@@ -177,16 +177,32 @@ public class ComicConverter: Node
|
||||
|
||||
if (DeleteNonPageImages)
|
||||
{
|
||||
List<string> nonPages = new();
|
||||
float imageCount = 0;
|
||||
foreach (var file in Directory.GetFiles(destinationPath, "*.*", SearchOption.AllDirectories))
|
||||
{
|
||||
if(rgxImages.IsMatch(file) == false)
|
||||
continue;
|
||||
imageCount++;
|
||||
string nameNoExtension = FileHelper.GetShortFileName(file);
|
||||
nameNoExtension = nameNoExtension[..nameNoExtension.LastIndexOf(".", StringComparison.Ordinal)];
|
||||
if (Regex.IsMatch(nameNoExtension, @"[\d]{2,}$") == false)
|
||||
{
|
||||
args.Logger?.ILog("Deleting non page image: " + file);
|
||||
File.Delete(file);
|
||||
nonPages.Add(file);
|
||||
}
|
||||
}
|
||||
|
||||
if (nonPages.Any())
|
||||
{
|
||||
float percent = ((float)nonPages.Count) / imageCount * 100;
|
||||
if (percent < 10)
|
||||
{
|
||||
// only delete if the number of non images is low, we dont want to mistakenly identify all pages as non images
|
||||
foreach (var file in nonPages)
|
||||
{
|
||||
args.Logger?.ILog("Deleting non page image: " + file);
|
||||
File.Delete(file);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -194,7 +194,9 @@ public class CreateComicInfo : Node
|
||||
else
|
||||
{
|
||||
// Pad the number with leading zeros based on the specified number of digits
|
||||
string paddedNumber = info.Number.Value.ToString().PadLeft(issueDigits, '0');
|
||||
string paddedNumber = info.Number < 0 ?
|
||||
("-" + info.Number.Value.ToString()[1..].PadLeft(issueDigits -1, '0')) :
|
||||
info.Number.Value.ToString().PadLeft(issueDigits, '0');
|
||||
|
||||
// Add the padded number to the name
|
||||
name += $" - #{paddedNumber}";
|
||||
@@ -268,8 +270,9 @@ public class CreateComicInfo : Node
|
||||
if (parts.Length < 2)
|
||||
{
|
||||
// remove any junk
|
||||
shortname = Regex.Replace(shortname, @"\(([\-]?\d+)\)", "$1").Trim();
|
||||
shortname = Regex.Replace(shortname, @"\s*\([^)]*\)\s*", " ").Trim();
|
||||
var lastChanceMatch = Regex.Match(shortname, @"(\d)+$");
|
||||
var lastChanceMatch = Regex.Match(shortname, @"([\-]?\d)+$");
|
||||
if(lastChanceMatch.Success)
|
||||
{
|
||||
info.Number = int.Parse(lastChanceMatch.Value);
|
||||
|
||||
@@ -119,6 +119,31 @@ public class ComicInfoTests : TestBase
|
||||
Assert.AreEqual("X-Man - #045.cbz", name.Value);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void MinusOne()
|
||||
{
|
||||
var result = CreateComicInfo.GetInfo(Logger,
|
||||
"/home/john/Comics/Marvel/X-Men/Cable (1993)/Cable (-1) (1997) (Digital) (Dark-Star).cbz",
|
||||
"/home/john/Comics",
|
||||
true);
|
||||
|
||||
TestContext.WriteLine(Logger.ToString());
|
||||
|
||||
Assert.IsFalse(result.IsFailed);
|
||||
var info = result.Value;
|
||||
Assert.IsNotNull(info);
|
||||
Assert.AreEqual("Marvel", info.Publisher);
|
||||
Assert.AreEqual("Cable (1993)", info.Series);
|
||||
Assert.AreEqual(-1, info.Number);
|
||||
|
||||
var xml = CreateComicInfo.SerializeToXml(info);
|
||||
Assert.IsFalse(string.IsNullOrWhiteSpace(xml));
|
||||
TestContext.WriteLine(new string('-', 70));
|
||||
TestContext.WriteLine(xml);
|
||||
|
||||
var name = CreateComicInfo.GetNewName(info, "cbz", 3);
|
||||
Assert.AreEqual("Cable (1993) - #-01.cbz", name.Value);
|
||||
}
|
||||
|
||||
[TestMethod]
|
||||
public void NameAndNumber2()
|
||||
|
||||
Reference in New Issue
Block a user