add folder output option (#1430)

This commit is contained in:
Alex Xu authored and GitHub committed 2026-09-02 16:56:42 -07:00
1 parent 8f191e604b
commit 55468019dd
2 files changed
+20 -3

No files matched your search

+9 -1
View File
@@ -127,6 +127,8 @@ class Icons:
self.MOBIFormat.addPixmap(QPixmap(":/Formats/icons/MOBI.png"), QIcon.Mode.Normal, QIcon.State.Off) self.MOBIFormat.addPixmap(QPixmap(":/Formats/icons/MOBI.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.CBZFormat = QIcon() self.CBZFormat = QIcon()
self.CBZFormat.addPixmap(QPixmap(":/Formats/icons/CBZ.png"), QIcon.Mode.Normal, QIcon.State.Off) self.CBZFormat.addPixmap(QPixmap(":/Formats/icons/CBZ.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.FOLDERFormat = QIcon()
self.FOLDERFormat.addPixmap(QPixmap(":/Formats/icons/CBZ.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.EPUBFormat = QIcon() self.EPUBFormat = QIcon()
self.EPUBFormat.addPixmap(QPixmap(":/Formats/icons/EPUB.png"), QIcon.Mode.Normal, QIcon.State.Off) self.EPUBFormat.addPixmap(QPixmap(":/Formats/icons/EPUB.png"), QIcon.Mode.Normal, QIcon.State.Off)
self.KFXFormat = QIcon() self.KFXFormat = QIcon()
@@ -442,6 +444,9 @@ class WorkerThread(QThread):
if gui_current_format == 'CBZ': if gui_current_format == 'CBZ':
MW.addMessage.emit('Creating CBZ files', 'info', False) MW.addMessage.emit('Creating CBZ files', 'info', False)
GUI.progress.content = 'Creating CBZ files' GUI.progress.content = 'Creating CBZ files'
elif gui_current_format == 'FOLDER':
MW.addMessage.emit('Creating folders', 'info', False)
GUI.progress.content = 'Creating folders'
elif gui_current_format == 'PDF': elif gui_current_format == 'PDF':
MW.addMessage.emit('Creating PDF files', 'info', False) MW.addMessage.emit('Creating PDF files', 'info', False)
GUI.progress.content = 'Creating PDF files' GUI.progress.content = 'Creating PDF files'
@@ -487,6 +492,8 @@ class WorkerThread(QThread):
GUI.progress.content = '' GUI.progress.content = ''
if gui_current_format == 'CBZ': if gui_current_format == 'CBZ':
MW.addMessage.emit('Creating CBZ files... <b>Done!</b>', 'info', True) MW.addMessage.emit('Creating CBZ files... <b>Done!</b>', 'info', True)
elif gui_current_format == 'FOLDER':
MW.addMessage.emit('Creating folders... <b>Done!</b>', 'info', True)
elif gui_current_format == 'PDF': elif gui_current_format == 'PDF':
MW.addMessage.emit('Creating PDF files... <b>Done!</b>', 'info', True) MW.addMessage.emit('Creating PDF files... <b>Done!</b>', 'info', True)
else: else:
@@ -1061,7 +1068,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.upscaleBox.setChecked(True) GUI.upscaleBox.setChecked(True)
elif not GUI.webtoonBox.isChecked(): elif not GUI.webtoonBox.isChecked():
GUI.chunkSizeCheckBox.setEnabled(True) GUI.chunkSizeCheckBox.setEnabled(True)
if GUI.formats[str(GUI.formatBox.currentText())]['format'] in ('CBZ', 'PDF') and not GUI.webtoonBox.isChecked(): if GUI.formats[str(GUI.formatBox.currentText())]['format'] in ('CBZ', 'FOLDER', 'PDF') and not GUI.webtoonBox.isChecked():
self.addMessage("Partially check W/B Margins if you don't want KCC to extend the image margins.", 'info') self.addMessage("Partially check W/B Margins if you don't want KCC to extend the image margins.", 'info')
GUI.borderBox.setCheckState(Qt.CheckState.PartiallyChecked) GUI.borderBox.setCheckState(Qt.CheckState.PartiallyChecked)
else: else:
@@ -1359,6 +1366,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
"MOBI/AZW3": {'icon': 'MOBI', 'format': 'MOBI'}, "MOBI/AZW3": {'icon': 'MOBI', 'format': 'MOBI'},
"EPUB": {'icon': 'EPUB', 'format': 'EPUB'}, "EPUB": {'icon': 'EPUB', 'format': 'EPUB'},
"CBZ": {'icon': 'CBZ', 'format': 'CBZ'}, "CBZ": {'icon': 'CBZ', 'format': 'CBZ'},
"Folder": {'icon': 'FOLDER', 'format': 'FOLDER'},
"PDF": {'icon': 'EPUB', 'format': 'PDF'}, "PDF": {'icon': 'EPUB', 'format': 'PDF'},
"PDF (200MB limit)": {'icon': 'EPUB', 'format': 'PDF-200MB'}, "PDF (200MB limit)": {'icon': 'EPUB', 'format': 'PDF-200MB'},
"KFX (Send to Kindle EPUB)": {'icon': 'KFX', 'format': 'KFX'}, "KFX (Send to Kindle EPUB)": {'icon': 'KFX', 'format': 'KFX'},
+11 -2
View File
@@ -1058,6 +1058,8 @@ def getWorkFolder(afile, options, workdir=None):
def getOutputFilename(srcpath, wantedname, ext, tomenumber): def getOutputFilename(srcpath, wantedname, ext, tomenumber):
if options.format == 'CBZ' and options.skip_zip:
ext = ''
source_path = Path(srcpath) source_path = Path(srcpath)
if srcpath[-1] == os.path.sep: if srcpath[-1] == os.path.sep:
srcpath = srcpath[:-1] srcpath = srcpath[:-1]
@@ -1093,10 +1095,10 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
filename = source_path.with_name(name) filename = source_path.with_name(name)
else: else:
filename = os.path.splitext(srcpath)[0] + tomenumber + ext filename = os.path.splitext(srcpath)[0] + tomenumber + ext
if os.path.isfile(filename): if os.path.exists(filename):
counter = 0 counter = 0
basename = os.path.splitext(filename)[0] basename = os.path.splitext(filename)[0]
while os.path.isfile(basename + '_kcc' + str(counter) + ext): while os.path.exists(basename + '_kcc' + str(counter) + ext):
counter += 1 counter += 1
filename = basename + '_kcc' + str(counter) + ext filename = basename + '_kcc' + str(counter) + ext
elif options.format == 'MOBI' and ext == '.epub': elif options.format == 'MOBI' and ext == '.epub':
@@ -1430,6 +1432,9 @@ def slugify(value, options, is_natural_sorted):
return value return value
def makeZIP(zipfilename, basedir, job_progress='', isepub=False): def makeZIP(zipfilename, basedir, job_progress='', isepub=False):
if options.format == 'CBZ' and options.skip_zip:
os.rename(basedir, zipfilename)
return zipfilename
start = perf_counter() start = perf_counter()
if SEVENZIP in available_archive_tools(): if SEVENZIP in available_archive_tools():
if isepub: if isepub:
@@ -1639,6 +1644,10 @@ def checkOptions(options):
options.keep_epub = True options.keep_epub = True
options.format = 'MOBI' options.format = 'MOBI'
options.kfx = False options.kfx = False
options.skip_zip = False
if options.format == 'FOLDER':
options.format = 'CBZ'
options.skip_zip = True
if options.format == 'Auto': if options.format == 'Auto':
if options.profile in ['KDX']: if options.profile in ['KDX']:
options.format = 'CBZ' options.format = 'CBZ'