From 4bb4231419b5f8080e54fea56bbd61a5c2bfd039 Mon Sep 17 00:00:00 2001 From: 8uziak Date: Sat, 25 May 2024 22:04:58 +0200 Subject: [PATCH 1/5] added cbz unpacking functionality when adding cbz files using directoryButton --- .gitignore | 1 + kindlecomicconverter/KCC_gui.py | 11 ++++++++++- kindlecomicconverter/comic2ebook.py | 25 +++++++++++++++++++++---- 3 files changed, 32 insertions(+), 5 deletions(-) diff --git a/.gitignore b/.gitignore index eaf9a6d0..0822ce41 100644 --- a/.gitignore +++ b/.gitignore @@ -12,3 +12,4 @@ KindleComicConverter*.egg-info/ /kindlegen* /kcc.bat .DS_Store +.vscode/ \ No newline at end of file diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 18f30e1f..551e796b 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -206,7 +206,16 @@ def clean(self): MW.addMessage.emit('Conversion interrupted.', 'error', False) MW.addTrayMessage.emit('Conversion interrupted.', 'Critical') MW.modeConvert.emit(1) - + + def displayProgressMessage(self): + MW.addMessage.emit('Source: ' + self, 'info', False) + MW.addMessage.emit('Creating EPUB files... Done!', 'info', False) + GUI.progress.content = 'Creating EPUB files' + MW.addMessage.emit('Creating MOBI files... Done!', 'info', False) + GUI.progress.content = 'Creating MOBI files' + MW.addMessage.emit('Processing MOBI files... Done!', 'info', False) + GUI.progress.content = 'Processing MOBI files... Done!' + # noinspection PyUnboundLocalVariable def run(self): MW.modeConvert.emit(0) diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 48d439d8..4fccab65 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -49,6 +49,7 @@ from . import metadata from . import kindle from . import __version__ +from . import KCC_gui ImageFile.LOAD_TRUNCATED_IMAGES = True @@ -1142,7 +1143,15 @@ def checkPre(source): pass except Exception: raise UserWarning("Target directory is not writable.") + +def listFilesS(source): + return [item for item in os.listdir(source) if os.path.isfile(os.path.join(source, item))] +def listCbzFilesS(source): + return [item for item in os.listdir(source) if os.path.isfile(os.path.join(source, item)) and item.endswith('.cbz')] + +def countCbzFilesS(source): + return len([item for item in os.listdir(source) if os.path.isfile(os.path.join(source, item)) and item.endswith('.cbz')]) def makeBook(source, qtgui=None): global GUI @@ -1154,9 +1163,17 @@ def makeBook(source, qtgui=None): checkPre(source) print("Preparing source images...") path = getWorkFolder(source) + pathOebpsImages = os.path.join(path, "OEBPS", "Images") print("Checking images...") - getComicInfo(os.path.join(path, "OEBPS", "Images"), source) - detectCorruption(os.path.join(path, "OEBPS", "Images"), source) + getComicInfo(pathOebpsImages, source) + listFiles, listCbzFiles, countCbzFiles = listFilesS(pathOebpsImages), listCbzFilesS(pathOebpsImages), countCbzFilesS(pathOebpsImages) + if countCbzFiles: + for file in listCbzFiles: + KCC_gui.WorkerThread.displayProgressMessage(file) + makeBook(os.path.join(source, file)) + if listFiles: + return [] + detectCorruption(pathOebpsImages, source) if options.webtoon: y = image.ProfileData.Profiles[options.profile][1][1] comic2panel.main(['-y ' + str(y), '-i', '-m', path], qtgui) @@ -1166,10 +1183,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: From bbad054988b1eb7eae84eb82837e02cc8eaf98c1 Mon Sep 17 00:00:00 2001 From: 8uziak Date: Sun, 26 May 2024 22:52:35 +0200 Subject: [PATCH 2/5] reversed previous changes and added directory unpacking feature which detects .cbz files and shows them as an input before clicking convert button --- kindlecomicconverter/KCC_gui.py | 20 +++++++++++--------- kindlecomicconverter/comic2ebook.py | 19 +------------------ 2 files changed, 12 insertions(+), 27 deletions(-) diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 551e796b..de00cfe0 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -207,15 +207,6 @@ def clean(self): MW.addTrayMessage.emit('Conversion interrupted.', 'Critical') MW.modeConvert.emit(1) - def displayProgressMessage(self): - MW.addMessage.emit('Source: ' + self, 'info', False) - MW.addMessage.emit('Creating EPUB files... Done!', 'info', False) - GUI.progress.content = 'Creating EPUB files' - MW.addMessage.emit('Creating MOBI files... Done!', 'info', False) - GUI.progress.content = 'Creating MOBI files' - MW.addMessage.emit('Processing MOBI files... Done!', 'info', False) - GUI.progress.content = 'Processing MOBI files... Done!' - # noinspection PyUnboundLocalVariable def run(self): MW.modeConvert.emit(0) @@ -461,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'): + file_path = os.path.join(root, file) + if sys.platform.startswith('win'): + file_path = file_path.replace('/', '\\') + GUI.jobList.addItem(file_path) + GUI.jobList.scrollToBottom() def selectFile(self): diff --git a/kindlecomicconverter/comic2ebook.py b/kindlecomicconverter/comic2ebook.py index 4fccab65..4ea43ae4 100755 --- a/kindlecomicconverter/comic2ebook.py +++ b/kindlecomicconverter/comic2ebook.py @@ -49,7 +49,6 @@ from . import metadata from . import kindle from . import __version__ -from . import KCC_gui ImageFile.LOAD_TRUNCATED_IMAGES = True @@ -1143,15 +1142,6 @@ def checkPre(source): pass except Exception: raise UserWarning("Target directory is not writable.") - -def listFilesS(source): - return [item for item in os.listdir(source) if os.path.isfile(os.path.join(source, item))] - -def listCbzFilesS(source): - return [item for item in os.listdir(source) if os.path.isfile(os.path.join(source, item)) and item.endswith('.cbz')] - -def countCbzFilesS(source): - return len([item for item in os.listdir(source) if os.path.isfile(os.path.join(source, item)) and item.endswith('.cbz')]) def makeBook(source, qtgui=None): global GUI @@ -1163,16 +1153,9 @@ def makeBook(source, qtgui=None): checkPre(source) print("Preparing source images...") path = getWorkFolder(source) - pathOebpsImages = os.path.join(path, "OEBPS", "Images") print("Checking images...") + pathOebpsImages = os.path.join(path, "OEBPS", "Images") getComicInfo(pathOebpsImages, source) - listFiles, listCbzFiles, countCbzFiles = listFilesS(pathOebpsImages), listCbzFilesS(pathOebpsImages), countCbzFilesS(pathOebpsImages) - if countCbzFiles: - for file in listCbzFiles: - KCC_gui.WorkerThread.displayProgressMessage(file) - makeBook(os.path.join(source, file)) - if listFiles: - return [] detectCorruption(pathOebpsImages, source) if options.webtoon: y = image.ProfileData.Profiles[options.profile][1][1] From a07e0895c23ac376f2e8538e9d6a87f577886c8c Mon Sep 17 00:00:00 2001 From: 8uziak Date: Thu, 30 May 2024 19:24:32 +0200 Subject: [PATCH 3/5] added support for 7z, cb7, zip, cbr and rar extensions and fixed a problem with constructing file directories --- kindlecomicconverter/KCC_gui.py | 10 ++++------ 1 file changed, 4 insertions(+), 6 deletions(-) diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index de00cfe0..29d8ebbc 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -454,19 +454,17 @@ def selectDir(self): GUI.jobList.clear() dname = QtWidgets.QFileDialog.getExistingDirectory(MW, 'Select directory', self.lastPath) - if dname != '': - if sys.platform.startswith('win'): - dname = dname.replace('/', '\\') + if dname: self.lastPath = os.path.abspath(os.path.join(dname, os.pardir)) GUI.jobList.addItem(dname) + supported_extensions = ('.cb7', '.7z', '.cbz', '.zip', '.cbr', '.rar') + for root, _, files in os.walk(dname): for file in files: - if file.lower().endswith('.cbz'): + if file.lower().endswith(supported_extensions): file_path = os.path.join(root, file) - if sys.platform.startswith('win'): - file_path = file_path.replace('/', '\\') GUI.jobList.addItem(file_path) GUI.jobList.scrollToBottom() From bcfcb1cb3be473be7accdd2bff87a6b68c389b36 Mon Sep 17 00:00:00 2001 From: 8uziak Date: Thu, 30 May 2024 19:28:43 +0200 Subject: [PATCH 4/5] removed random spaces --- kindlecomicconverter/KCC_gui.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/kindlecomicconverter/KCC_gui.py b/kindlecomicconverter/KCC_gui.py index 29d8ebbc..2e7aa295 100644 --- a/kindlecomicconverter/KCC_gui.py +++ b/kindlecomicconverter/KCC_gui.py @@ -206,7 +206,7 @@ def clean(self): MW.addMessage.emit('Conversion interrupted.', 'error', False) MW.addTrayMessage.emit('Conversion interrupted.', 'Critical') MW.modeConvert.emit(1) - + # noinspection PyUnboundLocalVariable def run(self): MW.modeConvert.emit(0) From b8af6ae2772102b3513d0df438753f79c16051fb Mon Sep 17 00:00:00 2001 From: 8uziak Date: Sat, 1 Jun 2024 21:11:45 +0200 Subject: [PATCH 5/5] code of conduct added --- code_of_conduct.md | 73 ++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 73 insertions(+) create mode 100644 code_of_conduct.md diff --git a/code_of_conduct.md b/code_of_conduct.md new file mode 100644 index 00000000..ea3af275 --- /dev/null +++ b/code_of_conduct.md @@ -0,0 +1,73 @@ +# Contributor Covenant Code of Conduct + +## Our Pledge + +In the interest of fostering an open and welcoming environment, we as +contributors and maintainers pledge to making participation in our project and +our community a harassment-free experience for everyone, regardless of age, body +size, disability, ethnicity, gender identity and expression, level of experience, +education, socio-economic status, nationality, personal appearance, race, +religion, or sexual identity and orientation. + +## Our Standards + +Examples of behavior that contributes to creating a positive environment +include: + +* Using welcoming and inclusive language +* Being respectful of differing viewpoints and experiences +* Gracefully accepting constructive criticism +* Focusing on what is best for the community +* Showing empathy towards other community members + +Examples of unacceptable behavior by participants include: + +* The use of sexualized language or imagery and unwelcome sexual attention or + advances +* Trolling, insulting/derogatory comments, and personal or political attacks +* Public or private harassment +* Publishing others' private information, such as a physical or electronic + address, without explicit permission +* Other conduct which could reasonably be considered inappropriate in a + professional setting + +## Our Responsibilities + +Project maintainers are responsible for clarifying the standards of acceptable +behavior and are expected to take appropriate and fair corrective action in +response to any instances of unacceptable behavior. + +Project maintainers have the right and responsibility to remove, edit, or +reject comments, commits, code, wiki edits, issues, and other contributions +that are not aligned to this Code of Conduct, or to ban temporarily or +permanently any contributor for other behaviors that they deem inappropriate, +threatening, offensive, or harmful. + +## Scope + +This Code of Conduct applies both within project spaces and in public spaces +when an individual is representing the project or its community. Examples of +representing a project or community include using an official project e-mail +address, posting via an official social media account, or acting as an appointed +representative at an online or offline event. Representation of a project may be +further defined and clarified by project maintainers. + +## Enforcement + +Instances of abusive, harassing, or otherwise unacceptable behavior may be +reported by contacting the project team at {{ email }}. All +complaints will be reviewed and investigated and will result in a response that +is deemed necessary and appropriate to the circumstances. The project team is +obligated to maintain confidentiality with regard to the reporter of an incident. +Further details of specific enforcement policies may be posted separately. + +Project maintainers who do not follow or enforce the Code of Conduct in good +faith may face temporary or permanent repercussions as determined by other +members of the project's leadership. + +## Attribution + +This Code of Conduct is adapted from the [Contributor Covenant][homepage], version 1.4, +available at https://www.contributor-covenant.org/version/1/4/code-of-conduct.html + +[homepage]: https://www.contributor-covenant.org \ No newline at end of file