diff options
| -rw-r--r-- | .gitignore | 1 | ||||
| -rw-r--r-- | README.md | 7 | ||||
| -rw-r--r-- | kcc/KCC_gui.py | 23 | ||||
| -rw-r--r-- | kcc/cbxarchive.py | 15 | ||||
| -rwxr-xr-x | kcc/comic2ebook.py | 3 | ||||
| -rw-r--r-- | other/Additional-LICENSE.txt | 91 | ||||
| -rw-r--r-- | setup.py | 6 |
7 files changed, 137 insertions, 9 deletions
diff --git a/.gitignore b/.gitignore index dc4e08c..14d4c97 100644 --- a/.gitignore +++ b/.gitignore @@ -8,3 +8,4 @@ kindlegen* .DS_Store Thumbs.db /UnRAR.exe +/7za.exe diff --git a/README.md b/README.md index 5cae032..7a2ef48 100644 --- a/README.md +++ b/README.md @@ -30,11 +30,13 @@ You can find the latest released binary at the following links: - Folders - CBZ, ZIP - CBR, RAR *(With `unrar` executable)* +- CB7, 7Z *(With `7za` executable)* - PDF *(Extracting only contained JPG images)* ## OPTIONAL REQUIREMENTS - [KindleGen](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211) v2.9+ in a directory reachable by your _PATH_ or in _KCC_ directory *(For .mobi generation)* - [UnRAR](http://www.rarlab.com/download.htm) *(For CBR/RAR support)* +- [7za](http://www.7-zip.org/download.html) *(For 7z/CB7 support)* ### For compiling/running from source: - Python 2.7 - Included in MacOS and Linux, follow the [official documentation](http://www.python.org/getit/windows/) to install on Windows. @@ -52,7 +54,7 @@ You can find the latest released binary at the following links: * Check our [wiki](https://github.com/ciromattia/kcc/wiki/Other-devices) for a list of tested Non-Kindle E-Readers. * The first image found will be set as the comic's cover. * All files/directories will be added to EPUB in alphabetical order. -* Output MOBI file should be uploaded via USB. Other methods (e.g. via Calibre) might corrupt it. +* Output MOBI file should be uploaded via USB. Other methods might corrupt it. ### GUI @@ -257,8 +259,9 @@ The app relies and includes the following scripts/binaries: * Layout of panels in Panel View mode is now automatically adjusted to content * Support for Virtual Panel View was removed * Margin color fill is now autodetected +* Added support of 7z/CB7 files * Profiles for Kindle Keyboard, Touch and Non-Touch are now merged -* Windows release is now bundled with UnRAR +* Windows release is now bundled with UnRAR and 7za * Small GUI tweaks ## KNOWN ISSUES diff --git a/kcc/KCC_gui.py b/kcc/KCC_gui.py index 6945e80..e047446 100644 --- a/kcc/KCC_gui.py +++ b/kcc/KCC_gui.py @@ -321,11 +321,19 @@ class Ui_KCC(object): self.needClean = False GUI.JobList.clear() if self.UnRAR: - fnames = QtGui.QFileDialog.getOpenFileNames(MainWindow, 'Select file', self.lastPath, - '*.cbz *.cbr *.zip *.rar *.pdf') + if self.sevenza: + fnames = QtGui.QFileDialog.getOpenFileNames(MainWindow, 'Select file', self.lastPath, + '*.cbz *.cbr *.cb7 *.zip *.rar *.7z *.pdf') + else: + fnames = QtGui.QFileDialog.getOpenFileNames(MainWindow, 'Select file', self.lastPath, + '*.cbz *.cbr *.zip *.rar *.pdf') else: - fnames = QtGui.QFileDialog.getOpenFileNames(MainWindow, 'Select file', self.lastPath, - '*.cbz *.zip *.pdf') + if self.sevenza: + fnames = QtGui.QFileDialog.getOpenFileNames(MainWindow, 'Select file', self.lastPath, + '*.cbz *.cb7 *.zip *.7z *.pdf') + else: + fnames = QtGui.QFileDialog.getOpenFileNames(MainWindow, 'Select file', self.lastPath, + '*.cbz *.zip *.pdf') # Lame UTF-8 security measure for fname in fnames: try: @@ -629,6 +637,13 @@ class Ui_KCC(object): self.UnRAR = False self.addMessage('Cannot find <a href="http://www.rarlab.com/rar_add.htm">UnRAR</a>!' ' Processing of CBR/RAR files will be disabled.', 'warning') + sevenzaExitCode = call('7za', stdout=PIPE, stderr=STDOUT, shell=True) + if sevenzaExitCode == 0 or sevenzaExitCode == 7: + self.sevenza = True + else: + self.sevenza = False + self.addMessage('Cannot find <a href="http://www.7-zip.org/download.html>7za</a>!' + ' Processing of CB7/7Z files will be disabled.', 'warning') GUI.BasicModeButton.clicked.connect(self.modeBasic) GUI.AdvModeButton.clicked.connect(self.modeAdvanced) diff --git a/kcc/cbxarchive.py b/kcc/cbxarchive.py index a2138f5..226e77a 100644 --- a/kcc/cbxarchive.py +++ b/kcc/cbxarchive.py @@ -22,6 +22,7 @@ __docformat__ = 'restructuredtext en' import os import zipfile import rarfile +from subprocess import Popen, STDOUT, PIPE # noinspection PyBroadException @@ -32,6 +33,8 @@ class CBxArchive: self.compressor = 'zip' elif rarfile.is_rarfile(origFileName): self.compressor = 'rar' + elif origFileName.endswith('.7z') or origFileName.endswith('.cb7'): + self.compressor = '7z' else: self.compressor = None @@ -68,12 +71,24 @@ class CBxArchive: filelist.append(f) cbrFile.extractall(targetdir, filelist) + def extractCB7(self, targetdir): + output = Popen('7za x "' + self.origFileName + '" -xr!__MACOSX -xr!.DS_Store -xr!thumbs.db -o"' + targetdir + + '"', stdout=PIPE, stderr=STDOUT, shell=True) + extracted = False + for line in output.stdout: + if "Everything is Ok" in line: + extracted = True + if not extracted: + raise OSError + def extract(self, targetdir): print "\n" + targetdir + "\n" if self.compressor == 'rar': self.extractCBR(targetdir) elif self.compressor == 'zip': self.extractCBZ(targetdir) + elif self.compressor == '7z': + self.extractCB7(targetdir) adir = os.listdir(targetdir) if len(adir) == 1 and os.path.isdir(os.path.join(targetdir, adir[0])): import shutil diff --git a/kcc/comic2ebook.py b/kcc/comic2ebook.py index e4df1ec..4ac8acb 100755 --- a/kcc/comic2ebook.py +++ b/kcc/comic2ebook.py @@ -569,8 +569,7 @@ def getWorkFolder(afile): path = cbx.extract(workdir) except OSError: rmtree(workdir) - print 'Unrar not found, please download from ' + \ - 'http://www.rarlab.com/download.htm and put into your PATH.' + print 'UnRAR/7za not found or file failed to extract!' sys.exit(21) else: rmtree(workdir) diff --git a/other/Additional-LICENSE.txt b/other/Additional-LICENSE.txt new file mode 100644 index 0000000..891d453 --- /dev/null +++ b/other/Additional-LICENSE.txt @@ -0,0 +1,91 @@ + ****** ***** ****** UnRAR - free utility for RAR archives + ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ****** ******* ****** License for use and distribution of + ** ** ** ** ** ** ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + ** ** ** ** ** ** FREEWARE version + ~~~~~~~~~~~~~~~~ + + The UnRAR utility is freeware. This means: + + 1. All copyrights to RAR and the utility UnRAR are exclusively + owned by the author - Alexander Roshal. + + 2. The UnRAR utility may be freely distributed. It is allowed + to distribute UnRAR inside of other software packages. + + 3. THE RAR ARCHIVER AND THE UnRAR UTILITY ARE DISTRIBUTED "AS IS". + NO WARRANTY OF ANY KIND IS EXPRESSED OR IMPLIED. YOU USE AT + YOUR OWN RISK. THE AUTHOR WILL NOT BE LIABLE FOR DATA LOSS, + DAMAGES, LOSS OF PROFITS OR ANY OTHER KIND OF LOSS WHILE USING + OR MISUSING THIS SOFTWARE. + + 4. Neither RAR binary code, WinRAR binary code, UnRAR source or UnRAR + binary code may be used or reverse engineered to re-create the RAR + compression algorithm, which is proprietary, without written + permission of the author. + + 5. If you don't agree with terms of the license you must remove + UnRAR files from your storage devices and cease to use the + utility. + + Thank you for your interest in RAR and UnRAR. + + + Alexander L. Roshal + + 7-Zip + ~~~~~ + License for use and distribution + ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + + 7-Zip Copyright (C) 1999-2012 Igor Pavlov. + + Licenses for files are: + + 1) 7z.dll: GNU LGPL + unRAR restriction + 2) All other files: GNU LGPL + + The GNU LGPL + unRAR restriction means that you must follow both + GNU LGPL rules and unRAR restriction rules. + + + Note: + You can use 7-Zip on any computer, including a computer in a commercial + organization. You don't need to register or pay for 7-Zip. + + + GNU LGPL information + -------------------- + + This library is free software; you can redistribute it and/or + modify it under the terms of the GNU Lesser General Public + License as published by the Free Software Foundation; either + version 2.1 of the License, or (at your option) any later version. + + This library is distributed in the hope that it will be useful, + but WITHOUT ANY WARRANTY; without even the implied warranty of + MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU + Lesser General Public License for more details. + + You can receive a copy of the GNU Lesser General Public License from + http://www.gnu.org/ + + + unRAR restriction + ----------------- + + The decompression engine for RAR archives was developed using source + code of unRAR program. + All copyrights to original unRAR code are owned by Alexander Roshal. + + The license for original unRAR code has the following restriction: + + The unRAR sources cannot be used to re-create the RAR compression algorithm, + which is proprietary. Distribution of modified unRAR sources in separate form + or as a part of other software is permitted, provided that it is clearly + stated in the documentation and source comments that the code may + not be used to develop a RAR (WinRAR) compatible archiver. + + + -- + Igor Pavlov \ No newline at end of file diff --git a/setup.py b/setup.py index 9d95d63..35edd24 100644 --- a/setup.py +++ b/setup.py @@ -41,7 +41,11 @@ elif platform == "win32": from cx_Freeze import setup, Executable base = "Win32GUI" extra_options = dict( - options={"build_exe": {"include_files": ['LICENSE.txt', ['other/UnRAR.exe', 'UnRAR.exe']], "compressed": True}}, + options={"build_exe": {"include_files": ['LICENSE.txt', + ['other/UnRAR.exe', 'UnRAR.exe'], + ['other/7za.exe', '7za.exe'], + ['other/Additional-LICENSE.txt', 'Additional-LICENSE.txt'] + ], "compressed": True}}, executables=[Executable(MAIN, base=base, targetName="KCC.exe", |