1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-12 17:26:23 +00:00

keep epub file when selecting another type of output file

* Keep epub file when selecting another type of output file
This commit is contained in:
darodi
2022-11-29 00:46:55 +01:00
parent 6987c8b1cd
commit a7a01f8269
3 changed files with 23 additions and 11 deletions

View File

@@ -122,7 +122,7 @@ Options:
Comic title [Default=filename or directory name]
-f FORMAT, --format=FORMAT
Output format (Available options: Auto, MOBI, EPUB,
CBZ, KFX) [Default=Auto]
CBZ, KFX, MOBI+EPUB, KFX+EPUB) [Default=Auto]
-b BATCHSPLIT, --batchsplit=BATCHSPLIT
Split output into multiple files. 0: Don't split 1:
Automatic mode 2: Consider every subdirectory as

View File

@@ -116,6 +116,10 @@ class Icons:
self.EPUBFormat.addPixmap(QtGui.QPixmap(":/Formats/icons/EPUB.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.KFXFormat = QtGui.QIcon()
self.KFXFormat.addPixmap(QtGui.QPixmap(":/Formats/icons/KFX.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.MOBIEPUBFormat = QtGui.QIcon()
self.MOBIEPUBFormat.addPixmap(QtGui.QPixmap(":/Formats/icons/MOBI.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.KFXEPUBFormat = QtGui.QIcon()
self.KFXEPUBFormat.addPixmap(QtGui.QPixmap(":/Formats/icons/KFX.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
self.info = QtGui.QIcon()
self.info.addPixmap(QtGui.QPixmap(":/Status/icons/info.png"), QtGui.QIcon.Normal, QtGui.QIcon.Off)
@@ -315,8 +319,7 @@ class WorkerThread(QtCore.QThread):
jobargv = list(argv)
jobargv.append(job)
try:
comic2ebook.options = copy(options)
comic2ebook.checkOptions()
comic2ebook.options = comic2ebook.checkOptions(copy(options))
outputPath = comic2ebook.makeBook(job, self)
MW.hideProgressBar.emit()
except UserWarning as warn:
@@ -361,7 +364,7 @@ class WorkerThread(QtCore.QThread):
MW.addMessage.emit('Creating CBZ files... <b>Done!</b>', 'info', True)
else:
MW.addMessage.emit('Creating EPUB files... <b>Done!</b>', 'info', True)
if str(GUI.formatBox.currentText()) == 'MOBI/AZW3':
if str(GUI.formatBox.currentText()) == 'MOBI/AZW3' or str(GUI.formatBox.currentText()) == 'MOBI+EPUB':
MW.progressBarTick.emit('Creating MOBI files')
MW.progressBarTick.emit(str(len(outputPath) * 2 + 1))
MW.progressBarTick.emit('tick')
@@ -1064,8 +1067,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
GUI.deviceBox.addItem(self.icons.deviceKobo, profile)
else:
GUI.deviceBox.addItem(self.icons.deviceKindle, profile)
for f in ['MOBI/AZW3', 'EPUB', 'CBZ', 'KFX']:
GUI.formatBox.addItem(eval('self.icons.' + f.replace('/AZW3', '') + 'Format'), f)
for f in ['MOBI/AZW3', 'EPUB', 'CBZ', 'KFX', 'MOBI+EPUB', 'KFX+EPUB']:
GUI.formatBox.addItem(eval('self.icons.' + f.replace('/AZW3', '').replace('+', '') + 'Format'), f)
if self.lastDevice > GUI.deviceBox.count():
self.lastDevice = 0
if profilesGUI[self.lastDevice] == "Separator":

View File

@@ -68,7 +68,7 @@ def main(argv=None):
for source in sources:
source = source.rstrip('\\').rstrip('/')
options = copy(optionstemplate)
checkOptions()
options = checkOptions(options)
if len(sources) > 1:
print('Working on ' + source + '...')
makeBook(source)
@@ -925,7 +925,8 @@ def makeParser():
outputOptions.add_option("-t", "--title", action="store", dest="title", default="defaulttitle",
help="Comic title [Default=filename or directory name]")
outputOptions.add_option("-f", "--format", action="store", dest="format", default="Auto",
help="Output format (Available options: Auto, MOBI, EPUB, CBZ, KFX) [Default=Auto]")
help="Output format (Available options: Auto, MOBI, EPUB, CBZ, KFX, MOBI+EPUB, KFX+EPUB) "
"[Default=Auto]")
outputOptions.add_option("-b", "--batchsplit", type="int", dest="batchsplit", default="0",
help="Split output into multiple files. 0: Don't split 1: Automatic mode "
"2: Consider every subdirectory as separate volume [Default=0]")
@@ -972,11 +973,17 @@ def makeParser():
return psr
def checkOptions():
global options
def checkOptions(options):
options.panelview = True
options.iskindle = False
options.bordersColor = None
options.keep_epub = False
if options.format == 'MOBI+EPUB':
options.keep_epub = True
options.format = 'MOBI'
if options.format == 'KFX+EPUB':
options.keep_epub = True
options.format = 'KFX'
options.kfx = False
if options.format == 'Auto':
if options.profile in ['K1', 'K2', 'K34', 'K578', 'KPW', 'KPW5', 'KV', 'KO']:
@@ -1032,6 +1039,7 @@ def checkOptions():
image.ProfileData.Profiles["Custom"] = newProfile
options.profile = "Custom"
options.profileData = image.ProfileData.Profiles[options.profile]
return options
def checkTools(source):
@@ -1166,7 +1174,8 @@ def makeBook(source, qtgui=None):
def makeMOBIFix(item, uuid):
os.remove(item)
if not options.keep_epub:
os.remove(item)
mobiPath = item.replace('.epub', '.mobi')
move(mobiPath, mobiPath + '_toclean')
try: