1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-15 10:46:40 +00:00

change kobo epub filenames (#616)

This commit is contained in:
Alex Xu
2023-12-21 12:51:26 -08:00
committed by GitHub
parent c29a4beac9
commit 6cdd9d5909

View File

@@ -19,6 +19,9 @@
# #
import os import os
import pathlib
import re
import subprocess
import sys import sys
from argparse import ArgumentParser from argparse import ArgumentParser
from time import strftime, gmtime from time import strftime, gmtime
@@ -672,11 +675,9 @@ def getOutputFilename(srcpath, wantedname, ext, tomenumber):
filename = srcpath + tomenumber + ext filename = srcpath + tomenumber + ext
else: else:
if 'Ko' in options.profile and options.format == 'EPUB': if 'Ko' in options.profile and options.format == 'EPUB':
path = srcpath.split(os.path.sep) src = pathlib.Path(srcpath)
path[-1] = ''.join(e for e in path[-1].split('.')[0] if e.isalnum()) + tomenumber + ext name = re.sub(r'\W+', '_', src.stem) + tomenumber + ext
if not path[-1].split('.')[0]: filename = src.with_name(name)
path[-1] = 'KCCPlaceholder' + tomenumber + ext
filename = os.path.sep.join(path)
else: else:
filename = os.path.splitext(srcpath)[0] + tomenumber + ext filename = os.path.splitext(srcpath)[0] + tomenumber + ext
if os.path.isfile(filename): if os.path.isfile(filename):