1
0
mirror of https://github.com/ciromattia/kcc synced 2026-04-18 23:19:00 +00:00

Compare commits

..

16 Commits

Author SHA1 Message Date
Alex Xu
6e6c13047e bump to 5.6.4 2023-11-28 08:32:34 -08:00
Alex Xu
b528dab711 Revert "fix files with ' or " by using arg lists instead of strings (#581)" (#628)
This reverts commit 431862a2e9.
2023-11-28 08:20:14 -08:00
Alex Xu
2ffefee928 link to readme not wiki for 7z kindlegen (#627)
* link to readme not wiki for 7z kindlegen

* update 7z link
2023-11-28 08:15:59 -08:00
Alex Xu
a5e5407363 streamline downloads and installation readme (#623)
* streamline downloads and installation

move linux stuff into wiki

* Update README.md

* update labels

* simplify
2023-11-28 07:38:46 -08:00
Alex Xu
da1ba64bd2 skip bookmarks if split (#620) 2023-11-28 06:54:47 -08:00
Alex Xu
6dcaf9a6d1 fix unsupported archive error (#619) 2023-11-28 06:53:58 -08:00
Alex Xu
3090a47f20 change mac pyinstaller -F to -D (#621) 2023-11-28 06:52:39 -08:00
Alex Xu
1e537915d4 make c2e and c2p versions first in file order 2023-11-28 06:50:55 -08:00
dependabot[bot]
7273ca25b8 Bump actions/setup-node from 3 to 4 (#609)
Bumps [actions/setup-node](https://github.com/actions/setup-node) from 3 to 4.
- [Release notes](https://github.com/actions/setup-node/releases)
- [Commits](https://github.com/actions/setup-node/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/setup-node
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-11-09 23:06:46 +00:00
Alex Xu
68da853e42 fix page order in pdf and more by using natural sort instead of python sort (#589)
* use natsorted

* Add fast
2023-11-09 23:00:44 +00:00
Alex Xu
431862a2e9 fix files with ' or " by using arg lists instead of strings (#581)
* replace popen with subprocess run

* add splitlines

* remove stdin

* fix xml

* fix error logging and 7zip
2023-11-09 22:27:09 +00:00
Alex Xu
65062f8984 add Kindle 4/5/7/8/10 label (#614) 2023-11-09 22:15:34 +00:00
Alex Xu
8122fa1e45 add c2e and c2p note (#606) 2023-10-26 19:29:16 +00:00
Alex Xu
13fedff77b lower auto crop threshold (#598) 2023-10-26 19:20:26 +00:00
dependabot[bot]
61b1207a3e Bump actions/checkout from 3 to 4 (#592)
Bumps [actions/checkout](https://github.com/actions/checkout) from 3 to 4.
- [Release notes](https://github.com/actions/checkout/releases)
- [Changelog](https://github.com/actions/checkout/blob/main/CHANGELOG.md)
- [Commits](https://github.com/actions/checkout/compare/v3...v4)

---
updated-dependencies:
- dependency-name: actions/checkout
  dependency-type: direct:production
  update-type: version-update:semver-major
...

Signed-off-by: dependabot[bot] <support@github.com>
Co-authored-by: dependabot[bot] <49699333+dependabot[bot]@users.noreply.github.com>
2023-09-16 12:10:53 +00:00
Alex Xu
60e9f075b8 replace exit() with sys.exit() (#590) 2023-09-08 20:18:32 +00:00
17 changed files with 57 additions and 69 deletions

View File

@@ -38,7 +38,7 @@ jobs:
steps: steps:
- name: Checkout repository - name: Checkout repository
uses: actions/checkout@v3 uses: actions/checkout@v4
# Initializes the CodeQL tools for scanning. # Initializes the CodeQL tools for scanning.
- name: Initialize CodeQL - name: Initialize CodeQL

View File

@@ -25,7 +25,7 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:

View File

@@ -25,7 +25,7 @@ jobs:
build: build:
runs-on: macos-latest runs-on: macos-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:
@@ -66,7 +66,7 @@ jobs:
# apply provisioning profile # apply provisioning profile
mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles mkdir -p ~/Library/MobileDevice/Provisioning\ Profiles
cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles cp $PP_PATH ~/Library/MobileDevice/Provisioning\ Profiles
- uses: actions/setup-node@v3 - uses: actions/setup-node@v4
with: with:
node-version: 16 node-version: 16
- run: npm install -g appdmg - run: npm install -g appdmg

View File

@@ -12,7 +12,7 @@ jobs:
build: build:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
# - name: Set up Python # - name: Set up Python
# uses: actions/setup-python@v4 # uses: actions/setup-python@v4
# with: # with:
@@ -44,8 +44,8 @@ jobs:
run: | run: |
version_built=$(cat kindlecomicconverter/__init__.py | grep version | awk '{print $3}' | sed "s/[^.0-9b]//g") version_built=$(cat kindlecomicconverter/__init__.py | grep version | awk '{print $3}' | sed "s/[^.0-9b]//g")
mv dist/windows/kcc.exe dist/windows/kcc_${version_built}.exe mv dist/windows/kcc.exe dist/windows/kcc_${version_built}.exe
mv dist/windows/kcc-c2e.exe dist/windows/kcc-c2e_${version_built}.exe mv dist/windows/kcc-c2e.exe dist/windows/kcc_c2e_${version_built}.exe
mv dist/windows/kcc-c2p.exe dist/windows/kcc-c2p_${version_built}.exe mv dist/windows/kcc-c2p.exe dist/windows/kcc_c2p_${version_built}.exe
- name: upload build - name: upload build
uses: actions/upload-artifact@v3 uses: actions/upload-artifact@v3
with: with:

View File

@@ -25,7 +25,7 @@ jobs:
build: build:
runs-on: windows-latest runs-on: windows-latest
steps: steps:
- uses: actions/checkout@v3 - uses: actions/checkout@v4
- name: Set up Python - name: Set up Python
uses: actions/setup-python@v4 uses: actions/setup-python@v4
with: with:

View File

@@ -30,9 +30,7 @@ If you find **KCC** valuable you can consider donating to the authors:
- [![Donate Bitcoin](https://img.shields.io/badge/Donate-Bitcoin-green.svg)](https://jastrzeb.ski/donate/) - [![Donate Bitcoin](https://img.shields.io/badge/Donate-Bitcoin-green.svg)](https://jastrzeb.ski/donate/)
## INSTALLATION ## DOWNLOADS
### DOWNLOADS
- **https://github.com/ciromattia/kcc/releases** - **https://github.com/ciromattia/kcc/releases**
@@ -42,45 +40,41 @@ You probably want either
- `kcc_*.*.*.exe` (Windows) - `kcc_*.*.*.exe` (Windows)
- `KindleComicConverter_osx_*.*.*.dmg` (Mac) - `KindleComicConverter_osx_*.*.*.dmg` (Mac)
Installation Wiki: https://github.com/ciromattia/kcc/wiki/Installation The `c2e` and `c2p` versions are command line tools for power users.
- flatpak : https://flathub.org/apps/details/io.github.ciromattia.kcc On Windows 11, you may need to run in compatibility mode for an older Windows version.
- Docker: https://github.com/ciromattia/kcc/pkgs/container/kcc
### DEPENDENCIES On Mac, right click open to get past the security warning.
Following software is required to run Linux version of **KCC** and/or bare sources:
- Python 3.3+
- [PyQt5](https://pypi.python.org/pypi/PyQt5) 5.6.0+ (only needed for GUI)
- [Pillow](https://pypi.python.org/pypi/Pillow/) 4.0.0+ (5.2.0+ needed for WebP support)
- [psutil](https://pypi.python.org/pypi/psutil) 5.0.0+
- [python-slugify](https://pypi.python.org/pypi/python-slugify) 1.2.1+, <8.0.0
- [raven](https://pypi.python.org/pypi/raven) 6.0.0+ (only needed for GUI)
On Debian based distributions these two commands should install all needed dependencies: For flatpak, Docker, amd AppImage versions, refer to the wiki: https://github.com/ciromattia/kcc/wiki/Installation
## INSTALL DEPENDENCIES
You'll need to install various tools to access important but optional features.
```bash The installation process has been greatly streamlined. No need to add 7z to PATH or locate KindleGen from the internet and put it in a special folder with KCC. Just run it and KCC will tell you what to install.
$ sudo apt-get install -y python3 python3-dev libpng-dev libjpeg-dev p7zip-full p7zip-rar unrar-free libgl1 python3-pyqt5 && \
python -m pip install --upgrade pip && \ ### 7-Zip
python -m pip install --upgrade -r requirements.txt
#### Windows 7-Zip
First install 7z from https://www.7-zip.org/ or with command line:
```
winget install --id 7zip.7zip
``` ```
#### macOS 7-Zip/Unar
#### Optional dependencies with [Homebrew](https://brew.sh/) installed
- Qt platform integration plugin for Deepin Desktop Environment ```
```bash brew install p7zip
$ sudo apt-get install qt5dxcb-plugin brew install unar
``` ```
- KindleGen ~~[(deprecated link)](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211)~~ v2.9+ (For MOBI generation) ### KindleGen
- should be placed in a directory reachable by your _PATH_ or in _KCC_ directory
- `KindleGen` can be found in [Kindle Previewer](https://www.amazon.com/Kindle-Previewer/b?ie=UTF8&node=21381691011)
- `KindleGen` can be also be found in [Kindle Comic Creator](https://www.amazon.com/b?node=23496309011)
- [7z](http://www.7-zip.org/download.html) *(For CBZ/ZIP, CBR/RAR, 7z/CB7 support)*
- Unrar (no rar in 7z on Fedora)
#### Windows / macOS KindleGen
Install [Kindle Previewer 3 (KP3)](https://www.amazon.com/Kindle-Previewer/b?ie=UTF8&node=21381691011). KCC will automatically detect KindleGen from it.
## INPUT FORMATS ## INPUT FORMATS
**KCC** can understand and convert, at the moment, the following input types: **KCC** can understand and convert, at the moment, the following input types:

View File

@@ -22,7 +22,7 @@ import sys
if sys.version_info < (3, 8, 0): if sys.version_info < (3, 8, 0):
print('ERROR: This is a Python 3.8+ script!') print('ERROR: This is a Python 3.8+ script!')
exit(1) sys.exit(1)
from multiprocessing import freeze_support, set_start_method from multiprocessing import freeze_support, set_start_method
from kindlecomicconverter.startup import startC2E from kindlecomicconverter.startup import startC2E

View File

@@ -22,7 +22,7 @@ import sys
if sys.version_info < (3, 8, 0): if sys.version_info < (3, 8, 0):
print('ERROR: This is a Python 3.8+ script!') print('ERROR: This is a Python 3.8+ script!')
exit(1) sys.exit(1)
from multiprocessing import freeze_support, set_start_method from multiprocessing import freeze_support, set_start_method
from kindlecomicconverter.startup import startC2P from kindlecomicconverter.startup import startC2P

2
kcc.py
View File

@@ -22,7 +22,7 @@ import sys
if sys.version_info < (3, 8, 0): if sys.version_info < (3, 8, 0):
print('ERROR: This is a Python 3.8+ script!') print('ERROR: This is a Python 3.8+ script!')
exit(1) sys.exit(1)
# OS specific workarounds # OS specific workarounds
import os import os

View File

@@ -752,7 +752,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
def display_kindlegen_missing(self): def display_kindlegen_missing(self):
self.addMessage( self.addMessage(
'<a href="https://github.com/ciromattia/kcc/wiki/Installation#kindlegen"><b>Cannot find KindleGen</b></a>: MOBI conversion is unavailable!', '<a href="https://github.com/ciromattia/kcc#kindlegen"><b>Install KindleGen (link)</b></a> to enable MOBI conversion for Kindles!',
'error' 'error'
) )
@@ -943,7 +943,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
'DefaultUpscale': True, 'Label': 'KV'}, 'DefaultUpscale': True, 'Label': 'KV'},
"Kindle PW 1/2": {'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, "Kindle PW 1/2": {'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0,
'DefaultUpscale': False, 'Label': 'KPW'}, 'DefaultUpscale': False, 'Label': 'KPW'},
"Kindle": {'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0, "Kindle 4/5/7/8/10": {'PVOptions': True, 'ForceExpert': False, 'DefaultFormat': 0,
'DefaultUpscale': False, 'Label': 'K578'}, 'DefaultUpscale': False, 'Label': 'K578'},
"Kindle DX/DXG": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 2, "Kindle DX/DXG": {'PVOptions': False, 'ForceExpert': False, 'DefaultFormat': 2,
'DefaultUpscale': False, 'Label': 'KDX'}, 'DefaultUpscale': False, 'Label': 'KDX'},
@@ -1011,7 +1011,7 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
"Kindle Voyage", "Kindle Voyage",
"Kindle 2", "Kindle 2",
"Kindle 1", "Kindle 1",
"Kindle", "Kindle 4/5/7/8/10",
"Separator", "Separator",
"Kobo Aura", "Kobo Aura",
"Kobo Aura ONE", "Kobo Aura ONE",
@@ -1045,8 +1045,8 @@ class KCCGUI(KCC_ui.Ui_mainWindow):
self.sevenzip = True self.sevenzip = True
else: else:
self.sevenzip = False self.sevenzip = False
self.addMessage('<a href="https://github.com/ciromattia/kcc/wiki/Installation#7-zip">Cannot find 7z</a>!' self.addMessage('<a href="https://github.com/ciromattia/kcc#7-zip">Install 7z (link)</a>'
' CBZ/CBR/ZIP/etc processing disabled.', 'warning') ' to enable CBZ/CBR/ZIP/etc processing.', 'warning')
self.detectKindleGen(True) self.detectKindleGen(True)
APP.messageFromOtherInstance.connect(self.handleMessage) APP.messageFromOtherInstance.connect(self.handleMessage)

View File

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

View File

@@ -31,6 +31,7 @@ from tempfile import mkdtemp, gettempdir, TemporaryFile
from shutil import move, copytree, rmtree, copyfile from shutil import move, copytree, rmtree, copyfile
from multiprocessing import Pool from multiprocessing import Pool
from uuid import uuid4 from uuid import uuid4
from natsort import natsorted
from slugify import slugify as slugify_ext from slugify import slugify as slugify_ext
from PIL import Image from PIL import Image
from subprocess import STDOUT, PIPE from subprocess import STDOUT, PIPE
@@ -726,7 +727,7 @@ def getComicInfo(path, originalpath):
options.authors.sort() options.authors.sort()
else: else:
options.authors = ['KCC'] options.authors = ['KCC']
if xml.data['Bookmarks']: if xml.data['Bookmarks'] and options.batchsplit == 0:
options.chapters = xml.data['Bookmarks'] options.chapters = xml.data['Bookmarks']
if xml.data['Summary']: if xml.data['Summary']:
options.summary = hescape(xml.data['Summary']) options.summary = hescape(xml.data['Summary'])
@@ -761,7 +762,7 @@ def getPanelViewSize(deviceres, size):
def sanitizeTree(filetree): def sanitizeTree(filetree):
chapterNames = {} chapterNames = {}
for root, dirs, files in os.walk(filetree, False): for root, dirs, files in os.walk(filetree, False):
for i, name in enumerate(sorted(files)): for i, name in enumerate(natsorted(files)):
splitname = os.path.splitext(name) splitname = os.path.splitext(name)
# file needs kcc at front AND back to avoid renaming issues # file needs kcc at front AND back to avoid renaming issues
@@ -1105,13 +1106,13 @@ def checkTools(source):
process.communicate() process.communicate()
if process.returncode != 0 and process.returncode != 7: if process.returncode != 0 and process.returncode != 7:
print('ERROR: 7z is missing!') print('ERROR: 7z is missing!')
exit(1) sys.exit(1)
if options.format == 'MOBI': if options.format == 'MOBI':
kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True) kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, stdin=PIPE, shell=True)
kindleGenExitCode.communicate() kindleGenExitCode.communicate()
if kindleGenExitCode.returncode != 0: if kindleGenExitCode.returncode != 0:
print('ERROR: KindleGen is missing!') print('ERROR: KindleGen is missing!')
exit(1) sys.exit(1)
def checkPre(source): def checkPre(source):

View File

@@ -49,11 +49,7 @@ class ComicArchive:
break break
process.communicate() process.communicate()
if process.returncode != 0: if process.returncode != 0:
raise OSError('Archive is corrupted or encrypted.') raise OSError(process.stdout.strip())
elif self.type not in ['7Z', 'RAR', 'RAR5', 'ZIP']:
raise OSError('Unsupported archive format.')
elif self.type not in ['7Z', 'RAR', 'RAR5', 'ZIP']:
raise OSError('Unsupported archive format.')
def extract(self, targetdir): def extract(self, targetdir):
if not os.path.isdir(targetdir): if not os.path.isdir(targetdir):

View File

@@ -24,12 +24,7 @@ import mozjpeg_lossless_optimization
from PIL import Image, ImageOps, ImageStat, ImageChops, ImageFilter from PIL import Image, ImageOps, ImageStat, ImageChops, ImageFilter
from .shared import md5Checksum from .shared import md5Checksum
# 0.045 was determined by AUTO_CROP_THRESHOLD = 0.015
# 1200 / 824 = 1.456 (Kindle DX resolution)
# 2250 / 1500 = 1.5 (Typical manga page resolution)
# 1.5 - 1.456 < 0.045
# 0.045 / 1.5 = 0.03 (So maximum 3% of is cropped)
AUTO_CROP_THRESHOLD = 0.045
class ProfileData: class ProfileData:

View File

@@ -23,6 +23,7 @@ from hashlib import md5
from html.parser import HTMLParser from html.parser import HTMLParser
from distutils.version import StrictVersion from distutils.version import StrictVersion
from re import split from re import split
import sys
from traceback import format_tb from traceback import format_tb
@@ -133,4 +134,4 @@ def dependencyCheck(level):
missing.append('Pillow 5.2.0+') missing.append('Pillow 5.2.0+')
if len(missing) > 0: if len(missing) > 0:
print('ERROR: ' + ', '.join(missing) + ' is not installed!') print('ERROR: ' + ', '.join(missing) + ' is not installed!')
exit(1) sys.exit(1)

View File

@@ -5,4 +5,5 @@ python-slugify>=1.2.1
raven>=6.0.0 raven>=6.0.0
# PyQt5-tools # PyQt5-tools
mozjpeg-lossless-optimization>=1.1.2 mozjpeg-lossless-optimization>=1.1.2
natsort[fast]>=8.4.0
distro distro

View File

@@ -37,19 +37,19 @@ class BuildBinaryCommand(distutils.cmd.Command):
def run(self): def run(self):
VERSION = __version__ VERSION = __version__
if sys.platform == 'darwin': if sys.platform == 'darwin':
os.system('pyinstaller -y -F -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s kcc.py') os.system('pyinstaller -y -D -i icons/comic2ebook.icns -n "Kindle Comic Converter" -w -s kcc.py')
# TODO /usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime dist/Applications/Kindle\ Comic\ Converter.app -v # TODO /usr/bin/codesign --force -s "$MACOS_CERTIFICATE_NAME" --options runtime dist/Applications/Kindle\ Comic\ Converter.app -v
os.system('appdmg kcc.json dist/KindleComicConverter_osx_' + VERSION + '.dmg') os.system('appdmg kcc.json dist/KindleComicConverter_osx_' + VERSION + '.dmg')
exit(0) sys.exit(0)
elif sys.platform == 'win32': elif sys.platform == 'win32':
os.system('pyinstaller -y -F -i icons\\comic2ebook.ico -n KCC_' + VERSION + ' -w --noupx kcc.py') os.system('pyinstaller -y -F -i icons\\comic2ebook.ico -n KCC_' + VERSION + ' -w --noupx kcc.py')
exit(0) sys.exit(0)
elif sys.platform == 'linux': elif sys.platform == 'linux':
os.system( os.system(
'pyinstaller --hidden-import=queue -y -F -i icons/comic2ebook.ico -n kcc_linux_' + VERSION + ' kcc.py') 'pyinstaller --hidden-import=queue -y -F -i icons/comic2ebook.ico -n kcc_linux_' + VERSION + ' kcc.py')
exit(0) sys.exit(0)
else: else:
exit(0) sys.exit(0)
setuptools.setup( setuptools.setup(