mirror of
https://github.com/ciromattia/kcc
synced 2026-09-09 20:37:06 +00:00
add folder output option (#1430)
This commit is contained in:
@@ -127,6 +127,8 @@ class Icons:
|
||||
self.MOBIFormat.addPixmap(QPixmap(":/Formats/icons/MOBI.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
self.CBZFormat = QIcon()
|
||||
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.addPixmap(QPixmap(":/Formats/icons/EPUB.png"), QIcon.Mode.Normal, QIcon.State.Off)
|
||||
self.KFXFormat = QIcon()
|
||||
@@ -442,6 +444,9 @@ class WorkerThread(QThread):
|
||||
if gui_current_format == 'CBZ':
|
||||
MW.addMessage.emit('Creating CBZ files', 'info', False)
|
||||
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':
|
||||
MW.addMessage.emit('Creating PDF files', 'info', False)
|
||||
GUI.progress.content = 'Creating PDF files'
|
||||
@@ -487,6 +492,8 @@ class WorkerThread(QThread):
|
||||
GUI.progress.content = ''
|
||||
if gui_current_format == 'CBZ':
|
||||
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':
|
||||
MW.addMessage.emit('Creating PDF files... <b>Done!</b>', 'info', True)
|
||||
else:
|
||||
@@ -1061,7 +1068,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
GUI.upscaleBox.setChecked(True)
|
||||
elif not GUI.webtoonBox.isChecked():
|
||||
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')
|
||||
GUI.borderBox.setCheckState(Qt.CheckState.PartiallyChecked)
|
||||
else:
|
||||
@@ -1359,6 +1366,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
|
||||
"MOBI/AZW3": {'icon': 'MOBI', 'format': 'MOBI'},
|
||||
"EPUB": {'icon': 'EPUB', 'format': 'EPUB'},
|
||||
"CBZ": {'icon': 'CBZ', 'format': 'CBZ'},
|
||||
"Folder": {'icon': 'FOLDER', 'format': 'FOLDER'},
|
||||
"PDF": {'icon': 'EPUB', 'format': 'PDF'},
|
||||
"PDF (200MB limit)": {'icon': 'EPUB', 'format': 'PDF-200MB'},
|
||||
"KFX (Send to Kindle EPUB)": {'icon': 'KFX', 'format': 'KFX'},
|
||||
|
||||
@@ -1058,6 +1058,8 @@ def getWorkFolder(afile, options, workdir=None):
|
||||
|
||||
|
||||
def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
||||
if options.format == 'CBZ' and options.skip_zip:
|
||||
ext = ''
|
||||
source_path = Path(srcpath)
|
||||
if srcpath[-1] == os.path.sep:
|
||||
srcpath = srcpath[:-1]
|
||||
@@ -1093,10 +1095,10 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
|
||||
filename = source_path.with_name(name)
|
||||
else:
|
||||
filename = os.path.splitext(srcpath)[0] + tomenumber + ext
|
||||
if os.path.isfile(filename):
|
||||
if os.path.exists(filename):
|
||||
counter = 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
|
||||
filename = basename + '_kcc' + str(counter) + ext
|
||||
elif options.format == 'MOBI' and ext == '.epub':
|
||||
@@ -1430,6 +1432,9 @@ def slugify(value, options, is_natural_sorted):
|
||||
return value
|
||||
|
||||
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()
|
||||
if SEVENZIP in available_archive_tools():
|
||||
if isepub:
|
||||
@@ -1639,6 +1644,10 @@ def checkOptions(options):
|
||||
options.keep_epub = True
|
||||
options.format = 'MOBI'
|
||||
options.kfx = False
|
||||
options.skip_zip = False
|
||||
if options.format == 'FOLDER':
|
||||
options.format = 'CBZ'
|
||||
options.skip_zip = True
|
||||
if options.format == 'Auto':
|
||||
if options.profile in ['KDX']:
|
||||
options.format = 'CBZ'
|
||||
|
||||
Reference in New Issue
Block a user