diff options
Diffstat (limited to 'kindlecomicconverter/KCC_gui.py')
-rw-r--r-- | kindlecomicconverter/KCC_gui.py | 38 |
1 files changed, 38 insertions, 0 deletions
diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 50e91dd..8765b7e 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -285,7 +285,44 @@ class WorkerThread(QtCore.QThread): # Make sure that we don't consider any system message as job to do if GUI.jobList.item(i).icon().isNull(): currentJobs.append(str(GUI.jobList.item(i).text())) + GUI.jobList.clear() + + #TODO: REname outputjoin to outputmerge + #NEEDS TO BE CBR FILENAME (SO IT CAN BE EXTRACTED) + if GUI.outputMerge.isChecked(): + import zipfile + from tempfile import TemporaryDirectory + + MW.addMessage.emit('Merging all files...', 'info', False) + GUI.progress.content = 'Merging all files' + + zf = zipfile.ZipFile(currentJobs[0].split('.', 1)[0] + "-MERGED.cbz", "w") + + #we should join cbz before converting + with TemporaryDirectory('', 'KCC-') as workdir: + for job in currentJobs: + + #unzip all in tmp folder + name = os.path.splitext(os.path.basename(job))[0] + extracted_dir = workdir + "/" + name + + with zipfile.ZipFile(job, 'r') as zip_ref: + zip_ref.extractall(extracted_dir) + + for dirname, subdirs, files in os.walk(extracted_dir): + for filename in files: + p = os.path.join(dirname, filename) + arcname = name+"/"+filename + zf.write(p, arcname=arcname)#change arcname to just the chapter (no tmp folder) + + zf.close() + + currentJobs = [zf.filename] + + GUI.progress.content = '' + + #GUI.jobList.clear() for job in currentJobs: sleep(0.5) if not self.conversionAlive: @@ -396,6 +433,7 @@ class WorkerThread(QtCore.QThread): except Exception: pass MW.addMessage.emit('Processing MOBI files... <b>Done!</b>', 'info', True) + #print(str(currentJobs)) k = kindle.Kindle() if k.path and k.coverSupport: for item in outputPath: |