mirror of
https://github.com/ciromattia/kcc
synced 2026-09-21 18:27:08 +00:00
implement custom covers for webtoon and fusion (#1438)
This commit is contained in:
@@ -418,6 +418,7 @@ class WorkerThread(QThread):
|
|||||||
if GUI.jobList.item(i).icon().isNull():
|
if GUI.jobList.item(i).icon().isNull():
|
||||||
currentJobs.append(str(GUI.jobList.item(i).text()))
|
currentJobs.append(str(GUI.jobList.item(i).text()))
|
||||||
GUI.jobList.clear()
|
GUI.jobList.clear()
|
||||||
|
fusion_cover_path = None
|
||||||
if options.filefusion:
|
if options.filefusion:
|
||||||
bookDir = []
|
bookDir = []
|
||||||
MW.addMessage.emit('Attempting file fusion', 'info', False)
|
MW.addMessage.emit('Attempting file fusion', 'info', False)
|
||||||
@@ -429,7 +430,8 @@ class WorkerThread(QThread):
|
|||||||
if options.output is None:
|
if options.output is None:
|
||||||
options.output = fusion_source_parent
|
options.output = fusion_source_parent
|
||||||
currentJobs.clear()
|
currentJobs.clear()
|
||||||
currentJobs.append(comic2ebook.makeFusion(bookDir))
|
job, fusion_cover_path = comic2ebook.makeFusion(bookDir)
|
||||||
|
currentJobs.append(job)
|
||||||
MW.addMessage.emit('Created fusion at ' + currentJobs[0], 'info', False)
|
MW.addMessage.emit('Created fusion at ' + currentJobs[0], 'info', False)
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
print('Fusion Failed. ' + str(e))
|
print('Fusion Failed. ' + str(e))
|
||||||
@@ -463,7 +465,7 @@ class WorkerThread(QThread):
|
|||||||
jobargv.append(job)
|
jobargv.append(job)
|
||||||
try:
|
try:
|
||||||
comic2ebook.options = comic2ebook.checkOptions(copy(options))
|
comic2ebook.options = comic2ebook.checkOptions(copy(options))
|
||||||
outputPath = comic2ebook.makeBook(job, self, job_progress_number)
|
outputPath = comic2ebook.makeBook(job, fusion_cover_path, self, job_progress_number)
|
||||||
MW.hideProgressBar.emit()
|
MW.hideProgressBar.emit()
|
||||||
except UserWarning as warn:
|
except UserWarning as warn:
|
||||||
if not self.conversionAlive:
|
if not self.conversionAlive:
|
||||||
|
|||||||
@@ -77,9 +77,10 @@ def main(argv=None):
|
|||||||
if len(sources) == 0:
|
if len(sources) == 0:
|
||||||
print('No matching files found.')
|
print('No matching files found.')
|
||||||
return 1
|
return 1
|
||||||
|
fusion_cover_path = None
|
||||||
if options.filefusion:
|
if options.filefusion:
|
||||||
fusion_source_parent = str(Path(sources[0]).parent)
|
fusion_source_parent = str(Path(sources[0]).parent)
|
||||||
fusion_path = makeFusion(list(sources))
|
fusion_path, fusion_cover_path = makeFusion(list(sources))
|
||||||
sources.clear()
|
sources.clear()
|
||||||
sources.append(fusion_path)
|
sources.append(fusion_path)
|
||||||
for source in sources:
|
for source in sources:
|
||||||
@@ -89,7 +90,7 @@ def main(argv=None):
|
|||||||
options.output = fusion_source_parent
|
options.output = fusion_source_parent
|
||||||
options = checkOptions(options)
|
options = checkOptions(options)
|
||||||
print('Working on ' + source + '...')
|
print('Working on ' + source + '...')
|
||||||
makeBook(source)
|
makeBook(source, fusion_cover_path)
|
||||||
|
|
||||||
return 0
|
return 0
|
||||||
|
|
||||||
@@ -1773,6 +1774,19 @@ def makeFusion(sources: List[str]):
|
|||||||
start = perf_counter()
|
start = perf_counter()
|
||||||
first_path = Path(sources[0])
|
first_path = Path(sources[0])
|
||||||
|
|
||||||
|
fusion_cover_path = None
|
||||||
|
if first_path.parent.joinpath('Covers').is_dir():
|
||||||
|
covers = os.listdir(first_path.parent.joinpath('Covers'))
|
||||||
|
filtered_covers = []
|
||||||
|
for cover in covers:
|
||||||
|
_, cover_ext = getImageFileName(cover)
|
||||||
|
if cover_ext in IMAGE_TYPES:
|
||||||
|
filtered_covers.append(cover)
|
||||||
|
try:
|
||||||
|
fusion_cover_path = first_path.parent.joinpath('Covers', filtered_covers[0])
|
||||||
|
except IndexError:
|
||||||
|
pass
|
||||||
|
|
||||||
if options.tempdir:
|
if options.tempdir:
|
||||||
fusion_parent = first_path.parent
|
fusion_parent = first_path.parent
|
||||||
else:
|
else:
|
||||||
@@ -1814,10 +1828,10 @@ def makeFusion(sources: List[str]):
|
|||||||
print(f"makefusion: {end - start} seconds")
|
print(f"makefusion: {end - start} seconds")
|
||||||
print("Combined File: "+ str(fusion_path))
|
print("Combined File: "+ str(fusion_path))
|
||||||
|
|
||||||
return str(fusion_path)
|
return str(fusion_path), fusion_cover_path
|
||||||
|
|
||||||
|
|
||||||
def makeBook(source, qtgui=None, job_progress=''):
|
def makeBook(source, fusion_cover_path=None, qtgui=None, job_progress=''):
|
||||||
start = perf_counter()
|
start = perf_counter()
|
||||||
global GUI
|
global GUI
|
||||||
GUI = qtgui
|
GUI = qtgui
|
||||||
@@ -1912,9 +1926,12 @@ def makeBook(source, qtgui=None, job_progress=''):
|
|||||||
options.customcover = True
|
options.customcover = True
|
||||||
except IndexError:
|
except IndexError:
|
||||||
pass
|
pass
|
||||||
|
if fusion_cover_path:
|
||||||
|
options.customcover = True
|
||||||
|
cover_path = fusion_cover_path
|
||||||
|
|
||||||
cover = None
|
cover = None
|
||||||
if not options.webtoon:
|
if not options.webtoon or options.customcover:
|
||||||
cover = image.Cover(cover_path, options)
|
cover = image.Cover(cover_path, options)
|
||||||
|
|
||||||
x, y = image.ProfileData.Profiles[options.profile][1]
|
x, y = image.ProfileData.Profiles[options.profile][1]
|
||||||
|
|||||||
Reference in New Issue
Block a user