mirror of
https://github.com/hyugogirubato/cbz.git
synced 2026-09-26 13:31:00 +00:00
fixpage name
This commit is contained in:
@@ -1,4 +1,5 @@
|
|||||||
import os
|
import os
|
||||||
|
import pathlib
|
||||||
import shutil
|
import shutil
|
||||||
import zipfile
|
import zipfile
|
||||||
|
|
||||||
@@ -64,8 +65,7 @@ class Helper:
|
|||||||
if not page.get('Type'):
|
if not page.get('Type'):
|
||||||
page['Type'] = 'FrontCover' if i == 0 else 'Story'
|
page['Type'] = 'FrontCover' if i == 0 else 'Story'
|
||||||
|
|
||||||
item = ' <Page DoublePage="True"' if get_key_value(
|
item = ' <Page DoublePage="True"' if get_key_value(page.get('DoublePage', False)) == 'Yes' else ' <Page'
|
||||||
page.get('DoublePage', False)) == 'Yes' else ' <Page'
|
|
||||||
pages.append(
|
pages.append(
|
||||||
item + ' Image="{image}" ImageHeight="{height}" ImageSize="{size}" ImageWidth="{width}" Type="{type}" />'.format(
|
item + ' Image="{image}" ImageHeight="{height}" ImageSize="{size}" ImageWidth="{width}" Type="{type}" />'.format(
|
||||||
double="False" if get_key_value(page.get('DoublePage', False)) == 'No' else "True",
|
double="False" if get_key_value(page.get('DoublePage', False)) == 'No' else "True",
|
||||||
@@ -106,11 +106,13 @@ class Helper:
|
|||||||
|
|
||||||
clear_path = []
|
clear_path = []
|
||||||
cbz = zipfile.ZipFile(output, 'w', compression=zipfile.ZIP_STORED)
|
cbz = zipfile.ZipFile(output, 'w', compression=zipfile.ZIP_STORED)
|
||||||
for file in self._files:
|
for i in range(len(self._files)):
|
||||||
if os.path.dirname(file) not in clear_path:
|
if os.path.dirname(self._files[i]) not in clear_path:
|
||||||
clear_path.append(os.path.dirname(file))
|
clear_path.append(os.path.dirname(self._files[i]))
|
||||||
with open(file, mode='rb') as f:
|
with open(self._files[i], mode='rb') as f:
|
||||||
cbz.writestr(os.path.basename(file), data=f.read())
|
extension = pathlib.Path(self._files[i]).suffix
|
||||||
|
cbz.writestr(f"page-{i + 1:03d}.{'.jpg' if extension == '' else extension}", data=f.read())
|
||||||
|
f.close()
|
||||||
cbz.writestr('ComicInfo.xml', data=self.metadata.encode('utf-8'))
|
cbz.writestr('ComicInfo.xml', data=self.metadata.encode('utf-8'))
|
||||||
cbz.close()
|
cbz.close()
|
||||||
print(f"INFO: File create: {output}")
|
print(f"INFO: File create: {output}")
|
||||||
|
|||||||
Reference in New Issue
Block a user