mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 09:46:25 +00:00
Tweaked KEPUB renamer (close #144)
This commit is contained in:
@@ -691,8 +691,8 @@ def getWorkFolder(afile):
|
|||||||
def getOutputFilename(srcpath, wantedname, ext, tomeNumber):
|
def getOutputFilename(srcpath, wantedname, ext, tomeNumber):
|
||||||
if srcpath[-1] == os.path.sep:
|
if srcpath[-1] == os.path.sep:
|
||||||
srcpath = srcpath[:-1]
|
srcpath = srcpath[:-1]
|
||||||
if not ext.startswith('.'):
|
if 'Ko' in options.profile and options.format == 'EPUB':
|
||||||
ext = '.' + ext
|
ext = '.kepub.epub'
|
||||||
if wantedname is not None:
|
if wantedname is not None:
|
||||||
if wantedname.endswith(ext):
|
if wantedname.endswith(ext):
|
||||||
filename = os.path.abspath(wantedname)
|
filename = os.path.abspath(wantedname)
|
||||||
@@ -704,7 +704,14 @@ def getOutputFilename(srcpath, wantedname, ext, tomeNumber):
|
|||||||
elif os.path.isdir(srcpath):
|
elif os.path.isdir(srcpath):
|
||||||
filename = srcpath + tomeNumber + ext
|
filename = srcpath + tomeNumber + ext
|
||||||
else:
|
else:
|
||||||
filename = os.path.splitext(srcpath)[0] + tomeNumber + ext
|
if 'Ko' in options.profile and options.format == 'EPUB':
|
||||||
|
path = srcpath.split(os.path.sep)
|
||||||
|
path[-1] = ''.join(e for e in path[-1].split('.')[0] if e.isalnum()) + tomeNumber + ext
|
||||||
|
if not path[-1].split('.')[0]:
|
||||||
|
path[-1] = 'KCCPlaceholder' + tomeNumber + ext
|
||||||
|
filename = os.path.sep.join(path)
|
||||||
|
else:
|
||||||
|
filename = os.path.splitext(srcpath)[0] + tomeNumber + ext
|
||||||
if os.path.isfile(filename):
|
if os.path.isfile(filename):
|
||||||
counter = 0
|
counter = 0
|
||||||
basename = os.path.splitext(filename)[0]
|
basename = os.path.splitext(filename)[0]
|
||||||
@@ -1248,11 +1255,6 @@ def makeBook(source, qtGUI=None):
|
|||||||
filepath.append(getOutputFilename(source, options.output, '.epub', ''))
|
filepath.append(getOutputFilename(source, options.output, '.epub', ''))
|
||||||
makeZIP(tome + '_comic', tome, True)
|
makeZIP(tome + '_comic', tome, True)
|
||||||
move(tome + '_comic.zip', filepath[-1])
|
move(tome + '_comic.zip', filepath[-1])
|
||||||
if 'Ko' in options.profile:
|
|
||||||
filename = filepath[-1].split(os.path.sep)
|
|
||||||
filename[-1] = ''.join(e for e in filename[-1].split('.')[0] if e.isalnum()) + '.kepub.epub'
|
|
||||||
filename = os.path.sep.join(filename)
|
|
||||||
move(filepath[-1], filename)
|
|
||||||
rmtree(tome, True)
|
rmtree(tome, True)
|
||||||
if GUI:
|
if GUI:
|
||||||
GUI.progressBarTick.emit('tick')
|
GUI.progressBarTick.emit('tick')
|
||||||
|
|||||||
Reference in New Issue
Block a user