Files
FileFlowsPlugins/ComicNodes/Helpers/ComicExtractor.cs
John Andrews e6813b8e23 FF-273 - added auto crop image node
fixed issue with mp4 image based subtitles
2022-08-09 11:24:07 +12:00

39 lines
1.5 KiB
C#

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace FileFlows.ComicNodes.Helpers;
internal class ComicExtractor
{
internal static bool Extract(NodeParameters args, string file, string destinationPath, bool halfProgress, CancellationToken cancellation)
{
string currentFormat = new FileInfo(args.WorkingFile).Extension;
if (string.IsNullOrEmpty(currentFormat))
{
args.Logger?.ELog("Could not detect format for: " + args.WorkingFile);
return false;
}
if (currentFormat[0] == '.')
currentFormat = currentFormat[1..]; // remove the dot
currentFormat = currentFormat.ToUpper();
Directory.CreateDirectory(destinationPath);
args.Logger?.ILog("Extracting comic pages to: " + destinationPath);
if (currentFormat == "PDF")
PdfHelper.Extract(args, args.WorkingFile, destinationPath, "page", halfProgress: halfProgress, cancellation: cancellation);
else if (currentFormat == "CBZ")
ZipHelper.Extract(args, args.WorkingFile, destinationPath, halfProgress: halfProgress);
else if (currentFormat == "CB7" || currentFormat == "CBR" || currentFormat == "GZ" || currentFormat == "BZ2")
GenericExtractor.Extract(args, args.WorkingFile, destinationPath, halfProgress: halfProgress);
else
throw new Exception("Unknown format:" + currentFormat);
return true;
}
}