1
0
mirror of https://github.com/ciromattia/kcc synced 2026-04-15 05:28:49 +00:00

Compare commits

...

5 Commits

Author SHA1 Message Date
Alex Xu
04618d5bbf Revert "Revert "remove GUI windows docker""
This reverts commit 57a0450026.
2025-02-25 08:06:45 -08:00
Alex Xu
b35a2baf05 bump 7.2.1 2025-02-20 18:24:53 -08:00
Alex Xu
11a395e983 fix pdf workdir (#830) 2025-02-20 18:24:06 -08:00
Alex Xu
2e39a8c227 add jpeg2000 (#828) 2025-02-19 16:29:26 -08:00
Alex Xu
02535421a0 rename batch to chunk (#826) 2025-02-12 15:31:40 -08:00
3 changed files with 9 additions and 9 deletions

View File

@@ -1,4 +1,4 @@
__version__ = '7.2.0'
__version__ = '7.2.1'
__license__ = 'ISC'
__copyright__ = '2012-2022, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>, darodi'
__docformat__ = 'restructuredtext en'

View File

@@ -645,6 +645,7 @@ def getWorkFolder(afile):
if afile.lower().endswith('.pdf'):
pdf = pdfjpgextract.PdfJpgExtract(afile)
path, njpg = pdf.extract()
workdir = path
sanitizePermissions(path)
if njpg == 0:
rmtree(path, True)
@@ -828,12 +829,11 @@ def sanitizePermissions(filetree):
os.chmod(os.path.join(root, name), S_IWRITE | S_IREAD | S_IEXEC)
def batch_directory(path):
def chunk_directory(path):
level = -1
for root, _, files in os.walk(os.path.join(path, 'OEBPS', 'Images')):
for f in files:
if f.endswith('.jpg') or f.endswith('.jpeg') or f.endswith('.png') or f.endswith('.gif') or \
f.endswith('.webp'):
if getImageFileName(f):
newLevel = os.path.join(root, f).replace(os.path.join(path, 'OEBPS', 'Images'), '').count(os.sep)
if level != -1 and level != newLevel:
level = 0
@@ -842,16 +842,16 @@ def batch_directory(path):
level = newLevel
if level > 0:
parent = pathlib.Path(path).parent
batcher = batch_process(os.path.join(path, 'OEBPS', 'Images'), level, parent)
chunker = chunk_process(os.path.join(path, 'OEBPS', 'Images'), level, parent)
path = [path]
for tome in batcher:
for tome in chunker:
path.append(tome)
return path
else:
raise UserWarning('Unsupported directory structure.')
def batch_process(path, mode, parent):
def chunk_process(path, mode, parent):
output = []
currentSize = 0
currentTarget = path
@@ -1196,7 +1196,7 @@ def makeBook(source, qtgui=None):
GUI.progressBarTick.emit('1')
chapterNames = sanitizeTree(os.path.join(path, 'OEBPS', 'Images'))
if options.batchsplit > 0:
tomes = batch_directory(path)
tomes = chunk_directory(path)
else:
tomes = [path]
filepath = []

View File

@@ -49,7 +49,7 @@ class HTMLStripper(HTMLParser):
def getImageFileName(imgfile):
name, ext = os.path.splitext(imgfile)
ext = ext.lower()
if (name.startswith('.') and len(name) == 1) or ext not in ['.png', '.jpg', '.jpeg', '.gif', '.webp']:
if (name.startswith('.') and len(name) == 1) or ext not in ['.png', '.jpg', '.jpeg', '.gif', '.webp', '.jp2', '.j2k', '.jpx']:
return None
return [name, ext]