Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

added cbz unpacking functionality when adding cbz files using directoryButton #700

Closed
wants to merge 13 commits into from
Closed
Show file tree
Hide file tree
Changes from 4 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -12,3 +12,4 @@ KindleComicConverter*.egg-info/
/kindlegen*
/kcc.bat
.DS_Store
.vscode/
13 changes: 12 additions & 1 deletion kindlecomicconverter/KCC_gui.py
Original file line number Diff line number Diff line change
Expand Up @@ -206,7 +206,7 @@ def clean(self):
MW.addMessage.emit('<b>Conversion interrupted.</b>', 'error', False)
MW.addTrayMessage.emit('Conversion interrupted.', 'Critical')
MW.modeConvert.emit(1)

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

don't add random spaces.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

# noinspection PyUnboundLocalVariable
def run(self):
MW.modeConvert.emit(0)
Expand Down Expand Up @@ -452,12 +452,23 @@ def selectDir(self):
if self.needClean:
self.needClean = False
GUI.jobList.clear()

dname = QtWidgets.QFileDialog.getExistingDirectory(MW, 'Select directory', self.lastPath)
if dname != '':
if sys.platform.startswith('win'):
dname = dname.replace('/', '\\')
self.lastPath = os.path.abspath(os.path.join(dname, os.pardir))

GUI.jobList.addItem(dname)

for root, _, files in os.walk(dname):
for file in files:
if file.lower().endswith('.cbz'):
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Only supporting CBZ and not other archives like zip/cbr isn't the best.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

file_path = os.path.join(root, file)
if sys.platform.startswith('win'):
file_path = file_path.replace('/', '\\')
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'd do the research, but pretty sure this kind of code is a relic of older Python/Windows and can be removed in modern computers repo-wide. (maybe in a separate PR).

os.path.join handles any conversions.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

done.

GUI.jobList.addItem(file_path)

GUI.jobList.scrollToBottom()

def selectFile(self):
Expand Down
10 changes: 5 additions & 5 deletions kindlecomicconverter/comic2ebook.py
Original file line number Diff line number Diff line change
Expand Up @@ -1143,7 +1143,6 @@ def checkPre(source):
except Exception:
raise UserWarning("Target directory is not writable.")


def makeBook(source, qtgui=None):
global GUI
GUI = qtgui
Expand All @@ -1155,8 +1154,9 @@ def makeBook(source, qtgui=None):
print("Preparing source images...")
path = getWorkFolder(source)
print("Checking images...")
getComicInfo(os.path.join(path, "OEBPS", "Images"), source)
detectCorruption(os.path.join(path, "OEBPS", "Images"), source)
pathOebpsImages = os.path.join(path, "OEBPS", "Images")
getComicInfo(pathOebpsImages, source)
detectCorruption(pathOebpsImages, source)
if options.webtoon:
y = image.ProfileData.Profiles[options.profile][1][1]
comic2panel.main(['-y ' + str(y), '-i', '-m', path], qtgui)
Expand All @@ -1166,10 +1166,10 @@ def makeBook(source, qtgui=None):
print("Processing images...")
if GUI:
GUI.progressBarTick.emit('Processing images')
imgDirectoryProcessing(os.path.join(path, "OEBPS", "Images"))
imgDirectoryProcessing(pathOebpsImages)
if GUI:
GUI.progressBarTick.emit('1')
chapterNames = sanitizeTree(os.path.join(path, 'OEBPS', 'Images'))
chapterNames = sanitizeTree(pathOebpsImages)
if options.batchsplit > 0:
tomes = splitDirectory(path)
else:
Expand Down