mirror of
https://github.com/ciromattia/kcc
synced 2026-04-17 14:38:47 +00:00
Compare commits
76 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
b174534c1c | ||
|
|
19d486a4ee | ||
|
|
652762b709 | ||
|
|
e6df87f8fd | ||
|
|
1a9cd0beb5 | ||
|
|
108e351126 | ||
|
|
dfe3e10470 | ||
|
|
787ad9fa66 | ||
|
|
f10e8869a9 | ||
|
|
715ada328f | ||
|
|
56f23ab488 | ||
|
|
996af59e00 | ||
|
|
37aa84c4aa | ||
|
|
50574632e6 | ||
|
|
0afb9e8c0b | ||
|
|
7511c7eed6 | ||
|
|
836a4146f9 | ||
|
|
15a240ccea | ||
|
|
0722ddf8b0 | ||
|
|
b3159b94e7 | ||
|
|
ef5207c990 | ||
|
|
db77d89817 | ||
|
|
4571fadadb | ||
|
|
94f56238ae | ||
|
|
5efb5d6dbb | ||
|
|
623f615dd9 | ||
|
|
39fbbc42b3 | ||
|
|
99405ab8a6 | ||
|
|
aadfca8306 | ||
|
|
5450502c2a | ||
|
|
c976b06413 | ||
|
|
b6facda95b | ||
|
|
3f608eb602 | ||
|
|
104cd04994 | ||
|
|
b323204628 | ||
|
|
56195d301d | ||
|
|
287723ca6f | ||
|
|
90490149c7 | ||
|
|
2210f484df | ||
|
|
d5502e85b0 | ||
|
|
59b26cfc8b | ||
|
|
a722e5fa49 | ||
|
|
fce3072dca | ||
|
|
f53cdf9cd7 | ||
|
|
de74318c69 | ||
|
|
b137e69510 | ||
|
|
888663fa4c | ||
|
|
8a2ba96ac5 | ||
|
|
cb6b0e0a7b | ||
|
|
49d2a7fbab | ||
|
|
3d84b27d58 | ||
|
|
e98a23d0c0 | ||
|
|
7f80dacea8 | ||
|
|
6efb3dcef3 | ||
|
|
942a828b7e | ||
|
|
df5ee1badf | ||
|
|
e3ab28642d | ||
|
|
a1831c45d5 | ||
|
|
52bea9957a | ||
|
|
a71339ec34 | ||
|
|
c5f09c44b8 | ||
|
|
64b199ef74 | ||
|
|
8dd0b0e694 | ||
|
|
181a2e8ab4 | ||
|
|
3fdff845b7 | ||
|
|
2ee5dc310b | ||
|
|
f32e9560b5 | ||
|
|
621827c1c2 | ||
|
|
dc312f36c2 | ||
|
|
4573ff6ec2 | ||
|
|
d77498405b | ||
|
|
e491fca445 | ||
|
|
d22ee1a488 | ||
|
|
7ebcccd8a2 | ||
|
|
9a691c3c63 | ||
|
|
2b04a0298e |
@@ -110,7 +110,7 @@
|
|||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p style='white-space:pre'>Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html></string>
|
<string><html><head/><body><p>Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>This mode was created for pages with a low width, high height and vertical panel flow.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Webtoon mode</string>
|
<string>Webtoon mode</string>
|
||||||
@@ -386,7 +386,7 @@
|
|||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode<br/></span><span style=" font-style:italic;">Use it when Panel View support is not needed.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Poor quality when zoom is enabled.<br/>- Lowest file size.</p><p><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode<br/></span><span style=" font-style:italic;">Not zoomed images </span><span style=" font-weight:600; font-style:italic;">might</span><span style=" font-style:italic;"> be blurry.<br/></span>- High quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.</p><p><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode<br/></span><span style=" font-style:italic;">Maximum possible quality.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.<br/>- Very high file size.</p></body></html></string>
|
<string><html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode</span><br/>Maximal quality of images but very poor magnification quality.<br/>Use it only when zoom is not needed or output files needs to be small.</p><p><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode</span><br/>In most cases high quality of images and magnification.<br/>Overall quality highly depends on the resolution of source files.<br/>On Kindle models older than Paperwhite non-zoomed images might be a little blurred.<br/><br/><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode</span><br/>Highest possible quality. Output files will be big.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>High/Ultra quality</string>
|
<string>High/Ultra quality</string>
|
||||||
|
|||||||
@@ -110,7 +110,7 @@
|
|||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p style='white-space:pre'>Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html></string>
|
<string><html><head/><body><p>Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God </span>or <span style=" font-style:italic;">Noblesse</span>.<br/>This mode was created for pages with a low width, high height and vertical panel flow.</p><p><br/></p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Webtoon mode</string>
|
<string>Webtoon mode</string>
|
||||||
@@ -391,7 +391,7 @@
|
|||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode<br/></span><span style=" font-style:italic;">Use it when Panel View support is not needed.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Poor quality when zoom is enabled.<br/>- Lowest file size.</p><p><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode<br/></span><span style=" font-style:italic;">Not zoomed image </span><span style=" font-weight:600; font-style:italic;">might</span><span style=" font-style:italic;"> be a little blurry.<br/></span>- High quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.</p><p><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode<br/></span><span style=" font-style:italic;">Maximum possible quality.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.<br/>- Very high file size.</p></body></html></string>
|
<string><html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode</span><br/>Maximal quality of images but very poor magnification quality.<br/>Use it only when zoom is not needed or output files needs to be small.</p><p><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode</span><br/>In most cases high quality of images and magnification.<br/>Overall quality highly depends on the resolution of source files.<br/>On Kindle models older than Paperwhite non-zoomed images might be a little blurred.</p><p><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode</span><br/>Highest possible quality. Output files will be big.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>High/Ultra quality</string>
|
<string>High/Ultra quality</string>
|
||||||
|
|||||||
4
KCC.ui
4
KCC.ui
@@ -94,7 +94,7 @@
|
|||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p style='white-space:pre'>Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html></string>
|
<string><html><head/><body><p style="white-space:pre">Enable auto-splitting of webtoons like <span style=" font-style:italic;">Tower of God</span> or <span style=" font-style:italic;">Noblesse</span>.<br/>This mode is created for pages with a low width, high height and vertical panel flow.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>Webtoon mode</string>
|
<string>Webtoon mode</string>
|
||||||
@@ -338,7 +338,7 @@
|
|||||||
<enum>Qt::NoFocus</enum>
|
<enum>Qt::NoFocus</enum>
|
||||||
</property>
|
</property>
|
||||||
<property name="toolTip">
|
<property name="toolTip">
|
||||||
<string><html><head/><body><p><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode<br/></span><span style=" font-style:italic;">Use it when Panel View support is not needed.</span><span style=" font-weight:600; text-decoration: underline;"><br/></span>- Maximum quality when zoom is not enabled.<br/>- Poor quality when zoom is enabled.<br/>- Lowest file size.</p><p><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode<br/></span><span style=" font-style:italic;">Not zoomed images </span><span style=" font-weight:600; font-style:italic;">might </span><span style=" font-style:italic;">be blurry.</span><span style=" font-weight:600; text-decoration: underline;"><br/></span>- High quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.</p><p><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode<br/></span><span style=" font-style:italic;">Maximum possible quality.</span><span style=" font-weight:600; text-decoration: underline;"><br/></span>- Maximum quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.<br/>- Very high file size.</p></body></html></string>
|
<string><html><head/><body><p style="white-space:pre"><span style=" font-weight:600; text-decoration: underline;">Unchecked - Normal quality mode<br/></span>Maximal quality of images but very poor magnification quality.<br/>Use it only when zoom is not needed or output files needs to be small.</p><p style="white-space:pre"><span style=" font-weight:600; text-decoration: underline;">Indeterminate - High quality mode<br/></span>In most cases high quality of images and magnification.<br/>Overall quality highly depends on the resolution of source files.<br/>On Kindle models older than Paperwhite non-zoomed images might be a little blurred.</p><p style="white-space:pre"><span style=" font-weight:600; text-decoration: underline;">Checked - Ultra quality mode<br/></span>Highest possible quality. Output files will be big.</p></body></html></string>
|
||||||
</property>
|
</property>
|
||||||
<property name="text">
|
<property name="text">
|
||||||
<string>High/Ultra quality</string>
|
<string>High/Ultra quality</string>
|
||||||
|
|||||||
@@ -1,7 +1,7 @@
|
|||||||
ISC LICENSE
|
ISC LICENSE
|
||||||
|
|
||||||
Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
Copyright (c) 2013-2014 Paweł Jastrzębski <pawelj@vulturis.eu>
|
Copyright (c) 2013-2014 Paweł Jastrzębski <pawelj@iosphe.re>
|
||||||
|
|
||||||
Permission to use, copy, modify, and/or distribute this software for
|
Permission to use, copy, modify, and/or distribute this software for
|
||||||
any purpose with or without fee is hereby granted, provided that the
|
any purpose with or without fee is hereby granted, provided that the
|
||||||
|
|||||||
132
README.md
132
README.md
@@ -1,13 +1,13 @@
|
|||||||
# KCC
|
# KCC
|
||||||
|
|
||||||
**Kindle Comic Converter** is a Python app to convert comic files or folders to ePub, Panel View MOBI or E-Ink optimized CBZ.
|
**Kindle Comic Converter** is a Python app to convert comic/manga files or folders to EPUB, Panel View MOBI or E-Ink optimized CBZ.
|
||||||
It was initally developed for Kindle but since v2.2 it outputs valid ePub 2.0 so _**despite its name, KCC is
|
It was initially developed for Kindle but since version 2.2 it outputs valid EPUB 2.0 so _**despite its name, KCC is
|
||||||
actually a comic to EPUB converter that every e-reader owner can happily use**_.
|
actually a comic/manga to EPUB converter that every e-reader owner can happily use**_.
|
||||||
It can also optionally optimize images by applying a number of transformations.
|
It can also optionally optimize images by applying a number of transformations.
|
||||||
|
|
||||||
### A word of warning
|
### A word of warning
|
||||||
**KCC** _is not_ [Amazon's Kindle Comic Creator](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1001103761) nor is in any way endorsed by Amazon.
|
**KCC** _is not_ [Amazon's Kindle Comic Creator](http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1001103761) nor is in any way endorsed by Amazon.
|
||||||
Amazon's tool is for comic publishers and involves a lot of manual effort, while **KCC** is for comic readers.
|
Amazon's tool is for comic publishers and involves a lot of manual effort, while **KCC** is for comic/manga readers.
|
||||||
_KC2_ in no way is a replacement for **KCC** so you can be quite confident we'll going to carry on developing our little monster ;-)
|
_KC2_ in no way is a replacement for **KCC** so you can be quite confident we'll going to carry on developing our little monster ;-)
|
||||||
|
|
||||||
### Issues / new features / donations
|
### Issues / new features / donations
|
||||||
@@ -17,14 +17,18 @@ If you can fix an open issue, fork & make a pull request.
|
|||||||
If you want more chances an issue is fixes or your wanted feature added, consider [placing a bounty](https://www.bountysource.com/trackers/65571-ciromattia-kcc)!
|
If you want more chances an issue is fixes or your wanted feature added, consider [placing a bounty](https://www.bountysource.com/trackers/65571-ciromattia-kcc)!
|
||||||
|
|
||||||
If you find **KCC** valuable you can consider donating to the authors:
|
If you find **KCC** valuable you can consider donating to the authors:
|
||||||
* Ciro Mattia Gonano: [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D8WNYNPBGDAS2) [](http://flattr.com/thing/2260449/ciromattiakcc-on-GitHub)
|
- Ciro Mattia Gonano:
|
||||||
* Paweł Jastrzębski: [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YTTJ4LK2JDHPS) [](bitcoin:1W15wwqsfd7wbaZ6wvSJf1LW1bz6q5L8b?label=KCC) [1W15wwqsfd7wbaZ6wvSJf1LW1bz6q5L8b](bitcoin:1W15wwqsfd7wbaZ6wvSJf1LW1bz6q5L8b?label=KCC)
|
- [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=D8WNYNPBGDAS2)
|
||||||
|
- [](http://flattr.com/thing/2260449/ciromattiakcc-on-GitHub)
|
||||||
|
- Paweł Jastrzębski:
|
||||||
|
- [](https://www.paypal.com/cgi-bin/webscr?cmd=_s-xclick&hosted_button_id=YTTJ4LK2JDHPS)
|
||||||
|
- Bitcoin: 1W15wwqsfd7wbaZ6wvSJf1LW1bz6q5L8b
|
||||||
|
|
||||||
## BINARY RELEASES
|
## BINARY RELEASES
|
||||||
You can find the latest released binary at the following links:
|
You can find the latest released binary at the following links:
|
||||||
- **Windows:** [http://kcc.vulturis.eu/Windows/](http://kcc.vulturis.eu/Windows/)
|
- **Windows (Vista or newer):** [http://kcc.iosphe.re/Windows/](http://kcc.iosphe.re/Windows/)
|
||||||
- **Linux:** [http://kcc.vulturis.eu/Linux/](http://kcc.vulturis.eu/Linux/)
|
- **Linux:** [http://kcc.iosphe.re/Linux/](http://kcc.iosphe.re/Linux/)
|
||||||
- **OS X (10.8+):** [http://kcc.vulturis.eu/OSX/](http://kcc.vulturis.eu/OSX/)
|
- **OS X (10.8+):** [http://kcc.iosphe.re/OSX/](http://kcc.iosphe.re/OSX/)
|
||||||
|
|
||||||
## 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:
|
||||||
@@ -32,7 +36,7 @@ You can find the latest released binary at the following links:
|
|||||||
- CBZ, ZIP
|
- CBZ, ZIP
|
||||||
- CBR, RAR *(With `unrar` executable)*
|
- CBR, RAR *(With `unrar` executable)*
|
||||||
- CB7, 7Z *(With `7za` executable)*
|
- CB7, 7Z *(With `7za` executable)*
|
||||||
- PDF *(Extracting only contained JPG images)*
|
- PDF *(Only extracting JPG images)*
|
||||||
|
|
||||||
## OPTIONAL REQUIREMENTS
|
## 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)*
|
- [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)*
|
||||||
@@ -40,10 +44,10 @@ You can find the latest released binary at the following links:
|
|||||||
- [7za](http://www.7-zip.org/download.html) *(For 7z/CB7 support)*
|
- [7za](http://www.7-zip.org/download.html) *(For 7z/CB7 support)*
|
||||||
|
|
||||||
### For running from source:
|
### For running from source:
|
||||||
- Python 3.3
|
- Python 3.3+
|
||||||
- [PyQt5](http://www.riverbankcomputing.co.uk/software/pyqt/download5)
|
- [PyQt5](http://www.riverbankcomputing.co.uk/software/pyqt/download5) 5.2.0+
|
||||||
- [Pillow](http://pypi.python.org/pypi/Pillow/) 2.3.0+
|
- [Pillow](http://pypi.python.org/pypi/Pillow/) 2.5.0+
|
||||||
- [psutil](https://pypi.python.org/pypi/psutil)
|
- [psutil](https://pypi.python.org/pypi/psutil) 2.0+
|
||||||
- [python-slugify](http://pypi.python.org/pypi/python-slugify)
|
- [python-slugify](http://pypi.python.org/pypi/python-slugify)
|
||||||
|
|
||||||
On Debian based distributions these two commands should install all dependencies:
|
On Debian based distributions these two commands should install all dependencies:
|
||||||
@@ -53,8 +57,8 @@ sudo pip3 install pillow python-slugify psutil
|
|||||||
```
|
```
|
||||||
|
|
||||||
### For freezing code:
|
### For freezing code:
|
||||||
- Windows - [cx_Freeze](https://bitbucket.org/anthony_tuininga/cx_freeze) version 4.3.2 with [this](https://bitbucket.org/anthony_tuininga/cx_freeze/pull-request/29/conversions-to-support-untranslated-wide) patchset.
|
- Windows - [py2exe](https://pypi.python.org/pypi/py2exe) 0.9.2+
|
||||||
- OS X - [py2app](https://bitbucket.org/ronaldoussoren/py2app) HEAD version.
|
- OS X - [py2app](https://bitbucket.org/ronaldoussoren/py2app) 0.8.0+
|
||||||
|
|
||||||
## USAGE
|
## USAGE
|
||||||
|
|
||||||
@@ -63,15 +67,19 @@ After completed conversion you should find ready file alongside the original inp
|
|||||||
|
|
||||||
Please check [our wiki](https://github.com/ciromattia/kcc/wiki/) for more details.
|
Please check [our wiki](https://github.com/ciromattia/kcc/wiki/) for more details.
|
||||||
|
|
||||||
### Standalone `comic2ebook.py` usage:
|
CLI version of **KCC** is intended for power users. It is not idiot-proof like GUI :-)
|
||||||
|
|
||||||
|
### Standalone `kcc-c2e.py` usage:
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage: comic2ebook.py [options] comic_file|comic_folder
|
Usage: kcc-c2e [options] comic_file|comic_folder
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
MAIN:
|
MAIN:
|
||||||
-p PROFILE, --profile=PROFILE
|
-p PROFILE, --profile=PROFILE
|
||||||
Device profile (Choose one among K1, K2, K345, KDX, KHD, KF, KFHD, KFHD8, KFHDX, KFHDX8, KFA, KoMT, KoG, KoA, KoAHD) [Default=KHD]
|
Device profile (Available options: K1, K2, K345, KDX,
|
||||||
|
KPW, KV, KFHD, KFHDX, KFHDX8, KFA, KoMT, KoG, KoA,
|
||||||
|
KoAHD, KoAH2O) [Default=KV]
|
||||||
-q QUALITY, --quality=QUALITY
|
-q QUALITY, --quality=QUALITY
|
||||||
Quality of Panel View. 0 - Normal 1 - High 2 - Ultra [Default=0]
|
Quality of Panel View. 0 - Normal 1 - High 2 - Ultra [Default=0]
|
||||||
-m, --manga-style Manga style (Right-to-left reading and splitting)
|
-m, --manga-style Manga style (Right-to-left reading and splitting)
|
||||||
@@ -82,7 +90,9 @@ Options:
|
|||||||
Output generated file to specified directory or file
|
Output generated file to specified directory or file
|
||||||
-t TITLE, --title=TITLE
|
-t TITLE, --title=TITLE
|
||||||
Comic title [Default=filename or directory name]
|
Comic title [Default=filename or directory name]
|
||||||
--cbz-output Outputs a CBZ archive and does not generate EPUB
|
-f FORMAT, --format=FORMAT
|
||||||
|
Output format (Available options: Auto, MOBI,
|
||||||
|
EPUB, CBZ) [Default=Auto]
|
||||||
--batchsplit Split output into multiple files
|
--batchsplit Split output into multiple files
|
||||||
|
|
||||||
PROCESSING:
|
PROCESSING:
|
||||||
@@ -108,10 +118,10 @@ Options:
|
|||||||
-h, --help Show this help message and exit
|
-h, --help Show this help message and exit
|
||||||
```
|
```
|
||||||
|
|
||||||
### Standalone `comic2panel.py` usage:
|
### Standalone `kcc-c2p.py` usage:
|
||||||
|
|
||||||
```
|
```
|
||||||
Usage: comic2panel.py [options] comic_folder
|
Usage: kcc-c2p [options] comic_folder
|
||||||
|
|
||||||
Options:
|
Options:
|
||||||
MANDATORY:
|
MANDATORY:
|
||||||
@@ -126,29 +136,27 @@ Options:
|
|||||||
```
|
```
|
||||||
|
|
||||||
## CREDITS
|
## CREDITS
|
||||||
**KCC** is made by [Ciro Mattia Gonano](http://github.com/ciromattia) and [Paweł Jastrzębski](http://github.com/AcidWeb)
|
**KCC** is made by [Ciro Mattia Gonano](http://github.com/ciromattia) and [Paweł Jastrzębski](http://github.com/AcidWeb).
|
||||||
|
|
||||||
This script born as a cross-platform alternative to `KindleComicParser` by **Dc5e** (published [here](http://www.mobileread.com/forums/showthread.php?t=192783))
|
This script born as a cross-platform alternative to `KindleComicParser` by **Dc5e** (published [here](http://www.mobileread.com/forums/showthread.php?t=192783)).
|
||||||
|
|
||||||
The app relies and includes the following scripts/binaries:
|
The app relies and includes the following scripts:
|
||||||
|
|
||||||
- `KindleUnpack` script by Charles **M. Hannum, P. Durrant, K. Hendricks, S. Siebert, fandrieu, DiapDealer, nickredding**. Released with GPLv3 License.
|
- `DualMetaFix` script by **K. Hendricks**. Released with GPL-3 License.
|
||||||
- `rarfile.py` script © 2005-2011 **Marko Kreen** <markokr@gmail.com>. Released with ISC License.
|
- `rarfile.py` script © 2005-2011 **Marko Kreen** <markokr@gmail.com>. Released with ISC License.
|
||||||
- `image.py` class from **Alex Yatskov**'s [Mangle](http://foosoft.net/mangle/) with subsequent [proDOOMman](https://github.com/proDOOMman/Mangle)'s and [Birua](https://github.com/Birua/Mangle)'s patches.
|
- `image.py` class from **Alex Yatskov**'s [Mangle](https://github.com/FooSoft/mangle/) with subsequent [proDOOMman](https://github.com/proDOOMman/Mangle)'s and [Birua](https://github.com/Birua/Mangle)'s patches.
|
||||||
- Icon is by **Nikolay Verin** ([http://ncrow.deviantart.com/](http://ncrow.deviantart.com/)) and released under [CC BY-NC-SA 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/) License.
|
- Icon is by **Nikolay Verin** ([http://ncrow.deviantart.com/](http://ncrow.deviantart.com/)) and released under [CC BY-NC-SA 3.0](http://creativecommons.org/licenses/by-nc-sa/3.0/) License.
|
||||||
|
|
||||||
## SAMPLE FILES CREATED BY KCC
|
## SAMPLE FILES CREATED BY KCC
|
||||||
* [Kindle Paperwhite](http://kcc.vulturis.eu/Samples/Ubunchu!-KPW.mobi)
|
* [Kindle Voyage](http://kcc.iosphe.re/Samples/Ubunchu!-KV.mobi)
|
||||||
* [Kindle](http://kcc.vulturis.eu/Samples/Ubunchu!-K345.mobi)
|
* [Kindle Paperwhite](http://kcc.iosphe.re/Samples/Ubunchu!-KPW.mobi)
|
||||||
* [Kindle DX/DXG](http://kcc.vulturis.eu/Samples/Ubunchu!-KDX.mobi)
|
* [Kindle](http://kcc.iosphe.re/Samples/Ubunchu!-K345.mobi)
|
||||||
* [Kindle Fire HD](http://kcc.vulturis.eu/Samples/Ubunchu!-KFHD.mobi)
|
* [Kindle DX/DXG](http://kcc.iosphe.re/Samples/Ubunchu!-KDX.cbz)
|
||||||
* [Kindle Fire HD 8.9"](http://kcc.vulturis.eu/Samples/Ubunchu!-KFHD8.mobi)
|
* [Kobo Mini/Touch](http://kcc.iosphe.re/Samples/Ubunchu!-KoMT.cbz)
|
||||||
* [Kindle Fire HDX](http://kcc.vulturis.eu/Samples/Ubunchu!-KFHDX.mobi)
|
* [Kobo Glow](http://kcc.iosphe.re/Samples/Ubunchu!-KoG.cbz)
|
||||||
* [Kindle Fire HDX 8.9"](http://kcc.vulturis.eu/Samples/Ubunchu!-KFHDX8.mobi)
|
* [Kobo Aura](http://kcc.iosphe.re/Samples/Ubunchu!-KoA.cbz)
|
||||||
* [Kobo Mini/Touch](http://kcc.vulturis.eu/Samples/Ubunchu!-KoMT.cbz)
|
* [Kobo Aura HD](http://kcc.iosphe.re/Samples/Ubunchu!-KoAHD.cbz)
|
||||||
* [Kobo Glow](http://kcc.vulturis.eu/Samples/Ubunchu!-KoG.cbz)
|
* [Kobo Aura H2O](http://kcc.iosphe.re/Samples/Ubunchu!-KoAH2O.cbz)
|
||||||
* [Kobo Aura](http://kcc.vulturis.eu/Samples/Ubunchu!-KoA.cbz)
|
|
||||||
* [Kobo Aura HD](http://kcc.vulturis.eu/Samples/Ubunchu!-KoAHD.cbz)
|
|
||||||
|
|
||||||
## CHANGELOG
|
## CHANGELOG
|
||||||
####1.0
|
####1.0
|
||||||
@@ -184,11 +192,11 @@ The app relies and includes the following scripts/binaries:
|
|||||||
* Added basic error reporting
|
* Added basic error reporting
|
||||||
|
|
||||||
####2.2:
|
####2.2:
|
||||||
* Added (valid!) ePub 2.0 output
|
* Added (valid!) EPUB 2.0 output
|
||||||
* Rename .zip files to .cbz to avoid overwriting
|
* Rename .zip files to .cbz to avoid overwriting
|
||||||
|
|
||||||
####2.3
|
####2.3
|
||||||
* Fixed win32 ePub generation, folder handling, filenames with spaces and subfolders
|
* Fixed win32 EPUB generation, folder handling, filenames with spaces and subfolders
|
||||||
|
|
||||||
####2.4
|
####2.4
|
||||||
* Use temporary directory as workdir (fixes converting from external volumes and zipfiles renaming)
|
* Use temporary directory as workdir (fixes converting from external volumes and zipfiles renaming)
|
||||||
@@ -196,22 +204,22 @@ The app relies and includes the following scripts/binaries:
|
|||||||
|
|
||||||
####2.5
|
####2.5
|
||||||
* Added --black-borders option to set added borders black when page's ratio is not the device's one (#11).
|
* Added --black-borders option to set added borders black when page's ratio is not the device's one (#11).
|
||||||
* Fixes epub containing zipped itself (#10)
|
* Fixes EPUB containing zipped itself (#10)
|
||||||
|
|
||||||
####2.6
|
####2.6
|
||||||
* Added --rotate option to rotate landscape images instead of splitting them (#16, #24)
|
* Added --rotate option to rotate landscape images instead of splitting them (#16, #24)
|
||||||
* Added --output option to customize ePub output dir/file (#22)
|
* Added --output option to customize EPUB output dir/file (#22)
|
||||||
* Add rendition:layout and rendition:orientation ePub meta tags (supported by new kindlegen 2.8)
|
* Add rendition:layout and rendition:orientation EPUB meta tags (supported by new kindlegen 2.8)
|
||||||
* Fixed natural sorting for files (#18)
|
* Fixed natural sorting for files (#18)
|
||||||
|
|
||||||
####2.7
|
####2.7
|
||||||
* Lots of GUI improvements (#27, #13)
|
* Lots of GUI improvements (#27, #13)
|
||||||
* Added gamma support within --gamma option (defaults to profile-specified gamma) (#26, #27)
|
* Added gamma support within --gamma option (defaults to profile-specified gamma) (#26, #27)
|
||||||
* Added --nodithering option to prevent dithering optimizations (#27)
|
* Added --nodithering option to prevent dithering optimizations (#27)
|
||||||
* Epub margins support (#30)
|
* EPUB margins support (#30)
|
||||||
* Fixed no file added if file has no spaces on Windows (#25)
|
* Fixed no file added if file has no spaces on Windows (#25)
|
||||||
* Gracefully exit if unrar missing (#15)
|
* Gracefully exit if unrar missing (#15)
|
||||||
* Do not call kindlegen if source epub is bigger than 320MB (#17)
|
* Do not call kindlegen if source EPUB is bigger than 320MB (#17)
|
||||||
* Get filetype from magic number (#14)
|
* Get filetype from magic number (#14)
|
||||||
* PDF conversion works again
|
* PDF conversion works again
|
||||||
|
|
||||||
@@ -225,7 +233,7 @@ The app relies and includes the following scripts/binaries:
|
|||||||
* Optimized archive extraction for zip/rar files (#40)
|
* Optimized archive extraction for zip/rar files (#40)
|
||||||
|
|
||||||
####2.9
|
####2.9
|
||||||
* Added support for generating a plain CBZ (skipping all the EPUB/Mobi generation) (#45)
|
* Added support for generating a plain CBZ (skipping all the EPUB/MOBI generation) (#45)
|
||||||
* Prevent output file overwriting the source one: if a duplicate name is detected, append _kcc to the name
|
* Prevent output file overwriting the source one: if a duplicate name is detected, append _kcc to the name
|
||||||
* Rarfile library updated to 2.6
|
* Rarfile library updated to 2.6
|
||||||
* Added GIF, TIFF and BMP to supported formats (#42)
|
* Added GIF, TIFF and BMP to supported formats (#42)
|
||||||
@@ -233,7 +241,7 @@ The app relies and includes the following scripts/binaries:
|
|||||||
|
|
||||||
####2.10:
|
####2.10:
|
||||||
* Multiprocessing support
|
* Multiprocessing support
|
||||||
* Kindle Fire support (color ePub/Mobi)
|
* Kindle Fire support (color EPUB/MOBI)
|
||||||
* Panel View support for horizontal content
|
* Panel View support for horizontal content
|
||||||
* Fixed panel order for horizontal pages when --rotate is enabled
|
* Fixed panel order for horizontal pages when --rotate is enabled
|
||||||
* Disabled cropping and page number cutting for blank pages
|
* Disabled cropping and page number cutting for blank pages
|
||||||
@@ -339,6 +347,36 @@ The app relies and includes the following scripts/binaries:
|
|||||||
* Improved performance of WebToon splitter
|
* Improved performance of WebToon splitter
|
||||||
* Tweaked margin color detection
|
* Tweaked margin color detection
|
||||||
|
|
||||||
|
####4.0.2:
|
||||||
|
* Fixed some Windows and OSX specific bugs
|
||||||
|
* Fixed problem with marigns when using HQ mode
|
||||||
|
|
||||||
|
####4.1:
|
||||||
|
* Thanks to code contributed by Kevin Hendricks speed of MOBI creation was greatly increased
|
||||||
|
* Improved performance on Windows
|
||||||
|
* Improved MOBI splitting and changed maximal size of output file
|
||||||
|
* Fixed _No optimization_ mode
|
||||||
|
* Multiple small tweaks nad minor bug fixes
|
||||||
|
|
||||||
|
####4.2:
|
||||||
|
* Added [Manga Cover Database](http://manga.joentjuh.nl/) support
|
||||||
|
* Officially dropped Windows XP support
|
||||||
|
* Fixed _Other_ profile
|
||||||
|
* Fixed problems with page order on stock KOBO CBZ reader
|
||||||
|
* Many other small bug fixes and tweaks
|
||||||
|
|
||||||
|
####4.2.1:
|
||||||
|
* Improved margin color detection
|
||||||
|
* Fixed random crashes of MOBI processing step
|
||||||
|
* Fixed resizing problems in high quality mode
|
||||||
|
* Fixed some MCD support bugs
|
||||||
|
* Default output format for Kindle DX is now CBZ
|
||||||
|
|
||||||
|
####4.3:
|
||||||
|
* Added profiles for Kindle Voyage and Kobo Aura H2O
|
||||||
|
* Added missing features to CLI version
|
||||||
|
* Other minor bug fixes
|
||||||
|
|
||||||
## KNOWN ISSUES
|
## KNOWN ISSUES
|
||||||
Please check [wiki page](https://github.com/ciromattia/kcc/wiki/Known-issues).
|
Please check [wiki page](https://github.com/ciromattia/kcc/wiki/Known-issues).
|
||||||
|
|
||||||
|
|||||||
34
kcc-c2e.py
34
kcc-c2e.py
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
# any purpose with or without fee is hereby granted, provided that the
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
__version__ = '4.0.1'
|
__version__ = '4.3'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@@ -28,25 +28,27 @@ if sys.version_info[0] != 3:
|
|||||||
print('ERROR: This is Python 3 script!')
|
print('ERROR: This is Python 3 script!')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Dependiences check
|
# Dependency check
|
||||||
missing = []
|
missing = []
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from psutil import TOTAL_PHYMEM, Popen
|
import psutil
|
||||||
|
if tuple(map(int, ('2.0.0'.split(".")))) > tuple(map(int, psutil.version_info)):
|
||||||
|
missing.append('psutil 2.0.0+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('psutil')
|
missing.append('psutil 2.0.0+')
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from slugify import slugify
|
import PIL
|
||||||
|
if tuple(map(int, ('2.5.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
|
||||||
|
missing.append('Pillow 2.5.0+')
|
||||||
|
except ImportError:
|
||||||
|
missing.append('Pillow 2.5.0+')
|
||||||
|
try:
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
import slugify
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('python-slugify')
|
missing.append('python-slugify')
|
||||||
try:
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from PIL import Image, ImageOps, ImageStat, ImageChops
|
|
||||||
if tuple(map(int, ('2.3.0'.split(".")))) > tuple(map(int, (Image.PILLOW_VERSION.split(".")))):
|
|
||||||
missing.append('Pillow 2.3.0+')
|
|
||||||
except ImportError:
|
|
||||||
missing.append('Pillow 2.3.0+')
|
|
||||||
if len(missing) > 0:
|
if len(missing) > 0:
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
@@ -61,10 +63,10 @@ if len(missing) > 0:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
from multiprocessing import freeze_support
|
from multiprocessing import freeze_support
|
||||||
from kcc.comic2ebook import main, Copyright
|
from kcc.comic2ebook import main
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
freeze_support()
|
freeze_support()
|
||||||
Copyright()
|
print(('comic2ebook v%(__version__)s. Written by Ciro Mattia Gonano and Pawel Jastrzebski.' % globals()))
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
26
kcc-c2p.py
26
kcc-c2p.py
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
# any purpose with or without fee is hereby granted, provided that the
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
@@ -18,25 +18,25 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
|
__version__ = '4.3'
|
||||||
|
__license__ = 'ISC'
|
||||||
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
if sys.version_info[0] != 3:
|
if sys.version_info[0] != 3:
|
||||||
print('ERROR: This is Python 3 script!')
|
print('ERROR: This is Python 3 script!')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
__version__ = '4.0.1'
|
# Dependency check
|
||||||
__license__ = 'ISC'
|
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
|
||||||
__docformat__ = 'restructuredtext en'
|
|
||||||
|
|
||||||
# Dependiences check
|
|
||||||
missing = []
|
missing = []
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from PIL import Image, ImageOps, ImageStat, ImageChops
|
import PIL
|
||||||
if tuple(map(int, ('2.3.0'.split(".")))) > tuple(map(int, (Image.PILLOW_VERSION.split(".")))):
|
if tuple(map(int, ('2.5.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
|
||||||
missing.append('Pillow 2.3.0+')
|
missing.append('Pillow 2.5.0+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('Pillow 2.3.0+')
|
missing.append('Pillow 2.5.0+')
|
||||||
if len(missing) > 0:
|
if len(missing) > 0:
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
@@ -51,10 +51,10 @@ if len(missing) > 0:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
from multiprocessing import freeze_support
|
from multiprocessing import freeze_support
|
||||||
from kcc.comic2panel import main, Copyright
|
from kcc.comic2panel import main
|
||||||
|
|
||||||
if __name__ == "__main__":
|
if __name__ == "__main__":
|
||||||
freeze_support()
|
freeze_support()
|
||||||
Copyright()
|
print(('comic2ebook v%(__version__)s. Written by Ciro Mattia Gonano and Pawel Jastrzebski.' % globals()))
|
||||||
main(sys.argv[1:])
|
main(sys.argv[1:])
|
||||||
sys.exit(0)
|
sys.exit(0)
|
||||||
21
kcc.iss
21
kcc.iss
@@ -1,7 +1,7 @@
|
|||||||
#define MyAppName "Kindle Comic Converter"
|
#define MyAppName "Kindle Comic Converter"
|
||||||
#define MyAppVersion "4.0.1"
|
#define MyAppVersion "4.3"
|
||||||
#define MyAppPublisher "Ciro Mattia Gonano, Paweł Jastrzębski"
|
#define MyAppPublisher "Ciro Mattia Gonano, Paweł Jastrzębski"
|
||||||
#define MyAppURL "http://kcc.vulturis.eu/"
|
#define MyAppURL "http://kcc.iosphe.re/"
|
||||||
#define MyAppExeName "KCC.exe"
|
#define MyAppExeName "KCC.exe"
|
||||||
|
|
||||||
[Setup]
|
[Setup]
|
||||||
@@ -30,6 +30,7 @@ UninstallDisplayIcon={app}\{#MyAppExeName}
|
|||||||
ChangesAssociations=True
|
ChangesAssociations=True
|
||||||
InfoAfterFile=other\InstallWarning.rtf
|
InfoAfterFile=other\InstallWarning.rtf
|
||||||
SignTool=SignTool /d $q{#MyAppName}$q /du $q{#MyAppURL}$q $f
|
SignTool=SignTool /d $q{#MyAppName}$q /du $q{#MyAppURL}$q $f
|
||||||
|
MinVersion=0,6.0
|
||||||
|
|
||||||
[Languages]
|
[Languages]
|
||||||
Name: "english"; MessagesFile: "compiler:Default.isl"
|
Name: "english"; MessagesFile: "compiler:Default.isl"
|
||||||
@@ -42,18 +43,14 @@ Name: "CB7association"; Description: "CB7"; GroupDescription: "File associations
|
|||||||
|
|
||||||
[Files]
|
[Files]
|
||||||
; x64 files
|
; x64 files
|
||||||
Source: "build\exe.win-amd64-3.3\imageformats\*"; DestDir: "{app}\imageformats\"; Flags: ignoreversion; Check: Is64BitInstallMode
|
Source: "dist_64\platforms\*"; DestDir: "{app}\platforms\"; Flags: ignoreversion; Check: Is64BitInstallMode
|
||||||
Source: "build\exe.win-amd64-3.3\platforms\*"; DestDir: "{app}\platforms\"; Flags: ignoreversion; Check: Is64BitInstallMode
|
Source: "dist_64\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
|
||||||
Source: "build\exe.win-amd64-3.3\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
|
Source: "dist_64\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
|
||||||
Source: "build\exe.win-amd64-3.3\*.pyd"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
|
|
||||||
Source: "build\exe.win-amd64-3.3\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: Is64BitInstallMode
|
|
||||||
Source: "other\vcredist_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: Is64BitInstallMode
|
Source: "other\vcredist_x64.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: Is64BitInstallMode
|
||||||
; x86 files
|
; x86 files
|
||||||
Source: "build\exe.win32-3.3\imageformats\*"; DestDir: "{app}\imageformats\"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
Source: "dist\platforms\*"; DestDir: "{app}\platforms\"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
||||||
Source: "build\exe.win32-3.3\platforms\*"; DestDir: "{app}\platforms\"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
Source: "dist\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
||||||
Source: "build\exe.win32-3.3\{#MyAppExeName}"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
Source: "dist\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
||||||
Source: "build\exe.win32-3.3\*.pyd"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
|
||||||
Source: "build\exe.win32-3.3\*.dll"; DestDir: "{app}"; Flags: ignoreversion; Check: not Is64BitInstallMode
|
|
||||||
Source: "other\vcredist_x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: not Is64BitInstallMode
|
Source: "other\vcredist_x86.exe"; DestDir: "{tmp}"; Flags: ignoreversion deleteafterinstall; Check: not Is64BitInstallMode
|
||||||
; Common files
|
; Common files
|
||||||
Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion solidbreak
|
Source: "LICENSE.txt"; DestDir: "{app}"; Flags: ignoreversion solidbreak
|
||||||
|
|||||||
88
kcc.py
88
kcc.py
@@ -2,7 +2,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
# any purpose with or without fee is hereby granted, provided that the
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
__version__ = '4.0.1'
|
__version__ = '4.3'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@@ -28,30 +28,34 @@ if sys.version_info[0] != 3:
|
|||||||
print('ERROR: This is Python 3 script!')
|
print('ERROR: This is Python 3 script!')
|
||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
# Dependiences check
|
# Dependency check
|
||||||
missing = []
|
missing = []
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from PyQt5 import QtCore, QtGui, QtNetwork, QtWidgets
|
from PyQt5 import QtCore, QtNetwork, QtWidgets
|
||||||
|
if tuple(map(int, ('5.2.0'.split(".")))) > tuple(map(int, (QtCore.qVersion().split(".")))):
|
||||||
|
missing.append('PyQt5 5.2.0+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('PyQt5')
|
missing.append('PyQt5 5.2.0+')
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from psutil import TOTAL_PHYMEM, Popen
|
import psutil
|
||||||
|
if tuple(map(int, ('2.0.0'.split(".")))) > tuple(map(int, psutil.version_info)):
|
||||||
|
missing.append('psutil 2.0.0+')
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('psutil')
|
missing.append('psutil 2.0.0+')
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
from slugify import slugify
|
import PIL
|
||||||
|
if tuple(map(int, ('2.5.0'.split(".")))) > tuple(map(int, (PIL.PILLOW_VERSION.split(".")))):
|
||||||
|
missing.append('Pillow 2.5.0+')
|
||||||
|
except ImportError:
|
||||||
|
missing.append('Pillow 2.5.0+')
|
||||||
|
try:
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
import slugify
|
||||||
except ImportError:
|
except ImportError:
|
||||||
missing.append('python-slugify')
|
missing.append('python-slugify')
|
||||||
try:
|
|
||||||
# noinspection PyUnresolvedReferences
|
|
||||||
from PIL import Image, ImageOps, ImageStat, ImageChops
|
|
||||||
if tuple(map(int, ('2.3.0'.split(".")))) > tuple(map(int, (Image.PILLOW_VERSION.split(".")))):
|
|
||||||
missing.append('Pillow 2.3.0+')
|
|
||||||
except ImportError:
|
|
||||||
missing.append('Pillow 2.3.0+')
|
|
||||||
if len(missing) > 0:
|
if len(missing) > 0:
|
||||||
try:
|
try:
|
||||||
# noinspection PyUnresolvedReferences
|
# noinspection PyUnresolvedReferences
|
||||||
@@ -78,6 +82,16 @@ if sys.platform.startswith('darwin'):
|
|||||||
elif sys.platform.startswith('win'):
|
elif sys.platform.startswith('win'):
|
||||||
if getattr(sys, 'frozen', False):
|
if getattr(sys, 'frozen', False):
|
||||||
os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
|
os.chdir(os.path.dirname(os.path.abspath(sys.executable)))
|
||||||
|
|
||||||
|
# Implementing dummy stdout and stderr for frozen Windows release
|
||||||
|
class FakeSTD(object):
|
||||||
|
def write(self, string):
|
||||||
|
pass
|
||||||
|
|
||||||
|
def flush(self):
|
||||||
|
pass
|
||||||
|
sys.stdout = FakeSTD()
|
||||||
|
sys.stderr = FakeSTD()
|
||||||
else:
|
else:
|
||||||
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/;' + os.environ['PATH']
|
os.environ['PATH'] = os.path.dirname(os.path.abspath(__file__)) + '/other/;' + os.environ['PATH']
|
||||||
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
os.chdir(os.path.dirname(os.path.abspath(__file__)))
|
||||||
@@ -89,35 +103,33 @@ class QApplicationMessaging(QtWidgets.QApplication):
|
|||||||
|
|
||||||
def __init__(self, argv):
|
def __init__(self, argv):
|
||||||
QtWidgets.QApplication.__init__(self, argv)
|
QtWidgets.QApplication.__init__(self, argv)
|
||||||
self._memory = QtCore.QSharedMemory(self)
|
|
||||||
self._memory.setKey('KCC')
|
|
||||||
if self._memory.attach():
|
|
||||||
self._running = True
|
|
||||||
else:
|
|
||||||
self._running = False
|
|
||||||
self._memory.create(1)
|
|
||||||
self._key = 'KCC'
|
self._key = 'KCC'
|
||||||
self._timeout = 1000
|
self._timeout = 1000
|
||||||
self._server = QtNetwork.QLocalServer(self)
|
self._locked = False
|
||||||
if not self.isRunning():
|
socket = QtNetwork.QLocalSocket(self)
|
||||||
|
socket.connectToServer(self._key, QtCore.QIODevice.WriteOnly)
|
||||||
|
if not socket.waitForConnected(self._timeout):
|
||||||
|
self._server = QtNetwork.QLocalServer(self)
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
self._server.newConnection.connect(self.handleMessage)
|
self._server.newConnection.connect(self.handleMessage)
|
||||||
self._server.listen(self._key)
|
self._server.listen(self._key)
|
||||||
|
else:
|
||||||
|
self._locked = True
|
||||||
|
socket.disconnectFromServer()
|
||||||
|
|
||||||
def __del__(self):
|
def __del__(self):
|
||||||
if self._memory.isAttached():
|
if not self._locked:
|
||||||
self._memory.detach()
|
|
||||||
self._server.close()
|
self._server.close()
|
||||||
|
|
||||||
def event(self, e):
|
def event(self, e):
|
||||||
if e.type() == QtCore.QEvent.FileOpen:
|
if e.type() == QtCore.QEvent.FileOpen:
|
||||||
# noinspection PyArgumentList
|
|
||||||
self.messageFromOtherInstance.emit(bytes(e.file(), 'UTF-8'))
|
self.messageFromOtherInstance.emit(bytes(e.file(), 'UTF-8'))
|
||||||
return True
|
return True
|
||||||
else:
|
else:
|
||||||
return QtWidgets.QApplication.event(self, e)
|
return QtWidgets.QApplication.event(self, e)
|
||||||
|
|
||||||
def isRunning(self):
|
def isRunning(self):
|
||||||
return self._running
|
return self._locked
|
||||||
|
|
||||||
def handleMessage(self):
|
def handleMessage(self):
|
||||||
socket = self._server.nextPendingConnection()
|
socket = self._server.nextPendingConnection()
|
||||||
@@ -125,18 +137,12 @@ class QApplicationMessaging(QtWidgets.QApplication):
|
|||||||
self.messageFromOtherInstance.emit(socket.readAll().data())
|
self.messageFromOtherInstance.emit(socket.readAll().data())
|
||||||
|
|
||||||
def sendMessage(self, message):
|
def sendMessage(self, message):
|
||||||
if self.isRunning():
|
socket = QtNetwork.QLocalSocket(self)
|
||||||
socket = QtNetwork.QLocalSocket(self)
|
socket.connectToServer(self._key, QtCore.QIODevice.WriteOnly)
|
||||||
socket.connectToServer(self._key, QtCore.QIODevice.WriteOnly)
|
socket.waitForConnected(self._timeout)
|
||||||
if not socket.waitForConnected(self._timeout):
|
socket.write(bytes(message, 'UTF-8'))
|
||||||
return False
|
socket.waitForBytesWritten(self._timeout)
|
||||||
# noinspection PyArgumentList
|
socket.disconnectFromServer()
|
||||||
socket.write(bytes(message, 'UTF-8'))
|
|
||||||
if not socket.waitForBytesWritten(self._timeout):
|
|
||||||
return False
|
|
||||||
socket.disconnectFromServer()
|
|
||||||
return True
|
|
||||||
return False
|
|
||||||
|
|
||||||
|
|
||||||
# Adding signals to QMainWindow
|
# Adding signals to QMainWindow
|
||||||
|
|||||||
303
kcc/KCC_gui.py
303
kcc/KCC_gui.py
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
# any purpose with or without fee is hereby granted, provided that the
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
@@ -17,9 +17,9 @@
|
|||||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
|
|
||||||
__version__ = '4.0.1'
|
__version__ = '4.3'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -36,10 +36,10 @@ from subprocess import STDOUT, PIPE
|
|||||||
from PyQt5 import QtGui, QtCore, QtWidgets
|
from PyQt5 import QtGui, QtCore, QtWidgets
|
||||||
from xml.dom.minidom import parse
|
from xml.dom.minidom import parse
|
||||||
from html.parser import HTMLParser
|
from html.parser import HTMLParser
|
||||||
from psutil import TOTAL_PHYMEM, Popen
|
from psutil import Popen, Process
|
||||||
|
from copy import copy
|
||||||
from .shared import md5Checksum
|
from .shared import md5Checksum
|
||||||
from . import comic2ebook
|
from . import comic2ebook
|
||||||
from . import kindlesplit
|
|
||||||
from . import KCC_rc_web
|
from . import KCC_rc_web
|
||||||
if sys.platform.startswith('darwin'):
|
if sys.platform.startswith('darwin'):
|
||||||
from . import KCC_ui_osx as KCC_ui
|
from . import KCC_ui_osx as KCC_ui
|
||||||
@@ -195,7 +195,7 @@ class VersionThread(QtCore.QThread):
|
|||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
try:
|
try:
|
||||||
XML = urlopen('http://kcc.vulturis.eu/Version.php')
|
XML = urlopen('http://kcc.iosphe.re/Version.php')
|
||||||
XML = parse(XML)
|
XML = parse(XML)
|
||||||
except Exception:
|
except Exception:
|
||||||
return
|
return
|
||||||
@@ -209,7 +209,7 @@ class VersionThread(QtCore.QThread):
|
|||||||
'<br/>Current version: ' + latestVersion +
|
'<br/>Current version: ' + latestVersion +
|
||||||
'<br/><br/>Would you like to start automatic update?', 'question')
|
'<br/><br/>Would you like to start automatic update?', 'question')
|
||||||
else:
|
else:
|
||||||
MW.addMessage.emit('<a href="http://kcc.vulturis.eu/">'
|
MW.addMessage.emit('<a href="http://kcc.iosphe.re/">'
|
||||||
'<b>New version is available!</b></a> '
|
'<b>New version is available!</b></a> '
|
||||||
'(<a href="https://github.com/ciromattia/kcc/releases/">'
|
'(<a href="https://github.com/ciromattia/kcc/releases/">'
|
||||||
'Changelog</a>)', 'warning', False)
|
'Changelog</a>)', 'warning', False)
|
||||||
@@ -219,7 +219,7 @@ class VersionThread(QtCore.QThread):
|
|||||||
try:
|
try:
|
||||||
MW.modeConvert.emit(-1)
|
MW.modeConvert.emit(-1)
|
||||||
MW.progressBarTick.emit('Downloading update')
|
MW.progressBarTick.emit('Downloading update')
|
||||||
path = urlretrieve('http://kcc.vulturis.eu/Windows/KindleComicConverter_win_'
|
path = urlretrieve('http://kcc.iosphe.re/Windows/KindleComicConverter_win_'
|
||||||
+ self.newVersion + '.exe', reporthook=self.getNewVersionTick)
|
+ self.newVersion + '.exe', reporthook=self.getNewVersionTick)
|
||||||
if self.md5 != md5Checksum(path[0]):
|
if self.md5 != md5Checksum(path[0]):
|
||||||
raise Exception
|
raise Exception
|
||||||
@@ -263,90 +263,14 @@ class ProgressThread(QtCore.QThread):
|
|||||||
self.running = False
|
self.running = False
|
||||||
|
|
||||||
|
|
||||||
class WorkerSignals(QtCore.QObject):
|
|
||||||
result = QtCore.pyqtSignal(list)
|
|
||||||
|
|
||||||
|
|
||||||
class KindleGenThread(QtCore.QRunnable):
|
|
||||||
def __init__(self, batch):
|
|
||||||
super(KindleGenThread, self).__init__()
|
|
||||||
self.signals = WorkerSignals()
|
|
||||||
self.work = batch
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
kindlegenErrorCode = 0
|
|
||||||
kindlegenError = ''
|
|
||||||
try:
|
|
||||||
if os.path.getsize(self.work) < 367001600:
|
|
||||||
output = Popen('kindlegen -locale en "' + self.work + '"', stdout=PIPE, stderr=STDOUT, shell=True)
|
|
||||||
for line in output.stdout:
|
|
||||||
line = line.decode('utf-8')
|
|
||||||
# ERROR: Generic error
|
|
||||||
if "Error(" in line:
|
|
||||||
kindlegenErrorCode = 1
|
|
||||||
kindlegenError = line
|
|
||||||
# ERROR: EPUB too big
|
|
||||||
if ":E23026:" in line:
|
|
||||||
kindlegenErrorCode = 23026
|
|
||||||
if kindlegenErrorCode > 0:
|
|
||||||
break
|
|
||||||
else:
|
|
||||||
# ERROR: EPUB too big
|
|
||||||
kindlegenErrorCode = 23026
|
|
||||||
self.signals.result.emit([kindlegenErrorCode, kindlegenError, self.work])
|
|
||||||
except Exception as err:
|
|
||||||
# ERROR: KCC unknown generic error
|
|
||||||
kindlegenErrorCode = 1
|
|
||||||
kindlegenError = format(err)
|
|
||||||
self.signals.result.emit([kindlegenErrorCode, kindlegenError, self.work])
|
|
||||||
|
|
||||||
|
|
||||||
class KindleUnpackThread(QtCore.QRunnable):
|
|
||||||
def __init__(self, batch):
|
|
||||||
super(KindleUnpackThread, self).__init__()
|
|
||||||
self.signals = WorkerSignals()
|
|
||||||
self.work = batch
|
|
||||||
|
|
||||||
def run(self):
|
|
||||||
item = self.work[0]
|
|
||||||
profile = self.work[1]
|
|
||||||
os.remove(item)
|
|
||||||
mobiPath = item.replace('.epub', '.mobi')
|
|
||||||
move(mobiPath, mobiPath + '_toclean')
|
|
||||||
try:
|
|
||||||
# MOBI file produced by KindleGen is hybrid. KF8 + M7 + Source header
|
|
||||||
# KindleSplit is removing redundant data as we need only KF8 part for new Kindle models
|
|
||||||
if profile in ['K345', 'KHD', 'KF', 'KFHD', 'KFHD8', 'KFHDX', 'KFHDX8', 'KFA']:
|
|
||||||
newKindle = True
|
|
||||||
else:
|
|
||||||
newKindle = False
|
|
||||||
mobisplit = kindlesplit.mobi_split(mobiPath + '_toclean', newKindle)
|
|
||||||
open(mobiPath, 'wb').write(mobisplit.getResult())
|
|
||||||
self.signals.result.emit([True])
|
|
||||||
except Exception as err:
|
|
||||||
self.signals.result.emit([False, format(err)])
|
|
||||||
|
|
||||||
|
|
||||||
class WorkerThread(QtCore.QThread):
|
class WorkerThread(QtCore.QThread):
|
||||||
#noinspection PyArgumentList
|
# noinspection PyArgumentList
|
||||||
def __init__(self):
|
def __init__(self):
|
||||||
QtCore.QThread.__init__(self)
|
QtCore.QThread.__init__(self)
|
||||||
self.pool = QtCore.QThreadPool()
|
|
||||||
self.conversionAlive = False
|
self.conversionAlive = False
|
||||||
self.errors = False
|
self.errors = False
|
||||||
self.kindlegenErrorCode = [0]
|
self.kindlegenErrorCode = [0]
|
||||||
self.workerOutput = []
|
self.workerOutput = []
|
||||||
# Let's make sure that we don't fill the memory
|
|
||||||
availableMemory = TOTAL_PHYMEM/1000000000
|
|
||||||
if availableMemory <= 2:
|
|
||||||
self.threadNumber = 1
|
|
||||||
elif 2 < availableMemory <= 4:
|
|
||||||
self.threadNumber = 2
|
|
||||||
else:
|
|
||||||
self.threadNumber = 4
|
|
||||||
# Let's make sure that we don't use too many threads
|
|
||||||
if self.threadNumber > QtCore.QThread.idealThreadCount():
|
|
||||||
self.threadNumber = QtCore.QThread.idealThreadCount()
|
|
||||||
self.progressBarTick = MW.progressBarTick
|
self.progressBarTick = MW.progressBarTick
|
||||||
self.addMessage = MW.addMessage
|
self.addMessage = MW.addMessage
|
||||||
|
|
||||||
@@ -365,55 +289,65 @@ class WorkerThread(QtCore.QThread):
|
|||||||
MW.addTrayMessage.emit('Conversion interrupted.', 'Critical')
|
MW.addTrayMessage.emit('Conversion interrupted.', 'Critical')
|
||||||
MW.modeConvert.emit(1)
|
MW.modeConvert.emit(1)
|
||||||
|
|
||||||
def addResult(self, output):
|
def sanitizeTrace(self, traceback):
|
||||||
MW.progressBarTick.emit('tick')
|
return ''.join(format_tb(traceback))\
|
||||||
self.workerOutput.append(output)
|
.replace('C:\\Users\\AcidWeb\\Documents\\Projekty\\KCC\\', '')\
|
||||||
|
.replace('C:\\Python34\\', '')\
|
||||||
|
.replace('C:\\Python34_64\\', '')
|
||||||
|
|
||||||
def run(self):
|
def run(self):
|
||||||
MW.modeConvert.emit(0)
|
MW.modeConvert.emit(0)
|
||||||
|
|
||||||
|
parser = comic2ebook.makeParser()
|
||||||
|
options, _ = parser.parse_args()
|
||||||
|
|
||||||
profile = GUI.profiles[str(GUI.DeviceBox.currentText())]['Label']
|
profile = GUI.profiles[str(GUI.DeviceBox.currentText())]['Label']
|
||||||
argv = ["--profile=" + profile]
|
options.profile = profile
|
||||||
|
argv = ''
|
||||||
currentJobs = []
|
currentJobs = []
|
||||||
|
|
||||||
|
# Basic mode settings
|
||||||
if GUI.MangaBox.isChecked():
|
if GUI.MangaBox.isChecked():
|
||||||
argv.append("--manga-style")
|
options.righttoleft = True
|
||||||
if GUI.RotateBox.isChecked():
|
if GUI.RotateBox.isChecked():
|
||||||
argv.append("--rotate")
|
options.rotate = True
|
||||||
if GUI.QualityBox.checkState() == 1:
|
if GUI.QualityBox.checkState() == 1:
|
||||||
argv.append("--quality=1")
|
options.quality = 1
|
||||||
elif GUI.QualityBox.checkState() == 2:
|
elif GUI.QualityBox.checkState() == 2:
|
||||||
argv.append("--quality=2")
|
options.quality = 2
|
||||||
if str(GUI.FormatBox.currentText()) == 'CBZ':
|
options.format = str(GUI.FormatBox.currentText())
|
||||||
argv.append("--cbz-output")
|
|
||||||
if GUI.currentMode == 1:
|
if GUI.currentMode == 1:
|
||||||
if profile in ['KFHD', 'KFHD8', 'KFHDX', 'KFHDX8']:
|
if 'KFH' in profile:
|
||||||
argv.append("--upscale")
|
options.upscale = True
|
||||||
|
|
||||||
|
# Advanced mode settings
|
||||||
if GUI.currentMode > 1:
|
if GUI.currentMode > 1:
|
||||||
if GUI.ProcessingBox.isChecked():
|
if GUI.ProcessingBox.isChecked():
|
||||||
argv.append("--noprocessing")
|
options.imgproc = False
|
||||||
if GUI.NoRotateBox.isChecked():
|
if GUI.NoRotateBox.isChecked():
|
||||||
argv.append("--nosplitrotate")
|
options.nosplitrotate = True
|
||||||
if GUI.UpscaleBox.checkState() == 1:
|
if GUI.UpscaleBox.checkState() == 1:
|
||||||
argv.append("--stretch")
|
options.stretch = True
|
||||||
elif GUI.UpscaleBox.checkState() == 2:
|
elif GUI.UpscaleBox.checkState() == 2:
|
||||||
argv.append("--upscale")
|
options.upscale = True
|
||||||
if GUI.BorderBox.checkState() == 1:
|
if GUI.BorderBox.checkState() == 1:
|
||||||
argv.append("--whiteborders")
|
options.white_borders = True
|
||||||
elif GUI.BorderBox.checkState() == 2:
|
elif GUI.BorderBox.checkState() == 2:
|
||||||
argv.append("--blackborders")
|
options.black_borders = True
|
||||||
if GUI.NoDitheringBox.isChecked():
|
if GUI.NoDitheringBox.isChecked():
|
||||||
argv.append("--forcepng")
|
options.forcepng = True
|
||||||
if GUI.WebtoonBox.isChecked():
|
if GUI.WebtoonBox.isChecked():
|
||||||
argv.append("--webtoon")
|
options.webtoon = True
|
||||||
if float(GUI.GammaValue) > 0.09:
|
if float(GUI.GammaValue) > 0.09:
|
||||||
# noinspection PyTypeChecker
|
options.gamma = float(GUI.GammaValue)
|
||||||
argv.append("--gamma=" + GUI.GammaValue)
|
|
||||||
if str(GUI.FormatBox.currentText()) == 'MOBI':
|
# Other/custom settings.
|
||||||
argv.append("--batchsplit")
|
|
||||||
if GUI.currentMode > 2:
|
if GUI.currentMode > 2:
|
||||||
argv.append("--customwidth=" + str(GUI.customWidth.text()))
|
options.customwidth = str(GUI.customWidth.text())
|
||||||
argv.append("--customheight=" + str(GUI.customHeight.text()))
|
options.customheight = str(GUI.customHeight.text())
|
||||||
if GUI.ColorBox.isChecked():
|
if GUI.ColorBox.isChecked():
|
||||||
argv.append("--forcecolor")
|
options.forcecolor = True
|
||||||
|
|
||||||
for i in range(GUI.JobList.count()):
|
for i in range(GUI.JobList.count()):
|
||||||
# Make sure that we don't consider any system message as job to do
|
# Make sure that we don't consider any system message as job to do
|
||||||
if GUI.JobList.item(i).icon().isNull():
|
if GUI.JobList.item(i).icon().isNull():
|
||||||
@@ -435,7 +369,9 @@ class WorkerThread(QtCore.QThread):
|
|||||||
jobargv = list(argv)
|
jobargv = list(argv)
|
||||||
jobargv.append(job)
|
jobargv.append(job)
|
||||||
try:
|
try:
|
||||||
outputPath = comic2ebook.main(jobargv, self)
|
comic2ebook.options = copy(options)
|
||||||
|
comic2ebook.checkOptions()
|
||||||
|
outputPath = comic2ebook.makeBook(job, self)
|
||||||
MW.hideProgressBar.emit()
|
MW.hideProgressBar.emit()
|
||||||
except UserWarning as warn:
|
except UserWarning as warn:
|
||||||
if not self.conversionAlive:
|
if not self.conversionAlive:
|
||||||
@@ -452,7 +388,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
self.errors = True
|
self.errors = True
|
||||||
_, _, traceback = sys.exc_info()
|
_, _, traceback = sys.exc_info()
|
||||||
MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
|
MW.showDialog.emit("Error during conversion %s:\n\n%s\n\nTraceback:\n%s"
|
||||||
% (jobargv[-1], str(err), "".join(format_tb(traceback))), 'error')
|
% (jobargv[-1], str(err), self.sanitizeTrace(traceback)), 'error')
|
||||||
MW.addMessage.emit('Failed to create EPUB!', 'error', False)
|
MW.addMessage.emit('Failed to create EPUB!', 'error', False)
|
||||||
MW.addTrayMessage.emit('Failed to create EPUB!', 'Critical')
|
MW.addTrayMessage.emit('Failed to create EPUB!', 'Critical')
|
||||||
if not self.conversionAlive:
|
if not self.conversionAlive:
|
||||||
@@ -473,15 +409,10 @@ class WorkerThread(QtCore.QThread):
|
|||||||
MW.progressBarTick.emit('tick')
|
MW.progressBarTick.emit('tick')
|
||||||
MW.addMessage.emit('Creating MOBI files', 'info', False)
|
MW.addMessage.emit('Creating MOBI files', 'info', False)
|
||||||
GUI.progress.content = 'Creating MOBI files'
|
GUI.progress.content = 'Creating MOBI files'
|
||||||
self.workerOutput = []
|
work = []
|
||||||
# Number of KindleGen threads depends on the size of RAM
|
|
||||||
self.pool.setMaxThreadCount(self.threadNumber)
|
|
||||||
for item in outputPath:
|
for item in outputPath:
|
||||||
worker = KindleGenThread(item)
|
work.append([item])
|
||||||
worker.signals.result.connect(self.addResult)
|
self.workerOutput = comic2ebook.makeMOBI(work, self)
|
||||||
self.pool.start(worker)
|
|
||||||
self.pool.waitForDone()
|
|
||||||
sleep(0.5)
|
|
||||||
self.kindlegenErrorCode = [0]
|
self.kindlegenErrorCode = [0]
|
||||||
for errors in self.workerOutput:
|
for errors in self.workerOutput:
|
||||||
if errors[0] != 0:
|
if errors[0] != 0:
|
||||||
@@ -498,20 +429,14 @@ class WorkerThread(QtCore.QThread):
|
|||||||
if self.kindlegenErrorCode[0] == 0:
|
if self.kindlegenErrorCode[0] == 0:
|
||||||
GUI.progress.content = ''
|
GUI.progress.content = ''
|
||||||
MW.addMessage.emit('Creating MOBI files... <b>Done!</b>', 'info', True)
|
MW.addMessage.emit('Creating MOBI files... <b>Done!</b>', 'info', True)
|
||||||
MW.addMessage.emit('Cleaning MOBI files', 'info', False)
|
MW.addMessage.emit('Processing MOBI files', 'info', False)
|
||||||
GUI.progress.content = 'Cleaning MOBI files'
|
GUI.progress.content = 'Processing MOBI files'
|
||||||
self.workerOutput = []
|
self.workerOutput = []
|
||||||
# Multithreading KindleUnpack in current form is a waste of resources.
|
|
||||||
# Unless we higly optimise KindleUnpack or drop 32bit support this will not change.
|
|
||||||
self.pool.setMaxThreadCount(1)
|
|
||||||
for item in outputPath:
|
for item in outputPath:
|
||||||
worker = KindleUnpackThread([item, profile])
|
self.workerOutput.append(comic2ebook.makeMOBIFix(item))
|
||||||
worker.signals.result.connect(self.addResult)
|
MW.progressBarTick.emit('tick')
|
||||||
self.pool.start(worker)
|
|
||||||
self.pool.waitForDone()
|
|
||||||
sleep(0.5)
|
|
||||||
for success in self.workerOutput:
|
for success in self.workerOutput:
|
||||||
if not success:
|
if not success[0]:
|
||||||
self.errors = True
|
self.errors = True
|
||||||
break
|
break
|
||||||
if not self.errors:
|
if not self.errors:
|
||||||
@@ -526,7 +451,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
except Exception:
|
except Exception:
|
||||||
pass
|
pass
|
||||||
GUI.completedWork[os.path.basename(mobiPath)] = mobiPath
|
GUI.completedWork[os.path.basename(mobiPath)] = mobiPath
|
||||||
MW.addMessage.emit('Cleaning MOBI files... <b>Done!</b>', 'info', True)
|
MW.addMessage.emit('Processing MOBI files... <b>Done!</b>', 'info', True)
|
||||||
else:
|
else:
|
||||||
GUI.progress.content = ''
|
GUI.progress.content = ''
|
||||||
for item in outputPath:
|
for item in outputPath:
|
||||||
@@ -535,11 +460,11 @@ class WorkerThread(QtCore.QThread):
|
|||||||
os.remove(mobiPath)
|
os.remove(mobiPath)
|
||||||
if os.path.exists(mobiPath + '_toclean'):
|
if os.path.exists(mobiPath + '_toclean'):
|
||||||
os.remove(mobiPath + '_toclean')
|
os.remove(mobiPath + '_toclean')
|
||||||
MW.addMessage.emit('KindleUnpack failed to clean MOBI file!', 'error', False)
|
MW.addMessage.emit('Failed to process MOBI file!', 'error', False)
|
||||||
MW.addTrayMessage.emit('KindleUnpack failed to clean MOBI file!', 'Critical')
|
MW.addTrayMessage.emit('Failed to process MOBI file!', 'Critical')
|
||||||
else:
|
else:
|
||||||
GUI.progress.content = ''
|
GUI.progress.content = ''
|
||||||
epubSize = (os.path.getsize(self.kindlegenErrorCode[2]))/1024/1024
|
epubSize = (os.path.getsize(self.kindlegenErrorCode[2]))//1024//1024
|
||||||
for item in outputPath:
|
for item in outputPath:
|
||||||
if os.path.exists(item):
|
if os.path.exists(item):
|
||||||
os.remove(item)
|
os.remove(item)
|
||||||
@@ -551,7 +476,7 @@ class WorkerThread(QtCore.QThread):
|
|||||||
MW.showDialog.emit("KindleGen error:\n\n" + self.kindlegenErrorCode[1], 'error')
|
MW.showDialog.emit("KindleGen error:\n\n" + self.kindlegenErrorCode[1], 'error')
|
||||||
if self.kindlegenErrorCode[0] == 23026:
|
if self.kindlegenErrorCode[0] == 23026:
|
||||||
MW.addMessage.emit('Created EPUB file was too big.', 'error', False)
|
MW.addMessage.emit('Created EPUB file was too big.', 'error', False)
|
||||||
MW.addMessage.emit('EPUB file: ' + str(epubSize) + 'MB. Supported size: ~300MB.', 'error',
|
MW.addMessage.emit('EPUB file: ' + str(epubSize) + 'MB. Supported size: ~350MB.', 'error',
|
||||||
False)
|
False)
|
||||||
else:
|
else:
|
||||||
for item in outputPath:
|
for item in outputPath:
|
||||||
@@ -575,6 +500,7 @@ class SystemTrayIcon(QtWidgets.QSystemTrayIcon):
|
|||||||
def __init__(self):
|
def __init__(self):
|
||||||
if self.isSystemTrayAvailable():
|
if self.isSystemTrayAvailable():
|
||||||
QtWidgets.QSystemTrayIcon.__init__(self, GUI.icons.programIcon, MW)
|
QtWidgets.QSystemTrayIcon.__init__(self, GUI.icons.programIcon, MW)
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
self.activated.connect(self.catchClicks)
|
self.activated.connect(self.catchClicks)
|
||||||
|
|
||||||
def catchClicks(self):
|
def catchClicks(self):
|
||||||
@@ -820,6 +746,9 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
if value == 2 and 'Kobo' in str(GUI.DeviceBox.currentText()):
|
if value == 2 and 'Kobo' in str(GUI.DeviceBox.currentText()):
|
||||||
self.addMessage('Kobo devices can\'t use ultra quality mode!', 'warning')
|
self.addMessage('Kobo devices can\'t use ultra quality mode!', 'warning')
|
||||||
GUI.QualityBox.setCheckState(0)
|
GUI.QualityBox.setCheckState(0)
|
||||||
|
elif value == 2 and 'CBZ' in str(GUI.FormatBox.currentText()):
|
||||||
|
self.addMessage('CBZ format don\'t support ultra quality mode!', 'warning')
|
||||||
|
GUI.QualityBox.setCheckState(0)
|
||||||
|
|
||||||
def changeGamma(self, value):
|
def changeGamma(self, value):
|
||||||
value = float(value)
|
value = float(value)
|
||||||
@@ -847,7 +776,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
GUI.AdvModeButton.setEnabled(True)
|
GUI.AdvModeButton.setEnabled(True)
|
||||||
if self.currentMode == 3:
|
if self.currentMode == 3:
|
||||||
self.modeBasic()
|
self.modeBasic()
|
||||||
self.changeFormat()
|
self.changeFormat(event=False)
|
||||||
GUI.GammaSlider.setValue(0)
|
GUI.GammaSlider.setValue(0)
|
||||||
self.changeGamma(0)
|
self.changeGamma(0)
|
||||||
if profile['DefaultUpscale']:
|
if profile['DefaultUpscale']:
|
||||||
@@ -856,19 +785,12 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
self.addMessage('<a href="https://github.com/ciromattia/kcc/wiki/NonKindle-devices">'
|
self.addMessage('<a href="https://github.com/ciromattia/kcc/wiki/NonKindle-devices">'
|
||||||
'List of supported Non-Kindle devices.</a>', 'info')
|
'List of supported Non-Kindle devices.</a>', 'info')
|
||||||
|
|
||||||
def changeFormat(self, outputFormat=None):
|
def changeFormat(self, outputFormat=None, event=True):
|
||||||
profile = GUI.profiles[str(GUI.DeviceBox.currentText())]
|
profile = GUI.profiles[str(GUI.DeviceBox.currentText())]
|
||||||
if outputFormat is not None:
|
if outputFormat is not None:
|
||||||
GUI.FormatBox.setCurrentIndex(outputFormat)
|
GUI.FormatBox.setCurrentIndex(outputFormat)
|
||||||
else:
|
else:
|
||||||
if GUI.FormatBox.count() == 3:
|
GUI.FormatBox.setCurrentIndex(profile['DefaultFormat'])
|
||||||
GUI.FormatBox.setCurrentIndex(profile['DefaultFormat'])
|
|
||||||
else:
|
|
||||||
if profile['DefaultFormat'] != 0:
|
|
||||||
tmpFormat = profile['DefaultFormat'] - 1
|
|
||||||
else:
|
|
||||||
tmpFormat = 0
|
|
||||||
GUI.FormatBox.setCurrentIndex(tmpFormat)
|
|
||||||
if GUI.WebtoonBox.isChecked():
|
if GUI.WebtoonBox.isChecked():
|
||||||
GUI.MangaBox.setEnabled(False)
|
GUI.MangaBox.setEnabled(False)
|
||||||
GUI.QualityBox.setEnabled(False)
|
GUI.QualityBox.setEnabled(False)
|
||||||
@@ -881,6 +803,10 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
if GUI.ProcessingBox.isChecked():
|
if GUI.ProcessingBox.isChecked():
|
||||||
GUI.QualityBox.setEnabled(False)
|
GUI.QualityBox.setEnabled(False)
|
||||||
GUI.QualityBox.setChecked(False)
|
GUI.QualityBox.setChecked(False)
|
||||||
|
if event and GUI.QualityBox.isEnabled() and 'CBZ' in str(GUI.FormatBox.currentText()) and\
|
||||||
|
GUI.QualityBox.checkState() == 2:
|
||||||
|
self.addMessage('CBZ format don\'t support ultra quality mode!', 'warning')
|
||||||
|
GUI.QualityBox.setCheckState(0)
|
||||||
|
|
||||||
def stripTags(self, html):
|
def stripTags(self, html):
|
||||||
s = HTMLStripper()
|
s = HTMLStripper()
|
||||||
@@ -959,6 +885,15 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
self.addMessage('Target resolution is not set!', 'error')
|
self.addMessage('Target resolution is not set!', 'error')
|
||||||
self.needClean = True
|
self.needClean = True
|
||||||
return
|
return
|
||||||
|
if str(GUI.FormatBox.currentText()) == 'MOBI' and not GUI.KindleGen:
|
||||||
|
self.addMessage('Cannot find <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211">'
|
||||||
|
'<b>KindleGen</b></a>! MOBI conversion is not possible!', 'error')
|
||||||
|
if sys.platform.startswith('win'):
|
||||||
|
self.addMessage('Download it and place EXE in KCC directory.', 'error')
|
||||||
|
else:
|
||||||
|
self.addMessage('Download it, and place executable in /usr/local/bin directory.', 'error')
|
||||||
|
self.needClean = True
|
||||||
|
return
|
||||||
self.worker.start()
|
self.worker.start()
|
||||||
|
|
||||||
def hideProgressBar(self):
|
def hideProgressBar(self):
|
||||||
@@ -996,8 +931,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
'customHeight': GUI.customHeight.text(),
|
'customHeight': GUI.customHeight.text(),
|
||||||
'GammaSlider': float(self.GammaValue)*100})
|
'GammaSlider': float(self.GammaValue)*100})
|
||||||
self.settings.sync()
|
self.settings.sync()
|
||||||
if not sys.platform.startswith('linux'):
|
self.tray.hide()
|
||||||
self.tray.hide()
|
|
||||||
|
|
||||||
def handleMessage(self, message):
|
def handleMessage(self, message):
|
||||||
MW.raise_()
|
MW.raise_()
|
||||||
@@ -1072,6 +1006,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
self.versionCheck = VersionThread()
|
self.versionCheck = VersionThread()
|
||||||
self.contentServer = WebServerThread()
|
self.contentServer = WebServerThread()
|
||||||
self.progress = ProgressThread()
|
self.progress = ProgressThread()
|
||||||
|
self.tray = SystemTrayIcon()
|
||||||
self.conversionAlive = False
|
self.conversionAlive = False
|
||||||
self.needClean = True
|
self.needClean = True
|
||||||
self.GammaValue = 1.0
|
self.GammaValue = 1.0
|
||||||
@@ -1082,9 +1017,6 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
self.statusBarFontSize = 10
|
self.statusBarFontSize = 10
|
||||||
self.statusBarStyle = 'QLabel{padding-top:2px;padding-bottom:3px;}'
|
self.statusBarStyle = 'QLabel{padding-top:2px;padding-bottom:3px;}'
|
||||||
self.ProgressBar.setStyleSheet('QProgressBar{padding-top:5px;text-align:center;}')
|
self.ProgressBar.setStyleSheet('QProgressBar{padding-top:5px;text-align:center;}')
|
||||||
self.tray = SystemTrayIcon()
|
|
||||||
self.tray.show()
|
|
||||||
MW.addTrayMessage.connect(self.tray.addTrayMessage)
|
|
||||||
elif sys.platform.startswith('linux'):
|
elif sys.platform.startswith('linux'):
|
||||||
self.listFontSize = 8
|
self.listFontSize = 8
|
||||||
self.statusBarFontSize = 8
|
self.statusBarFontSize = 8
|
||||||
@@ -1095,27 +1027,27 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
self.statusBarFontSize = 8
|
self.statusBarFontSize = 8
|
||||||
self.statusBarStyle = 'QLabel{padding-top:3px;padding-bottom:3px}'
|
self.statusBarStyle = 'QLabel{padding-top:3px;padding-bottom:3px}'
|
||||||
self.statusBar.setStyleSheet('QStatusBar::item{border:0px;border-top:2px solid #C2C7CB;}')
|
self.statusBar.setStyleSheet('QStatusBar::item{border:0px;border-top:2px solid #C2C7CB;}')
|
||||||
self.tray = SystemTrayIcon()
|
# Decrease priority to increase system responsiveness during conversion
|
||||||
self.tray.show()
|
from psutil import BELOW_NORMAL_PRIORITY_CLASS
|
||||||
MW.addTrayMessage.connect(self.tray.addTrayMessage)
|
self.p = Process(os.getpid())
|
||||||
|
self.p.nice(BELOW_NORMAL_PRIORITY_CLASS)
|
||||||
|
self.p.ionice(1)
|
||||||
|
|
||||||
self.profiles = {
|
self.profiles = {
|
||||||
|
"Kindle Voyage": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
|
'DefaultUpscale': False, 'Label': 'KV'},
|
||||||
"Kindle Paperwhite": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
"Kindle Paperwhite": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
'DefaultUpscale': False, 'Label': 'KHD'},
|
'DefaultUpscale': False, 'Label': 'KPW'},
|
||||||
"Kindle": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
"Kindle": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
'DefaultUpscale': False, 'Label': 'K345'},
|
'DefaultUpscale': False, 'Label': 'K345'},
|
||||||
"Kindle DX/DXG": {'Quality': False, 'ForceExpert': False, 'DefaultFormat': 0,
|
"Kindle DX/DXG": {'Quality': False, 'ForceExpert': False, 'DefaultFormat': 2,
|
||||||
'DefaultUpscale': False, 'Label': 'KDX'},
|
'DefaultUpscale': False, 'Label': 'KDX'},
|
||||||
"Kindle Fire": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
"K. Fire HD": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
'DefaultUpscale': False, 'Label': 'KF'},
|
'DefaultUpscale': True, 'Label': 'KFHD'},
|
||||||
"K. Fire HD 7\"": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
"K. Fire HDX": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
'DefaultUpscale': True, 'Label': 'KFHD'},
|
'DefaultUpscale': True, 'Label': 'KFHDX'},
|
||||||
"K. Fire HD 8.9\"": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
"K. Fire HDX 8.9": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
||||||
'DefaultUpscale': True, 'Label': 'KFHD8'},
|
'DefaultUpscale': True, 'Label': 'KFHDX8'},
|
||||||
"K. Fire HDX 7\"": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
|
||||||
'DefaultUpscale': True, 'Label': 'KFHDX'},
|
|
||||||
"K. Fire HDX 8.9\"": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 0,
|
|
||||||
'DefaultUpscale': True, 'Label': 'KFHDX8'},
|
|
||||||
"Kobo Mini/Touch": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 2,
|
"Kobo Mini/Touch": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 2,
|
||||||
'DefaultUpscale': False, 'Label': 'KoMT'},
|
'DefaultUpscale': False, 'Label': 'KoMT'},
|
||||||
"Kobo Glow": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 2,
|
"Kobo Glow": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 2,
|
||||||
@@ -1124,6 +1056,8 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
'DefaultUpscale': False, 'Label': 'KoA'},
|
'DefaultUpscale': False, 'Label': 'KoA'},
|
||||||
"Kobo Aura HD": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 2,
|
"Kobo Aura HD": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 2,
|
||||||
'DefaultUpscale': False, 'Label': 'KoAHD'},
|
'DefaultUpscale': False, 'Label': 'KoAHD'},
|
||||||
|
"Kobo Aura H2O": {'Quality': True, 'ForceExpert': False, 'DefaultFormat': 2,
|
||||||
|
'DefaultUpscale': False, 'Label': 'KoAH2O'},
|
||||||
"Other": {'Quality': False, 'ForceExpert': True, 'DefaultFormat': 1,
|
"Other": {'Quality': False, 'ForceExpert': True, 'DefaultFormat': 1,
|
||||||
'DefaultUpscale': False, 'Label': 'OTHER'},
|
'DefaultUpscale': False, 'Label': 'OTHER'},
|
||||||
"Kindle for Android": {'Quality': False, 'ForceExpert': True, 'DefaultFormat': 0,
|
"Kindle for Android": {'Quality': False, 'ForceExpert': True, 'DefaultFormat': 0,
|
||||||
@@ -1134,29 +1068,29 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
'DefaultUpscale': False, 'Label': 'K2'}
|
'DefaultUpscale': False, 'Label': 'K2'}
|
||||||
}
|
}
|
||||||
profilesGUI = [
|
profilesGUI = [
|
||||||
|
"Kindle Voyage",
|
||||||
"Kindle Paperwhite",
|
"Kindle Paperwhite",
|
||||||
"Kindle",
|
"Kindle",
|
||||||
"Kindle DX/DXG",
|
|
||||||
"Separator",
|
"Separator",
|
||||||
"Kindle Fire",
|
"K. Fire HD",
|
||||||
"K. Fire HD 7\"",
|
"K. Fire HDX",
|
||||||
"K. Fire HD 8.9\"",
|
"K. Fire HDX 8.9",
|
||||||
"K. Fire HDX 7\"",
|
|
||||||
"K. Fire HDX 8.9\"",
|
|
||||||
"Separator",
|
"Separator",
|
||||||
"Kobo Mini/Touch",
|
"Kobo Mini/Touch",
|
||||||
"Kobo Glow",
|
"Kobo Glow",
|
||||||
"Kobo Aura",
|
"Kobo Aura",
|
||||||
"Kobo Aura HD",
|
"Kobo Aura HD",
|
||||||
|
"Kobo Aura H2O",
|
||||||
"Separator",
|
"Separator",
|
||||||
"Other",
|
"Other",
|
||||||
"Separator",
|
"Separator",
|
||||||
"Kindle for Android",
|
"Kindle for Android",
|
||||||
"Kindle 1",
|
"Kindle 1",
|
||||||
"Kindle 2",
|
"Kindle 2",
|
||||||
|
"Kindle DX/DXG",
|
||||||
]
|
]
|
||||||
|
|
||||||
statusBarLabel = QtWidgets.QLabel('<b><a href="http://kcc.vulturis.eu/">HOMEPAGE</a> - <a href="https://github.'
|
statusBarLabel = QtWidgets.QLabel('<b><a href="http://kcc.iosphe.re/">HOMEPAGE</a> - <a href="https://github.'
|
||||||
'com/ciromattia/kcc/blob/master/README.md#issues--new-features--donations">DO'
|
'com/ciromattia/kcc/blob/master/README.md#issues--new-features--donations">DO'
|
||||||
'NATE</a> - <a href="https://github.com/ciromattia/kcc/wiki">WIKI</a> - <a hr'
|
'NATE</a> - <a href="https://github.com/ciromattia/kcc/wiki">WIKI</a> - <a hr'
|
||||||
'ef="http://www.mobileread.com/forums/showthread.php?t=207461">FORUM</a></b>')
|
'ef="http://www.mobileread.com/forums/showthread.php?t=207461">FORUM</a></b>')
|
||||||
@@ -1174,10 +1108,14 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
self.addMessage('Since you are new user of <b>KCC</b> please see few '
|
self.addMessage('Since you are new user of <b>KCC</b> please see few '
|
||||||
'<a href="https://github.com/ciromattia/kcc/wiki/Important-tips">important tips</a>.',
|
'<a href="https://github.com/ciromattia/kcc/wiki/Important-tips">important tips</a>.',
|
||||||
'info')
|
'info')
|
||||||
|
if not sys.platform.startswith('win'):
|
||||||
|
try:
|
||||||
|
os.chmod('/usr/local/bin/kindlegen', 0o755)
|
||||||
|
except Exception:
|
||||||
|
pass
|
||||||
kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, shell=True)
|
kindleGenExitCode = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, shell=True)
|
||||||
if kindleGenExitCode.wait() == 0:
|
if kindleGenExitCode.wait() == 0:
|
||||||
self.KindleGen = True
|
self.KindleGen = True
|
||||||
formats = ['MOBI', 'EPUB', 'CBZ']
|
|
||||||
versionCheck = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, shell=True)
|
versionCheck = Popen('kindlegen -locale en', stdout=PIPE, stderr=STDOUT, shell=True)
|
||||||
for line in versionCheck.stdout:
|
for line in versionCheck.stdout:
|
||||||
line = line.decode("utf-8")
|
line = line.decode("utf-8")
|
||||||
@@ -1191,13 +1129,6 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
break
|
break
|
||||||
else:
|
else:
|
||||||
self.KindleGen = False
|
self.KindleGen = False
|
||||||
formats = ['EPUB', 'CBZ']
|
|
||||||
if sys.platform.startswith('win'):
|
|
||||||
self.addMessage('Cannot find <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211">'
|
|
||||||
'kindlegen</a> in KCC directory! MOBI creation will be disabled.', 'warning')
|
|
||||||
else:
|
|
||||||
self.addMessage('Cannot find <a href="http://www.amazon.com/gp/feature.html?ie=UTF8&docId=1000765211">'
|
|
||||||
'kindlegen</a> in PATH! MOBI creation will be disabled.', 'warning')
|
|
||||||
rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, shell=True)
|
rarExitCode = Popen('unrar', stdout=PIPE, stderr=STDOUT, shell=True)
|
||||||
rarExitCode = rarExitCode.wait()
|
rarExitCode = rarExitCode.wait()
|
||||||
if rarExitCode == 0 or rarExitCode == 7:
|
if rarExitCode == 0 or rarExitCode == 7:
|
||||||
@@ -1237,6 +1168,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
MW.forceShutdown.connect(self.forceShutdown)
|
MW.forceShutdown.connect(self.forceShutdown)
|
||||||
MW.dialogAnswer.connect(self.versionCheck.getNewVersion)
|
MW.dialogAnswer.connect(self.versionCheck.getNewVersion)
|
||||||
MW.closeEvent = self.saveSettings
|
MW.closeEvent = self.saveSettings
|
||||||
|
MW.addTrayMessage.connect(self.tray.addTrayMessage)
|
||||||
|
|
||||||
GUI.Form.setAcceptDrops(True)
|
GUI.Form.setAcceptDrops(True)
|
||||||
GUI.Form.dragEnterEvent = self.dragAndDrop
|
GUI.Form.dragEnterEvent = self.dragAndDrop
|
||||||
@@ -1251,7 +1183,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
GUI.DeviceBox.addItem(self.icons.deviceKobo, profile)
|
GUI.DeviceBox.addItem(self.icons.deviceKobo, profile)
|
||||||
else:
|
else:
|
||||||
GUI.DeviceBox.addItem(self.icons.deviceKindle, profile)
|
GUI.DeviceBox.addItem(self.icons.deviceKindle, profile)
|
||||||
for f in formats:
|
for f in ['MOBI', 'EPUB', 'CBZ']:
|
||||||
GUI.FormatBox.addItem(eval('self.icons.' + f + 'Format'), f)
|
GUI.FormatBox.addItem(eval('self.icons.' + f + 'Format'), f)
|
||||||
if self.lastDevice > GUI.DeviceBox.count():
|
if self.lastDevice > GUI.DeviceBox.count():
|
||||||
self.lastDevice = 0
|
self.lastDevice = 0
|
||||||
@@ -1262,7 +1194,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
GUI.DeviceBox.setCurrentIndex(self.lastDevice)
|
GUI.DeviceBox.setCurrentIndex(self.lastDevice)
|
||||||
self.changeDevice()
|
self.changeDevice()
|
||||||
if self.currentFormat != self.profiles[str(GUI.DeviceBox.currentText())]['DefaultFormat']:
|
if self.currentFormat != self.profiles[str(GUI.DeviceBox.currentText())]['DefaultFormat']:
|
||||||
self.changeFormat(self.currentFormat)
|
self.changeFormat(self.currentFormat, False)
|
||||||
for option in self.options:
|
for option in self.options:
|
||||||
if str(option) == "customWidth":
|
if str(option) == "customWidth":
|
||||||
GUI.customWidth.setText(str(self.options[option]))
|
GUI.customWidth.setText(str(self.options[option]))
|
||||||
@@ -1279,6 +1211,7 @@ class KCCGUI(KCC_ui.Ui_KCC):
|
|||||||
self.worker.sync()
|
self.worker.sync()
|
||||||
self.versionCheck.start()
|
self.versionCheck.start()
|
||||||
self.contentServer.start()
|
self.contentServer.start()
|
||||||
|
self.tray.show()
|
||||||
MW.setWindowTitle("Kindle Comic Converter " + __version__)
|
MW.setWindowTitle("Kindle Comic Converter " + __version__)
|
||||||
MW.show()
|
MW.show()
|
||||||
MW.raise_()
|
MW.raise_()
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'KCC.ui'
|
# Form implementation generated from reading ui file 'KCC.ui'
|
||||||
#
|
#
|
||||||
# Created: Sat Jan 25 17:36:53 2014
|
# Created: Sun May 18 09:08:27 2014
|
||||||
# by: PyQt5 UI code generator 5.2
|
# by: PyQt5 UI code generator 5.2.1
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
@@ -264,7 +264,7 @@ class Ui_KCC(object):
|
|||||||
self.ProcessingBox.setText(_translate("KCC", "No optimisation"))
|
self.ProcessingBox.setText(_translate("KCC", "No optimisation"))
|
||||||
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>"))
|
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>"))
|
||||||
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale"))
|
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale"))
|
||||||
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html>"))
|
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\"white-space:pre\">Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>This mode is created for pages with a low width, high height and vertical panel flow.</p></body></html>"))
|
||||||
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode"))
|
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode"))
|
||||||
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Create PNG files instead JPEG.<br/>Quality increase is not noticeable on most of devices.<br/>Output files <span style=\" font-weight:600;\">might</span> be smaller.<br/><span style=\" font-weight:600;\">MOBI conversion will be much slower.</span></p></body></html>"))
|
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Create PNG files instead JPEG.<br/>Quality increase is not noticeable on most of devices.<br/>Output files <span style=\" font-weight:600;\">might</span> be smaller.<br/><span style=\" font-weight:600;\">MOBI conversion will be much slower.</span></p></body></html>"))
|
||||||
self.NoDitheringBox.setText(_translate("KCC", "PNG output"))
|
self.NoDitheringBox.setText(_translate("KCC", "PNG output"))
|
||||||
@@ -281,7 +281,7 @@ class Ui_KCC(object):
|
|||||||
self.ClearButton.setText(_translate("KCC", "Clear list"))
|
self.ClearButton.setText(_translate("KCC", "Clear list"))
|
||||||
self.MangaBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable right-to-left reading.</p></body></html>"))
|
self.MangaBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable right-to-left reading.</p></body></html>"))
|
||||||
self.MangaBox.setText(_translate("KCC", "Manga mode"))
|
self.MangaBox.setText(_translate("KCC", "Manga mode"))
|
||||||
self.QualityBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode<br/></span><span style=\" font-style:italic;\">Use it when Panel View support is not needed.</span><span style=\" font-weight:600; text-decoration: underline;\"><br/></span>- Maximum quality when zoom is not enabled.<br/>- Poor quality when zoom is enabled.<br/>- Lowest file size.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode<br/></span><span style=\" font-style:italic;\">Not zoomed images </span><span style=\" font-weight:600; font-style:italic;\">might </span><span style=\" font-style:italic;\">be blurry.</span><span style=\" font-weight:600; text-decoration: underline;\"><br/></span>- High quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode<br/></span><span style=\" font-style:italic;\">Maximum possible quality.</span><span style=\" font-weight:600; text-decoration: underline;\"><br/></span>- Maximum quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.<br/>- Very high file size.</p></body></html>"))
|
self.QualityBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\"white-space:pre\"><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode<br/></span>Maximal quality of images but very poor magnification quality.<br/>Use it only when zoom is not needed or output files needs to be small.</p><p style=\"white-space:pre\"><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode<br/></span>In most cases high quality of images and magnification.<br/>Overall quality highly depends on the resolution of source files.<br/>On Kindle models older than Paperwhite non-zoomed images might be a little blurred.</p><p style=\"white-space:pre\"><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode<br/></span>Highest possible quality. Output files will be big.</p></body></html>"))
|
||||||
self.QualityBox.setText(_translate("KCC", "High/Ultra quality"))
|
self.QualityBox.setText(_translate("KCC", "High/Ultra quality"))
|
||||||
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Disable splitting of two-page spreads.<br/>They will be rotated instead.</p></body></html>"))
|
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Disable splitting of two-page spreads.<br/>They will be rotated instead.</p></body></html>"))
|
||||||
self.RotateBox.setText(_translate("KCC", "Horizontal mode"))
|
self.RotateBox.setText(_translate("KCC", "Horizontal mode"))
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'KCC-Linux.ui'
|
# Form implementation generated from reading ui file 'KCC-Linux.ui'
|
||||||
#
|
#
|
||||||
# Created: Sat Jan 25 17:37:02 2014
|
# Created: Sun May 18 09:08:37 2014
|
||||||
# by: PyQt5 UI code generator 5.2
|
# by: PyQt5 UI code generator 5.2.1
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
@@ -333,7 +333,7 @@ class Ui_KCC(object):
|
|||||||
self.ProcessingBox.setText(_translate("KCC", "No optimisation"))
|
self.ProcessingBox.setText(_translate("KCC", "No optimisation"))
|
||||||
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>"))
|
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>"))
|
||||||
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale"))
|
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale"))
|
||||||
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html>"))
|
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>This mode was created for pages with a low width, high height and vertical panel flow.</p></body></html>"))
|
||||||
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode"))
|
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode"))
|
||||||
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Create PNG files instead JPEG.<br/>Quality increase is not noticeable on most of devices.<br/>Output files <span style=\" font-weight:600;\">might</span> be smaller.<br/><span style=\" font-weight:600;\">MOBI conversion will be much slower.</span></p></body></html>"))
|
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Create PNG files instead JPEG.<br/>Quality increase is not noticeable on most of devices.<br/>Output files <span style=\" font-weight:600;\">might</span> be smaller.<br/><span style=\" font-weight:600;\">MOBI conversion will be much slower.</span></p></body></html>"))
|
||||||
self.NoDitheringBox.setText(_translate("KCC", "PNG output"))
|
self.NoDitheringBox.setText(_translate("KCC", "PNG output"))
|
||||||
@@ -350,7 +350,7 @@ class Ui_KCC(object):
|
|||||||
self.ClearButton.setText(_translate("KCC", "Clear list"))
|
self.ClearButton.setText(_translate("KCC", "Clear list"))
|
||||||
self.MangaBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable right-to-left reading.</p></body></html>"))
|
self.MangaBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable right-to-left reading.</p></body></html>"))
|
||||||
self.MangaBox.setText(_translate("KCC", "Manga mode"))
|
self.MangaBox.setText(_translate("KCC", "Manga mode"))
|
||||||
self.QualityBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode<br/></span><span style=\" font-style:italic;\">Use it when Panel View support is not needed.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Poor quality when zoom is enabled.<br/>- Lowest file size.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode<br/></span><span style=\" font-style:italic;\">Not zoomed images </span><span style=\" font-weight:600; font-style:italic;\">might</span><span style=\" font-style:italic;\"> be blurry.<br/></span>- High quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode<br/></span><span style=\" font-style:italic;\">Maximum possible quality.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.<br/>- Very high file size.</p></body></html>"))
|
self.QualityBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode</span><br/>Maximal quality of images but very poor magnification quality.<br/>Use it only when zoom is not needed or output files needs to be small.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode</span><br/>In most cases high quality of images and magnification.<br/>Overall quality highly depends on the resolution of source files.<br/>On Kindle models older than Paperwhite non-zoomed images might be a little blurred.<br/><br/><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode</span><br/>Highest possible quality. Output files will be big.</p></body></html>"))
|
||||||
self.QualityBox.setText(_translate("KCC", "High/Ultra quality"))
|
self.QualityBox.setText(_translate("KCC", "High/Ultra quality"))
|
||||||
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Disable splitting of two-page spreads.<br/>They will be rotated instead.</p></body></html>"))
|
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Disable splitting of two-page spreads.<br/>They will be rotated instead.</p></body></html>"))
|
||||||
self.RotateBox.setText(_translate("KCC", "Horizontal mode"))
|
self.RotateBox.setText(_translate("KCC", "Horizontal mode"))
|
||||||
|
|||||||
@@ -2,8 +2,8 @@
|
|||||||
|
|
||||||
# Form implementation generated from reading ui file 'KCC-OSX.ui'
|
# Form implementation generated from reading ui file 'KCC-OSX.ui'
|
||||||
#
|
#
|
||||||
# Created: Sat Jan 25 17:37:10 2014
|
# Created: Sun May 18 09:08:44 2014
|
||||||
# by: PyQt5 UI code generator 5.2
|
# by: PyQt5 UI code generator 5.2.1
|
||||||
#
|
#
|
||||||
# WARNING! All changes made in this file will be lost!
|
# WARNING! All changes made in this file will be lost!
|
||||||
|
|
||||||
@@ -356,7 +356,7 @@ class Ui_KCC(object):
|
|||||||
self.ProcessingBox.setText(_translate("KCC", "No optimisation"))
|
self.ProcessingBox.setText(_translate("KCC", "No optimisation"))
|
||||||
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>"))
|
self.UpscaleBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Nothing<br/></span>Images smaller than device resolution will not be resized.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - Stretching<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be not preserved.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Upscaling<br/></span>Images smaller than device resolution will be resized. Aspect ratio will be preserved.</p></body></html>"))
|
||||||
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale"))
|
self.UpscaleBox.setText(_translate("KCC", "Stretch/Upscale"))
|
||||||
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God</span> or <span style=\" font-style:italic;\">Noblesse</span>.<br/>Pages with a low width, high height and vertical panel flow.</p></body></html>"))
|
self.WebtoonBox.setToolTip(_translate("KCC", "<html><head/><body><p>Enable auto-splitting of webtoons like <span style=\" font-style:italic;\">Tower of God </span>or <span style=\" font-style:italic;\">Noblesse</span>.<br/>This mode was created for pages with a low width, high height and vertical panel flow.</p><p><br/></p></body></html>"))
|
||||||
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode"))
|
self.WebtoonBox.setText(_translate("KCC", "Webtoon mode"))
|
||||||
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Create PNG files instead JPEG.<br/>Quality increase is not noticeable on most of devices.<br/>Output files <span style=\" font-weight:600;\">might</span> be smaller.<br/><span style=\" font-weight:600;\">MOBI conversion will be much slower.</span></p></body></html>"))
|
self.NoDitheringBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Create PNG files instead JPEG.<br/>Quality increase is not noticeable on most of devices.<br/>Output files <span style=\" font-weight:600;\">might</span> be smaller.<br/><span style=\" font-weight:600;\">MOBI conversion will be much slower.</span></p></body></html>"))
|
||||||
self.NoDitheringBox.setText(_translate("KCC", "PNG output"))
|
self.NoDitheringBox.setText(_translate("KCC", "PNG output"))
|
||||||
@@ -373,7 +373,7 @@ class Ui_KCC(object):
|
|||||||
self.ClearButton.setText(_translate("KCC", "Clear list"))
|
self.ClearButton.setText(_translate("KCC", "Clear list"))
|
||||||
self.MangaBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable right-to-left reading.</p></body></html>"))
|
self.MangaBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Enable right-to-left reading.</p></body></html>"))
|
||||||
self.MangaBox.setText(_translate("KCC", "Manga mode"))
|
self.MangaBox.setText(_translate("KCC", "Manga mode"))
|
||||||
self.QualityBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode<br/></span><span style=\" font-style:italic;\">Use it when Panel View support is not needed.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Poor quality when zoom is enabled.<br/>- Lowest file size.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode<br/></span><span style=\" font-style:italic;\">Not zoomed image </span><span style=\" font-weight:600; font-style:italic;\">might</span><span style=\" font-style:italic;\"> be a little blurry.<br/></span>- High quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode<br/></span><span style=\" font-style:italic;\">Maximum possible quality.<br/></span>- Maximum quality when zoom is not enabled.<br/>- Maximum quality when zoom is enabled.<br/>- Very high file size.</p></body></html>"))
|
self.QualityBox.setToolTip(_translate("KCC", "<html><head/><body><p><span style=\" font-weight:600; text-decoration: underline;\">Unchecked - Normal quality mode</span><br/>Maximal quality of images but very poor magnification quality.<br/>Use it only when zoom is not needed or output files needs to be small.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Indeterminate - High quality mode</span><br/>In most cases high quality of images and magnification.<br/>Overall quality highly depends on the resolution of source files.<br/>On Kindle models older than Paperwhite non-zoomed images might be a little blurred.</p><p><span style=\" font-weight:600; text-decoration: underline;\">Checked - Ultra quality mode</span><br/>Highest possible quality. Output files will be big.</p></body></html>"))
|
||||||
self.QualityBox.setText(_translate("KCC", "High/Ultra quality"))
|
self.QualityBox.setText(_translate("KCC", "High/Ultra quality"))
|
||||||
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Disable splitting of two-page spreads.<br/>They will be rotated instead.</p></body></html>"))
|
self.RotateBox.setToolTip(_translate("KCC", "<html><head/><body><p style=\'white-space:pre\'>Disable splitting of two-page spreads.<br/>They will be rotated instead.</p></body></html>"))
|
||||||
self.RotateBox.setText(_translate("KCC", "Horizontal mode"))
|
self.RotateBox.setText(_translate("KCC", "Horizontal mode"))
|
||||||
|
|||||||
@@ -1,4 +1,4 @@
|
|||||||
__version__ = '4.0.1'
|
__version__ = '4.3'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
# any purpose with or without fee is hereby granted, provided that the
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import sys
|
import sys
|
||||||
@@ -104,7 +104,7 @@ class CBxArchive:
|
|||||||
for f in os.listdir(os.path.join(targetdir, adir[0])):
|
for f in os.listdir(os.path.join(targetdir, adir[0])):
|
||||||
# If directory names contain UTF-8 chars shutil.move can't clean up the mess alone
|
# If directory names contain UTF-8 chars shutil.move can't clean up the mess alone
|
||||||
if os.path.isdir(os.path.join(targetdir, f)):
|
if os.path.isdir(os.path.join(targetdir, f)):
|
||||||
os.rename(os.path.join(targetdir, adir[0], f), os.path.join(targetdir, adir[0], f + '-A'))
|
os.replace(os.path.join(targetdir, adir[0], f), os.path.join(targetdir, adir[0], f + '-A'))
|
||||||
f += '-A'
|
f += '-A'
|
||||||
move(os.path.join(targetdir, adir[0], f), targetdir)
|
move(os.path.join(targetdir, adir[0], f), targetdir)
|
||||||
os.rmdir(os.path.join(targetdir, adir[0]))
|
os.rmdir(os.path.join(targetdir, adir[0]))
|
||||||
|
|||||||
1173
kcc/comic2ebook.py
1173
kcc/comic2ebook.py
File diff suppressed because it is too large
Load Diff
@@ -1,7 +1,7 @@
|
|||||||
# -*- coding: utf-8 -*-
|
# -*- coding: utf-8 -*-
|
||||||
#
|
#
|
||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
# any purpose with or without fee is hereby granted, provided that the
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
@@ -18,9 +18,9 @@
|
|||||||
# PERFORMANCE OF THIS SOFTWARE.
|
# PERFORMANCE OF THIS SOFTWARE.
|
||||||
#
|
#
|
||||||
|
|
||||||
__version__ = '4.0.1'
|
__version__ = '4.3'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
@@ -36,7 +36,7 @@ except ImportError:
|
|||||||
QtCore = None
|
QtCore = None
|
||||||
|
|
||||||
|
|
||||||
def mergeDirectory_tick(output):
|
def mergeDirectoryTick(output):
|
||||||
if output:
|
if output:
|
||||||
mergeWorkerOutput.append(output)
|
mergeWorkerOutput.append(output)
|
||||||
mergeWorkerPool.terminate()
|
mergeWorkerPool.terminate()
|
||||||
@@ -108,7 +108,7 @@ def sanitizePanelSize(panel, opt):
|
|||||||
return newPanels
|
return newPanels
|
||||||
|
|
||||||
|
|
||||||
def splitImage_tick(output):
|
def splitImageTick(output):
|
||||||
if output:
|
if output:
|
||||||
splitWorkerOutput.append(output)
|
splitWorkerOutput.append(output)
|
||||||
splitWorkerPool.terminate()
|
splitWorkerPool.terminate()
|
||||||
@@ -118,13 +118,12 @@ def splitImage_tick(output):
|
|||||||
splitWorkerPool.terminate()
|
splitWorkerPool.terminate()
|
||||||
|
|
||||||
|
|
||||||
#noinspection PyUnboundLocalVariable
|
|
||||||
def splitImage(work):
|
def splitImage(work):
|
||||||
try:
|
try:
|
||||||
path = work[0]
|
path = work[0]
|
||||||
name = work[1]
|
name = work[1]
|
||||||
opt = work[2]
|
opt = work[2]
|
||||||
# Harcoded opttions
|
# Hardcoded options
|
||||||
threshold = 1.0
|
threshold = 1.0
|
||||||
delta = 15
|
delta = 15
|
||||||
fileExpanded = os.path.splitext(name)
|
fileExpanded = os.path.splitext(name)
|
||||||
@@ -165,6 +164,7 @@ def splitImage(work):
|
|||||||
for panel in panelsCleaned:
|
for panel in panelsCleaned:
|
||||||
panels.append(panel)
|
panels.append(panel)
|
||||||
if opt.debug:
|
if opt.debug:
|
||||||
|
# noinspection PyUnboundLocalVariable
|
||||||
debugImage.save(os.path.join(path, fileExpanded[0] + '-debug.png'), 'PNG')
|
debugImage.save(os.path.join(path, fileExpanded[0] + '-debug.png'), 'PNG')
|
||||||
|
|
||||||
# Create virtual pages
|
# Create virtual pages
|
||||||
@@ -207,13 +207,9 @@ def splitImage(work):
|
|||||||
return str(sys.exc_info()[1])
|
return str(sys.exc_info()[1])
|
||||||
|
|
||||||
|
|
||||||
def Copyright():
|
|
||||||
print(('comic2panel v%(__version__)s. Written by Ciro Mattia Gonano and Pawel Jastrzebski.' % globals()))
|
|
||||||
|
|
||||||
|
|
||||||
def main(argv=None, qtGUI=None):
|
def main(argv=None, qtGUI=None):
|
||||||
global options, GUI, splitWorkerPool, splitWorkerOutput, mergeWorkerPool, mergeWorkerOutput
|
global options, GUI, splitWorkerPool, splitWorkerOutput, mergeWorkerPool, mergeWorkerOutput
|
||||||
parser = OptionParser(usage="Usage: %prog [options] comic_folder", add_help_option=False)
|
parser = OptionParser(usage="Usage: kcc-c2p [options] comic_folder", add_help_option=False)
|
||||||
mainOptions = OptionGroup(parser, "MANDATORY")
|
mainOptions = OptionGroup(parser, "MANDATORY")
|
||||||
otherOptions = OptionGroup(parser, "OTHER")
|
otherOptions = OptionGroup(parser, "OTHER")
|
||||||
mainOptions.add_option("-y", "--height", type="int", dest="height", default=0,
|
mainOptions.add_option("-y", "--height", type="int", dest="height", default=0,
|
||||||
@@ -261,7 +257,7 @@ def main(argv=None, qtGUI=None):
|
|||||||
GUI.progressBarTick.emit('Combining images')
|
GUI.progressBarTick.emit('Combining images')
|
||||||
GUI.progressBarTick.emit(str(directoryNumer))
|
GUI.progressBarTick.emit(str(directoryNumer))
|
||||||
for i in mergeWork:
|
for i in mergeWork:
|
||||||
mergeWorkerPool.apply_async(func=mergeDirectory, args=(i, ), callback=mergeDirectory_tick)
|
mergeWorkerPool.apply_async(func=mergeDirectory, args=(i, ), callback=mergeDirectoryTick)
|
||||||
mergeWorkerPool.close()
|
mergeWorkerPool.close()
|
||||||
mergeWorkerPool.join()
|
mergeWorkerPool.join()
|
||||||
if GUI and not GUI.conversionAlive:
|
if GUI and not GUI.conversionAlive:
|
||||||
@@ -284,7 +280,7 @@ def main(argv=None, qtGUI=None):
|
|||||||
GUI.progressBarTick.emit('tick')
|
GUI.progressBarTick.emit('tick')
|
||||||
if len(work) > 0:
|
if len(work) > 0:
|
||||||
for i in work:
|
for i in work:
|
||||||
splitWorkerPool.apply_async(func=splitImage, args=(i, ), callback=splitImage_tick)
|
splitWorkerPool.apply_async(func=splitImage, args=(i, ), callback=splitImageTick)
|
||||||
splitWorkerPool.close()
|
splitWorkerPool.close()
|
||||||
splitWorkerPool.join()
|
splitWorkerPool.join()
|
||||||
if GUI and not GUI.conversionAlive:
|
if GUI and not GUI.conversionAlive:
|
||||||
|
|||||||
184
kcc/dualmetafix.py
Normal file
184
kcc/dualmetafix.py
Normal file
@@ -0,0 +1,184 @@
|
|||||||
|
# -*- coding: utf-8 -*-
|
||||||
|
#
|
||||||
|
# Based on initial version of DualMetaFix. Copyright (C) 2013 Kevin Hendricks
|
||||||
|
# Changes for KCC Copyright (C) 2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
|
#
|
||||||
|
# This program is free software: you can redistribute it and/or modify
|
||||||
|
# it under the terms of the GNU General Public License as published by
|
||||||
|
# the Free Software Foundation, either version 3 of the License, or
|
||||||
|
# (at your option) any later version.
|
||||||
|
#
|
||||||
|
# This program 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 General Public License for more details.
|
||||||
|
#
|
||||||
|
# You should have received a copy of the GNU General Public License
|
||||||
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
import struct
|
||||||
|
import mmap
|
||||||
|
import shutil
|
||||||
|
|
||||||
|
|
||||||
|
class DualMetaFixException(Exception):
|
||||||
|
pass
|
||||||
|
|
||||||
|
# palm database offset constants
|
||||||
|
number_of_pdb_records = 76
|
||||||
|
first_pdb_record = 78
|
||||||
|
|
||||||
|
# important rec0 offsets
|
||||||
|
mobi_header_base = 16
|
||||||
|
mobi_header_length = 20
|
||||||
|
mobi_version = 36
|
||||||
|
title_offset = 84
|
||||||
|
|
||||||
|
|
||||||
|
def getint(data, ofs, sz='L'):
|
||||||
|
i, = struct.unpack_from('>'+sz, data, ofs)
|
||||||
|
return i
|
||||||
|
|
||||||
|
|
||||||
|
def writeint(data, ofs, n, slen='L'):
|
||||||
|
if slen == 'L':
|
||||||
|
return data[:ofs]+struct.pack('>L', n)+data[ofs+4:]
|
||||||
|
else:
|
||||||
|
return data[:ofs]+struct.pack('>H', n)+data[ofs+2:]
|
||||||
|
|
||||||
|
|
||||||
|
def getsecaddr(datain, secno):
|
||||||
|
nsec = getint(datain, number_of_pdb_records, 'H')
|
||||||
|
if (secno < 0) | (secno >= nsec):
|
||||||
|
emsg = 'requested section number %d out of range (nsec=%d)' % (secno, nsec)
|
||||||
|
raise DualMetaFixException(emsg)
|
||||||
|
secstart = getint(datain, first_pdb_record+secno*8)
|
||||||
|
if secno == nsec-1:
|
||||||
|
secend = len(datain)
|
||||||
|
else:
|
||||||
|
secend = getint(datain, first_pdb_record+(secno+1)*8)
|
||||||
|
return secstart, secend
|
||||||
|
|
||||||
|
|
||||||
|
def readsection(datain, secno):
|
||||||
|
secstart, secend = getsecaddr(datain, secno)
|
||||||
|
return datain[secstart:secend]
|
||||||
|
|
||||||
|
|
||||||
|
# overwrite section - must be exact same length as original
|
||||||
|
def replacesection(datain, secno, secdata):
|
||||||
|
secstart, secend = getsecaddr(datain, secno)
|
||||||
|
seclen = secend - secstart
|
||||||
|
if len(secdata) != seclen:
|
||||||
|
raise DualMetaFixException('section length change in replacesection')
|
||||||
|
datain[secstart:secstart+seclen] = secdata
|
||||||
|
|
||||||
|
|
||||||
|
def get_exth_params(rec0):
|
||||||
|
ebase = mobi_header_base + getint(rec0, mobi_header_length)
|
||||||
|
if rec0[ebase:ebase+4] != b'EXTH':
|
||||||
|
raise DualMetaFixException('EXTH tag not found where expected')
|
||||||
|
elen = getint(rec0, ebase+4)
|
||||||
|
enum = getint(rec0, ebase+8)
|
||||||
|
rlen = len(rec0)
|
||||||
|
return ebase, elen, enum, rlen
|
||||||
|
|
||||||
|
|
||||||
|
def add_exth(rec0, exth_num, exth_bytes):
|
||||||
|
ebase, elen, enum, rlen = get_exth_params(rec0)
|
||||||
|
newrecsize = 8+len(exth_bytes)
|
||||||
|
newrec0 = rec0[0:ebase+4]+struct.pack('>L', elen+newrecsize)+struct.pack('>L', enum+1)+struct.pack('>L', exth_num)\
|
||||||
|
+ struct.pack('>L', newrecsize)+exth_bytes+rec0[ebase+12:]
|
||||||
|
newrec0 = writeint(newrec0, title_offset, getint(newrec0, title_offset)+newrecsize)
|
||||||
|
# keep constant record length by removing newrecsize null bytes from end
|
||||||
|
sectail = newrec0[-newrecsize:]
|
||||||
|
if sectail != b'\0'*newrecsize:
|
||||||
|
raise DualMetaFixException('add_exth: trimmed non-null bytes at end of section')
|
||||||
|
newrec0 = newrec0[0:rlen]
|
||||||
|
return newrec0
|
||||||
|
|
||||||
|
|
||||||
|
def read_exth(rec0, exth_num):
|
||||||
|
exth_values = []
|
||||||
|
ebase, elen, enum, rlen = get_exth_params(rec0)
|
||||||
|
ebase += 12
|
||||||
|
while enum > 0:
|
||||||
|
exth_id = getint(rec0, ebase)
|
||||||
|
if exth_id == exth_num:
|
||||||
|
# We might have multiple exths, so build a list.
|
||||||
|
exth_values.append(rec0[ebase+8:ebase+getint(rec0, ebase+4)])
|
||||||
|
enum -= 1
|
||||||
|
ebase = ebase+getint(rec0, ebase+4)
|
||||||
|
return exth_values
|
||||||
|
|
||||||
|
|
||||||
|
def del_exth(rec0, exth_num):
|
||||||
|
ebase, elen, enum, rlen = get_exth_params(rec0)
|
||||||
|
ebase_idx = ebase+12
|
||||||
|
enum_idx = 0
|
||||||
|
while enum_idx < enum:
|
||||||
|
exth_id = getint(rec0, ebase_idx)
|
||||||
|
exth_size = getint(rec0, ebase_idx+4)
|
||||||
|
if exth_id == exth_num:
|
||||||
|
newrec0 = rec0
|
||||||
|
newrec0 = writeint(newrec0, title_offset, getint(newrec0, title_offset)-exth_size)
|
||||||
|
newrec0 = newrec0[:ebase_idx]+newrec0[ebase_idx+exth_size:]
|
||||||
|
newrec0 = newrec0[0:ebase+4]+struct.pack('>L', elen-exth_size)+struct.pack('>L', enum-1)+newrec0[ebase+12:]
|
||||||
|
newrec0 += b'\0'*exth_size
|
||||||
|
if rlen != len(newrec0):
|
||||||
|
raise DualMetaFixException('del_exth: incorrect section size change')
|
||||||
|
return newrec0
|
||||||
|
enum_idx += 1
|
||||||
|
ebase_idx = ebase_idx+exth_size
|
||||||
|
return rec0
|
||||||
|
|
||||||
|
|
||||||
|
class DualMobiMetaFix:
|
||||||
|
def __init__(self, infile, outfile, asin):
|
||||||
|
shutil.copyfile(infile, outfile)
|
||||||
|
f = open(outfile, "r+b")
|
||||||
|
self.datain = mmap.mmap(f.fileno(), 0)
|
||||||
|
self.datain_rec0 = readsection(self.datain, 0)
|
||||||
|
|
||||||
|
# in the first mobi header
|
||||||
|
# add 501 to "EBOK", add 113 as asin, add 504 as asin
|
||||||
|
rec0 = self.datain_rec0
|
||||||
|
rec0 = del_exth(rec0, 501)
|
||||||
|
rec0 = del_exth(rec0, 113)
|
||||||
|
rec0 = del_exth(rec0, 504)
|
||||||
|
rec0 = add_exth(rec0, 501, b'EBOK')
|
||||||
|
rec0 = add_exth(rec0, 113, asin)
|
||||||
|
rec0 = add_exth(rec0, 504, asin)
|
||||||
|
replacesection(self.datain, 0, rec0)
|
||||||
|
|
||||||
|
ver = getint(self.datain_rec0, mobi_version)
|
||||||
|
self.combo = (ver != 8)
|
||||||
|
if not self.combo:
|
||||||
|
return
|
||||||
|
|
||||||
|
exth121 = read_exth(self.datain_rec0, 121)
|
||||||
|
if len(exth121) == 0:
|
||||||
|
self.combo = False
|
||||||
|
return
|
||||||
|
else:
|
||||||
|
# only pay attention to first exth121
|
||||||
|
# (there should only be one)
|
||||||
|
datain_kf8, = struct.unpack_from('>L', exth121[0], 0)
|
||||||
|
if datain_kf8 == 0xffffffff:
|
||||||
|
self.combo = False
|
||||||
|
return
|
||||||
|
self.datain_kfrec0 = readsection(self.datain, datain_kf8)
|
||||||
|
|
||||||
|
# in the second header
|
||||||
|
# add 501 to "EBOK", add 113 as asin, add 504 as asin
|
||||||
|
rec0 = self.datain_kfrec0
|
||||||
|
rec0 = del_exth(rec0, 501)
|
||||||
|
rec0 = del_exth(rec0, 113)
|
||||||
|
rec0 = del_exth(rec0, 504)
|
||||||
|
rec0 = add_exth(rec0, 501, b'EBOK')
|
||||||
|
rec0 = add_exth(rec0, 113, asin)
|
||||||
|
rec0 = add_exth(rec0, 504, asin)
|
||||||
|
replacesection(self.datain, datain_kf8, rec0)
|
||||||
|
|
||||||
|
self.datain.flush()
|
||||||
|
self.datain.close()
|
||||||
164
kcc/image.py
164
kcc/image.py
@@ -1,7 +1,7 @@
|
|||||||
# Copyright (C) 2010 Alex Yatskov
|
# Copyright (C) 2010 Alex Yatskov
|
||||||
# Copyright (C) 2011 Stanislav (proDOOMman) Kosolapov <prodoomman@gmail.com>
|
# Copyright (C) 2011 Stanislav (proDOOMman) Kosolapov <prodoomman@gmail.com>
|
||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# This program is free software: you can redistribute it and/or modify
|
# This program is free software: you can redistribute it and/or modify
|
||||||
# it under the terms of the GNU General Public License as published by
|
# it under the terms of the GNU General Public License as published by
|
||||||
@@ -16,11 +16,15 @@
|
|||||||
# You should have received a copy of the GNU General Public License
|
# You should have received a copy of the GNU General Public License
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||||
|
|
||||||
|
__version__ = '4.3'
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from io import BytesIO
|
||||||
|
from urllib.request import Request, urlopen
|
||||||
|
from urllib.parse import quote
|
||||||
from functools import reduce
|
from functools import reduce
|
||||||
from PIL import Image, ImageOps, ImageStat, ImageChops
|
from PIL import Image, ImageOps, ImageStat, ImageChops
|
||||||
from .shared import md5Checksum
|
from .shared import md5Checksum
|
||||||
@@ -81,18 +85,18 @@ class ProfileData:
|
|||||||
'K1': ("Kindle 1", (600, 670), Palette4, 1.8, (900, 1005)),
|
'K1': ("Kindle 1", (600, 670), Palette4, 1.8, (900, 1005)),
|
||||||
'K2': ("Kindle 2", (600, 670), Palette15, 1.8, (900, 1005)),
|
'K2': ("Kindle 2", (600, 670), Palette15, 1.8, (900, 1005)),
|
||||||
'K345': ("Kindle", (600, 800), Palette16, 1.8, (900, 1200)),
|
'K345': ("Kindle", (600, 800), Palette16, 1.8, (900, 1200)),
|
||||||
'KHD': ("Kindle Paperwhite", (758, 1024), Palette16, 1.8, (1137, 1536)),
|
|
||||||
'KDX': ("Kindle DX/DXG", (824, 1000), Palette16, 1.8, (1236, 1500)),
|
'KDX': ("Kindle DX/DXG", (824, 1000), Palette16, 1.8, (1236, 1500)),
|
||||||
'KF': ("Kindle Fire", (600, 1024), PalleteNull, 1.0, (900, 1536)),
|
'KPW': ("Kindle Paperwhite", (758, 1024), Palette16, 1.8, (1137, 1536)),
|
||||||
'KFHD': ("K. Fire HD 7\"", (800, 1280), PalleteNull, 1.0, (1200, 1920)),
|
'KV': ("Kindle Voyage", (1080, 1440), Palette16, 1.8, (1620, 2160)),
|
||||||
'KFHD8': ("K. Fire HD 8.9\"", (1200, 1920), PalleteNull, 1.0, (1800, 2880)),
|
'KFHD': ("K. Fire HD", (800, 1280), PalleteNull, 1.0, (1200, 1920)),
|
||||||
'KFHDX': ("K. Fire HDX 7\"", (1200, 1920), PalleteNull, 1.0, (1800, 2880)),
|
'KFHDX': ("K. Fire HDX", (1200, 1920), PalleteNull, 1.0, (1800, 2880)),
|
||||||
'KFHDX8': ("K. Fire HDX 8.9\"", (1600, 2560), PalleteNull, 1.0, (2400, 3840)),
|
'KFHDX8': ("K. Fire HDX 8.9", (1600, 2560), PalleteNull, 1.0, (2400, 3840)),
|
||||||
|
'KFA': ("Kindle for Android", (0, 0), PalleteNull, 1.0, (0, 0)),
|
||||||
'KoMT': ("Kobo Mini/Touch", (600, 800), Palette16, 1.8, (900, 1200)),
|
'KoMT': ("Kobo Mini/Touch", (600, 800), Palette16, 1.8, (900, 1200)),
|
||||||
'KoG': ("Kobo Glow", (768, 1024), Palette16, 1.8, (1152, 1536)),
|
'KoG': ("Kobo Glow", (768, 1024), Palette16, 1.8, (1152, 1536)),
|
||||||
'KoA': ("Kobo Aura", (758, 1024), Palette16, 1.8, (1137, 1536)),
|
'KoA': ("Kobo Aura", (758, 1024), Palette16, 1.8, (1137, 1536)),
|
||||||
'KoAHD': ("Kobo Aura HD", (1080, 1440), Palette16, 1.8, (1620, 2160)),
|
'KoAHD': ("Kobo Aura HD", (1080, 1440), Palette16, 1.8, (1620, 2160)),
|
||||||
'KFA': ("Kindle for Android", (0, 0), PalleteNull, 1.0, (0, 0)),
|
'KoAH2O': ("Kobo Aura H2O", (1080, 1430), Palette16, 1.8, (1620, 2145)),
|
||||||
'OTHER': ("Other", (0, 0), Palette16, 1.8, (0, 0)),
|
'OTHER': ("Other", (0, 0), Palette16, 1.8, (0, 0)),
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -144,7 +148,7 @@ class ComicPage:
|
|||||||
+ str(self.border[2]) + "-" + str(self.border[3]))
|
+ str(self.border[2]) + "-" + str(self.border[3]))
|
||||||
if forcepng:
|
if forcepng:
|
||||||
filename += ".png"
|
filename += ".png"
|
||||||
self.image.save(filename, "PNG", optimize=1)
|
self.image.save(filename, "PNG", optimize=1)
|
||||||
else:
|
else:
|
||||||
filename += ".jpg"
|
filename += ".jpg"
|
||||||
self.image.save(filename, "JPEG", optimize=1)
|
self.image.save(filename, "JPEG", optimize=1)
|
||||||
@@ -223,6 +227,9 @@ class ComicPage:
|
|||||||
self.size[0] and self.image.size[1] <= self.size[1]:
|
self.size[0] and self.image.size[1] <= self.size[1]:
|
||||||
size = (self.size[0], self.size[1])
|
size = (self.size[0], self.size[1])
|
||||||
elif qualityMode == 1:
|
elif qualityMode == 1:
|
||||||
|
# Forcing upscale to make sure that margins will be not too big
|
||||||
|
if not stretch:
|
||||||
|
upscale = True
|
||||||
size = (self.panelviewsize[0], self.panelviewsize[1])
|
size = (self.panelviewsize[0], self.panelviewsize[1])
|
||||||
elif qualityMode == 2 and not stretch and not upscale and self.image.size[0] <=\
|
elif qualityMode == 2 and not stretch and not upscale and self.image.size[0] <=\
|
||||||
self.size[0] and self.image.size[1] <= self.size[1]:
|
self.size[0] and self.image.size[1] <= self.size[1]:
|
||||||
@@ -359,27 +366,28 @@ class ComicPage:
|
|||||||
self.image = self.image.crop((0, 0, widthImg, heightImg - diff))
|
self.image = self.image.crop((0, 0, widthImg, heightImg - diff))
|
||||||
return self.image
|
return self.image
|
||||||
|
|
||||||
def cropWhiteSpace(self, threshold):
|
def cropWhiteSpace(self):
|
||||||
if ImageChops.invert(self.image).getbbox() is not None:
|
if ImageChops.invert(self.image).getbbox() is not None:
|
||||||
widthImg, heightImg = self.image.size
|
widthImg, heightImg = self.image.size
|
||||||
delta = 10
|
delta = 10
|
||||||
diff = delta
|
diff = delta
|
||||||
|
fixedThreshold = 0.1
|
||||||
# top
|
# top
|
||||||
while ImageStat.Stat(self.image.crop((0, 0, widthImg, diff))).var[0] < threshold and diff < heightImg:
|
while ImageStat.Stat(self.image.crop((0, 0, widthImg, diff))).var[0] < fixedThreshold and diff < heightImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
self.image = self.image.crop((0, diff, widthImg, heightImg))
|
self.image = self.image.crop((0, diff, widthImg, heightImg))
|
||||||
widthImg, heightImg = self.image.size
|
widthImg, heightImg = self.image.size
|
||||||
diff = delta
|
diff = delta
|
||||||
# left
|
# left
|
||||||
while ImageStat.Stat(self.image.crop((0, 0, diff, heightImg))).var[0] < threshold and diff < widthImg:
|
while ImageStat.Stat(self.image.crop((0, 0, diff, heightImg))).var[0] < fixedThreshold and diff < widthImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
self.image = self.image.crop((diff, 0, widthImg, heightImg))
|
self.image = self.image.crop((diff, 0, widthImg, heightImg))
|
||||||
widthImg, heightImg = self.image.size
|
widthImg, heightImg = self.image.size
|
||||||
diff = delta
|
diff = delta
|
||||||
# down
|
# down
|
||||||
while ImageStat.Stat(self.image.crop((0, heightImg - diff, widthImg, heightImg))).var[0] < threshold\
|
while ImageStat.Stat(self.image.crop((0, heightImg - diff, widthImg, heightImg))).var[0] < fixedThreshold\
|
||||||
and diff < heightImg:
|
and diff < heightImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
@@ -387,7 +395,7 @@ class ComicPage:
|
|||||||
widthImg, heightImg = self.image.size
|
widthImg, heightImg = self.image.size
|
||||||
diff = delta
|
diff = delta
|
||||||
# right
|
# right
|
||||||
while ImageStat.Stat(self.image.crop((widthImg - diff, 0, widthImg, heightImg))).var[0] < threshold\
|
while ImageStat.Stat(self.image.crop((widthImg - diff, 0, widthImg, heightImg))).var[0] < fixedThreshold\
|
||||||
and diff < widthImg:
|
and diff < widthImg:
|
||||||
diff += delta
|
diff += delta
|
||||||
diff -= delta
|
diff -= delta
|
||||||
@@ -396,50 +404,44 @@ class ComicPage:
|
|||||||
|
|
||||||
def getImageHistogram(self, image):
|
def getImageHistogram(self, image):
|
||||||
histogram = image.histogram()
|
histogram = image.histogram()
|
||||||
RBGW = []
|
if histogram[0] == 0:
|
||||||
pixelCount = 0
|
|
||||||
for i in range(256):
|
|
||||||
pixelCount += histogram[i] + histogram[256 + i] + histogram[512 + i]
|
|
||||||
RBGW.append(histogram[i] + histogram[256 + i] + histogram[512 + i])
|
|
||||||
white = 0
|
|
||||||
black = 0
|
|
||||||
for i in range(251, 256):
|
|
||||||
white += RBGW[i]
|
|
||||||
for i in range(5):
|
|
||||||
black += RBGW[i]
|
|
||||||
if black > pixelCount*0.8 and white == 0:
|
|
||||||
return 1
|
|
||||||
elif white > pixelCount*0.8 and black == 0:
|
|
||||||
return -1
|
return -1
|
||||||
|
elif histogram[255] == 0:
|
||||||
|
return 1
|
||||||
else:
|
else:
|
||||||
return False
|
return 0
|
||||||
|
|
||||||
def getImageFill(self, webtoon):
|
def getImageFill(self):
|
||||||
fill = 0
|
bw = self.image.convert('L').point(lambda x: 0 if x < 128 else 255, '1')
|
||||||
if not webtoon and not self.rotated:
|
imageBoxA = bw.getbbox()
|
||||||
# Search for horizontal solid lines
|
imageBoxB = ImageChops.invert(bw).getbbox()
|
||||||
startY = 0
|
if imageBoxA is None or imageBoxB is None:
|
||||||
while startY < self.image.size[1]:
|
surfaceB, surfaceW = 0, 0
|
||||||
if startY + 5 > self.image.size[1]:
|
|
||||||
startY = self.image.size[1] - 5
|
|
||||||
checkSolid = self.getImageHistogram(self.image.crop((0, startY, self.image.size[0], startY+5)))
|
|
||||||
if checkSolid:
|
|
||||||
fill += checkSolid
|
|
||||||
startY += 5
|
|
||||||
else:
|
else:
|
||||||
# Search for vertical solid lines
|
surfaceB = (imageBoxA[2] - imageBoxA[0]) * (imageBoxA[3] - imageBoxA[1])
|
||||||
startX = 0
|
surfaceW = (imageBoxB[2] - imageBoxB[0]) * (imageBoxB[3] - imageBoxB[1])
|
||||||
while startX < self.image.size[0]:
|
if surfaceW < surfaceB:
|
||||||
if startX + 5 > self.image.size[0]:
|
self.fill = 'white'
|
||||||
startX = self.image.size[0] - 5
|
elif surfaceW > surfaceB:
|
||||||
checkSolid = self.getImageHistogram(self.image.crop((startX, 0, startX+5, self.image.size[1])))
|
|
||||||
if checkSolid:
|
|
||||||
fill += checkSolid
|
|
||||||
startX += 5
|
|
||||||
if fill > 0:
|
|
||||||
self.fill = 'black'
|
self.fill = 'black'
|
||||||
else:
|
else:
|
||||||
self.fill = 'white'
|
fill = 0
|
||||||
|
startY = 0
|
||||||
|
while startY < bw.size[1]:
|
||||||
|
if startY + 5 > bw.size[1]:
|
||||||
|
startY = bw.size[1] - 5
|
||||||
|
fill += self.getImageHistogram(bw.crop((0, startY, bw.size[0], startY+5)))
|
||||||
|
startY += 5
|
||||||
|
startX = 0
|
||||||
|
while startX < bw.size[0]:
|
||||||
|
if startX + 5 > bw.size[0]:
|
||||||
|
startX = bw.size[0] - 5
|
||||||
|
fill += self.getImageHistogram(bw.crop((startX, 0, startX+5, bw.size[1])))
|
||||||
|
startX += 5
|
||||||
|
if fill > 0:
|
||||||
|
self.fill = 'black'
|
||||||
|
else:
|
||||||
|
self.fill = 'white'
|
||||||
|
|
||||||
def isImageColor(self):
|
def isImageColor(self):
|
||||||
v = ImageStat.Stat(self.image).var
|
v = ImageStat.Stat(self.image).var
|
||||||
@@ -465,3 +467,59 @@ class ComicPage:
|
|||||||
else:
|
else:
|
||||||
# Detection failed
|
# Detection failed
|
||||||
return False
|
return False
|
||||||
|
|
||||||
|
|
||||||
|
class Cover:
|
||||||
|
def __init__(self, source, target, opt, tomeNumber):
|
||||||
|
self.options = opt
|
||||||
|
self.source = source
|
||||||
|
self.target = target
|
||||||
|
if tomeNumber == 0:
|
||||||
|
self.tomeNumber = 1
|
||||||
|
else:
|
||||||
|
self.tomeNumber = tomeNumber
|
||||||
|
if self.tomeNumber in self.options.remoteCovers:
|
||||||
|
try:
|
||||||
|
source = urlopen(Request(quote(self.options.remoteCovers[self.tomeNumber]).replace('%3A', ':', 1),
|
||||||
|
headers={'User-Agent': 'KindleComicConverter/' + __version__})).read()
|
||||||
|
self.image = Image.open(BytesIO(source))
|
||||||
|
self.processExternal()
|
||||||
|
except Exception:
|
||||||
|
self.image = Image.open(source)
|
||||||
|
self.processInternal()
|
||||||
|
else:
|
||||||
|
self.image = Image.open(source)
|
||||||
|
self.processInternal()
|
||||||
|
|
||||||
|
def processInternal(self):
|
||||||
|
self.image = self.image.convert('RGB')
|
||||||
|
self.image = self.trim()
|
||||||
|
self.save()
|
||||||
|
|
||||||
|
def processExternal(self):
|
||||||
|
self.image = self.image.convert('RGB')
|
||||||
|
self.image.thumbnail(self.options.profileData[1], Image.ANTIALIAS)
|
||||||
|
self.save(True)
|
||||||
|
|
||||||
|
def trim(self):
|
||||||
|
bg = Image.new(self.image.mode, self.image.size, self.image.getpixel((0, 0)))
|
||||||
|
diff = ImageChops.difference(self.image, bg)
|
||||||
|
diff = ImageChops.add(diff, diff, 2.0, -100)
|
||||||
|
bbox = diff.getbbox()
|
||||||
|
if bbox:
|
||||||
|
return self.image.crop(bbox)
|
||||||
|
else:
|
||||||
|
return self.image
|
||||||
|
|
||||||
|
def save(self, external=False):
|
||||||
|
if external:
|
||||||
|
source = self.options.remoteCovers[self.tomeNumber].split('/')[-1]
|
||||||
|
else:
|
||||||
|
source = self.source
|
||||||
|
try:
|
||||||
|
if os.path.splitext(source)[1].lower() == '.png':
|
||||||
|
self.image.save(self.target, "PNG", optimize=1)
|
||||||
|
else:
|
||||||
|
self.image.save(self.target, "JPEG", optimize=1)
|
||||||
|
except IOError:
|
||||||
|
raise RuntimeError('Failed to save cover')
|
||||||
|
|||||||
@@ -1,382 +0,0 @@
|
|||||||
# -*- coding: utf-8 -*-
|
|
||||||
#
|
|
||||||
# Based on initial version of KindleUnpack. Copyright (C) 2009 Charles M. Hannum <root@ihack.net>
|
|
||||||
# Improvements Copyright (C) 2009-2012 P. Durrant, K. Hendricks, S. Siebert, fandrieu, DiapDealer, nickredding
|
|
||||||
# Changes for KCC Copyright (C) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
|
||||||
#
|
|
||||||
# This program is free software: you can redistribute it and/or modify
|
|
||||||
# it under the terms of the GNU General Public License as published by
|
|
||||||
# the Free Software Foundation, either version 3 of the License, or
|
|
||||||
# (at your option) any later version.
|
|
||||||
#
|
|
||||||
# This program 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 General Public License for more details.
|
|
||||||
#
|
|
||||||
# You should have received a copy of the GNU General Public License
|
|
||||||
# along with this program. If not, see <http://www.gnu.org/licenses/>.
|
|
||||||
|
|
||||||
import struct
|
|
||||||
# from uuid import uuid4
|
|
||||||
|
|
||||||
# important pdb header offsets
|
|
||||||
unique_id_seed = 68
|
|
||||||
number_of_pdb_records = 76
|
|
||||||
|
|
||||||
# important palmdoc header offsets
|
|
||||||
book_length = 4
|
|
||||||
book_record_count = 8
|
|
||||||
first_pdb_record = 78
|
|
||||||
|
|
||||||
# important rec0 offsets
|
|
||||||
length_of_book = 4
|
|
||||||
mobi_header_base = 16
|
|
||||||
mobi_header_length = 20
|
|
||||||
mobi_type = 24
|
|
||||||
mobi_version = 36
|
|
||||||
first_non_text = 80
|
|
||||||
title_offset = 84
|
|
||||||
first_image_record = 108
|
|
||||||
first_content_index = 192
|
|
||||||
last_content_index = 194
|
|
||||||
kf8_last_content_index = 192 # for KF8 mobi headers
|
|
||||||
fcis_index = 200
|
|
||||||
flis_index = 208
|
|
||||||
srcs_index = 224
|
|
||||||
srcs_count = 228
|
|
||||||
primary_index = 244
|
|
||||||
datp_index = 256
|
|
||||||
huffoff = 112
|
|
||||||
hufftbloff = 120
|
|
||||||
|
|
||||||
|
|
||||||
def getint(datain, ofs, sz='L'):
|
|
||||||
i, = struct.unpack_from('>'+sz, datain, ofs)
|
|
||||||
return i
|
|
||||||
|
|
||||||
|
|
||||||
def writeint(datain, ofs, n, length='L'):
|
|
||||||
if length == 'L':
|
|
||||||
return datain[:ofs]+struct.pack('>L', n)+datain[ofs+4:]
|
|
||||||
else:
|
|
||||||
return datain[:ofs]+struct.pack('>H', n)+datain[ofs+2:]
|
|
||||||
|
|
||||||
|
|
||||||
def getsecaddr(datain, secno):
|
|
||||||
nsec = getint(datain, number_of_pdb_records, 'H')
|
|
||||||
assert secno >= 0 & secno < nsec, 'secno %d out of range (nsec=%d)' % (secno, nsec)
|
|
||||||
secstart = getint(datain, first_pdb_record+secno*8)
|
|
||||||
if secno == nsec-1:
|
|
||||||
secend = len(datain)
|
|
||||||
else:
|
|
||||||
secend = getint(datain, first_pdb_record+(secno+1)*8)
|
|
||||||
return secstart, secend
|
|
||||||
|
|
||||||
|
|
||||||
def readsection(datain, secno):
|
|
||||||
secstart, secend = getsecaddr(datain, secno)
|
|
||||||
return datain[secstart:secend]
|
|
||||||
|
|
||||||
|
|
||||||
def writesection(datain, secno, secdata): # overwrite, accounting for different length
|
|
||||||
dataout = deletesectionrange(datain, secno, secno)
|
|
||||||
return insertsection(dataout, secno, secdata)
|
|
||||||
|
|
||||||
|
|
||||||
def nullsection(datain, secno): # make it zero-length without deleting it
|
|
||||||
datalst = []
|
|
||||||
nsec = getint(datain, number_of_pdb_records, 'H')
|
|
||||||
secstart, secend = getsecaddr(datain, secno)
|
|
||||||
zerosecstart, zerosecend = getsecaddr(datain, 0)
|
|
||||||
dif = secend-secstart
|
|
||||||
datalst.append(datain[:first_pdb_record])
|
|
||||||
for i in range(0, secno+1):
|
|
||||||
ofs, flgval = struct.unpack_from('>2L', datain, first_pdb_record+i*8)
|
|
||||||
datalst.append(struct.pack('>L', ofs) + struct.pack('>L', flgval))
|
|
||||||
for i in range(secno+1, nsec):
|
|
||||||
ofs, flgval = struct.unpack_from('>2L', datain, first_pdb_record+i*8)
|
|
||||||
ofs -= dif
|
|
||||||
datalst.append(struct.pack('>L', ofs) + struct.pack('>L', flgval))
|
|
||||||
lpad = zerosecstart - (first_pdb_record + 8*nsec)
|
|
||||||
if lpad > 0:
|
|
||||||
datalst.append(b'\0' * lpad)
|
|
||||||
datalst.append(datain[zerosecstart: secstart])
|
|
||||||
datalst.append(datain[secend:])
|
|
||||||
dataout = b"".join(datalst)
|
|
||||||
return dataout
|
|
||||||
|
|
||||||
|
|
||||||
def deletesectionrange(datain, firstsec, lastsec): # delete a range of sections
|
|
||||||
datalst = []
|
|
||||||
firstsecstart, firstsecend = getsecaddr(datain, firstsec)
|
|
||||||
lastsecstart, lastsecend = getsecaddr(datain, lastsec)
|
|
||||||
zerosecstart, zerosecend = getsecaddr(datain, 0)
|
|
||||||
dif = lastsecend - firstsecstart + 8*(lastsec-firstsec+1)
|
|
||||||
nsec = getint(datain, number_of_pdb_records, 'H')
|
|
||||||
datalst.append(datain[:unique_id_seed])
|
|
||||||
datalst.append(struct.pack('>L', 2*(nsec-(lastsec-firstsec+1))+1))
|
|
||||||
datalst.append(datain[unique_id_seed+4:number_of_pdb_records])
|
|
||||||
datalst.append(struct.pack('>H', nsec-(lastsec-firstsec+1)))
|
|
||||||
newstart = zerosecstart - 8*(lastsec-firstsec+1)
|
|
||||||
for i in range(0, firstsec):
|
|
||||||
ofs, flgval = struct.unpack_from('>2L', datain, first_pdb_record+i*8)
|
|
||||||
ofs -= 8 * (lastsec - firstsec + 1)
|
|
||||||
datalst.append(struct.pack('>L', ofs) + struct.pack('>L', flgval))
|
|
||||||
for i in range(lastsec+1, nsec):
|
|
||||||
ofs, flgval = struct.unpack_from('>2L', datain, first_pdb_record+i*8)
|
|
||||||
ofs -= dif
|
|
||||||
flgval = 2*(i-(lastsec-firstsec+1))
|
|
||||||
datalst.append(struct.pack('>L', ofs) + struct.pack('>L', flgval))
|
|
||||||
lpad = newstart - (first_pdb_record + 8*(nsec - (lastsec - firstsec + 1)))
|
|
||||||
if lpad > 0:
|
|
||||||
datalst.append(b'\0' * lpad)
|
|
||||||
datalst.append(datain[zerosecstart:firstsecstart])
|
|
||||||
datalst.append(datain[lastsecend:])
|
|
||||||
dataout = b"".join(datalst)
|
|
||||||
return dataout
|
|
||||||
|
|
||||||
|
|
||||||
def insertsection(datain, secno, secdata): # insert a new section
|
|
||||||
datalst = []
|
|
||||||
nsec = getint(datain, number_of_pdb_records, 'H')
|
|
||||||
secstart, secend = getsecaddr(datain, secno)
|
|
||||||
zerosecstart, zerosecend = getsecaddr(datain, 0)
|
|
||||||
dif = len(secdata)
|
|
||||||
datalst.append(datain[:unique_id_seed])
|
|
||||||
datalst.append(struct.pack('>L', 2*(nsec+1)+1))
|
|
||||||
datalst.append(datain[unique_id_seed+4:number_of_pdb_records])
|
|
||||||
datalst.append(struct.pack('>H', nsec+1))
|
|
||||||
newstart = zerosecstart + 8
|
|
||||||
for i in range(0, secno):
|
|
||||||
ofs, flgval = struct.unpack_from('>2L', datain, first_pdb_record+i*8)
|
|
||||||
ofs += 8
|
|
||||||
datalst.append(struct.pack('>L', ofs) + struct.pack('>L', flgval))
|
|
||||||
datalst.append(struct.pack('>L', secstart + 8) + struct.pack('>L', (2*secno)))
|
|
||||||
for i in range(secno, nsec):
|
|
||||||
ofs, flgval = struct.unpack_from('>2L', datain, first_pdb_record+i*8)
|
|
||||||
ofs = ofs + dif + 8
|
|
||||||
flgval = 2*(i+1)
|
|
||||||
datalst.append(struct.pack('>L', ofs) + struct.pack('>L', flgval))
|
|
||||||
lpad = newstart - (first_pdb_record + 8*(nsec + 1))
|
|
||||||
if lpad > 0:
|
|
||||||
datalst.append(b'\0' * lpad)
|
|
||||||
datalst.append(datain[zerosecstart:secstart])
|
|
||||||
datalst.append(secdata)
|
|
||||||
datalst.append(datain[secstart:])
|
|
||||||
dataout = b"".join(datalst)
|
|
||||||
return dataout
|
|
||||||
|
|
||||||
|
|
||||||
def insertsectionrange(sectionsource, firstsec, lastsec, sectiontarget, targetsec): # insert a range of sections
|
|
||||||
dataout = sectiontarget
|
|
||||||
for idx in range(lastsec, firstsec-1, -1):
|
|
||||||
dataout = insertsection(dataout, targetsec, readsection(sectionsource, idx))
|
|
||||||
return dataout
|
|
||||||
|
|
||||||
|
|
||||||
def get_exth_params(rec0):
|
|
||||||
ebase = mobi_header_base + getint(rec0, mobi_header_length)
|
|
||||||
elen = getint(rec0, ebase+4)
|
|
||||||
enum = getint(rec0, ebase+8)
|
|
||||||
return ebase, elen, enum
|
|
||||||
|
|
||||||
|
|
||||||
def add_exth(rec0, exth_num, exth_bytes):
|
|
||||||
ebase, elen, enum = get_exth_params(rec0)
|
|
||||||
newrecsize = 8+len(exth_bytes)
|
|
||||||
newrec0 = rec0[0:ebase+4]+struct.pack('>L', elen+newrecsize)+struct.pack('>L', enum+1) +\
|
|
||||||
struct.pack('>L', exth_num) + struct.pack('>L', newrecsize)+exth_bytes+rec0[ebase+12:]
|
|
||||||
newrec0 = writeint(newrec0, title_offset, getint(newrec0, title_offset)+newrecsize)
|
|
||||||
return newrec0
|
|
||||||
|
|
||||||
|
|
||||||
def read_exth(rec0, exth_num):
|
|
||||||
exth_values = []
|
|
||||||
ebase, elen, enum = get_exth_params(rec0)
|
|
||||||
ebase += 12
|
|
||||||
while enum > 0:
|
|
||||||
exth_id = getint(rec0, ebase)
|
|
||||||
if exth_id == exth_num:
|
|
||||||
# We might have multiple exths, so build a list.
|
|
||||||
exth_values.append(rec0[ebase+8:ebase+getint(rec0, ebase+4)])
|
|
||||||
enum -= 1
|
|
||||||
ebase = ebase+getint(rec0, ebase+4)
|
|
||||||
return exth_values
|
|
||||||
|
|
||||||
|
|
||||||
def write_exth(rec0, exth_num, exth_bytes):
|
|
||||||
ebase, elen, enum = get_exth_params(rec0)
|
|
||||||
ebase_idx = ebase+12
|
|
||||||
enum_idx = enum
|
|
||||||
while enum_idx > 0:
|
|
||||||
exth_id = getint(rec0, ebase_idx)
|
|
||||||
if exth_id == exth_num:
|
|
||||||
dif = len(exth_bytes)+8-getint(rec0, ebase_idx+4)
|
|
||||||
newrec0 = rec0
|
|
||||||
if dif != 0:
|
|
||||||
newrec0 = writeint(newrec0, title_offset, getint(newrec0, title_offset)+dif)
|
|
||||||
return newrec0[:ebase+4]+struct.pack('>L', elen+len(exth_bytes)+8-getint(rec0, ebase_idx+4)) +\
|
|
||||||
struct.pack('>L', enum)+rec0[ebase+12:ebase_idx+4] +\
|
|
||||||
struct.pack('>L', len(exth_bytes)+8)+exth_bytes +\
|
|
||||||
rec0[ebase_idx+getint(rec0, ebase_idx+4):]
|
|
||||||
enum_idx -= 1
|
|
||||||
ebase_idx = ebase_idx+getint(rec0, ebase_idx+4)
|
|
||||||
return rec0
|
|
||||||
|
|
||||||
|
|
||||||
def del_exth(rec0, exth_num):
|
|
||||||
ebase, elen, enum = get_exth_params(rec0)
|
|
||||||
ebase_idx = ebase+12
|
|
||||||
enum_idx = 0
|
|
||||||
while enum_idx < enum:
|
|
||||||
exth_id = getint(rec0, ebase_idx)
|
|
||||||
exth_size = getint(rec0, ebase_idx+4)
|
|
||||||
if exth_id == exth_num:
|
|
||||||
newrec0 = rec0
|
|
||||||
newrec0 = writeint(newrec0, title_offset, getint(newrec0, title_offset)-exth_size)
|
|
||||||
newrec0 = newrec0[:ebase_idx]+newrec0[ebase_idx+exth_size:]
|
|
||||||
newrec0 = newrec0[0:ebase+4]+struct.pack('>L', elen-exth_size)+struct.pack('>L', enum-1)+newrec0[ebase+12:]
|
|
||||||
return newrec0
|
|
||||||
enum_idx += 1
|
|
||||||
ebase_idx = ebase_idx+exth_size
|
|
||||||
return rec0
|
|
||||||
|
|
||||||
|
|
||||||
class mobi_split:
|
|
||||||
def __init__(self, infile, newKindle):
|
|
||||||
try:
|
|
||||||
datain = open(infile, 'rb').read()
|
|
||||||
datain_rec0 = readsection(datain, 0)
|
|
||||||
ver = getint(datain_rec0, mobi_version)
|
|
||||||
# fake_asin = str(uuid4())
|
|
||||||
self.combo = (ver != 8)
|
|
||||||
if not self.combo:
|
|
||||||
return
|
|
||||||
exth121 = read_exth(datain_rec0, 121)
|
|
||||||
if len(exth121) == 0:
|
|
||||||
self.combo = False
|
|
||||||
return
|
|
||||||
else:
|
|
||||||
# only pay attention to first exth121
|
|
||||||
# (there should only be one)
|
|
||||||
datain_kf8, = struct.unpack_from('>L', exth121[0], 0)
|
|
||||||
if datain_kf8 == 0xffffffff:
|
|
||||||
self.combo = False
|
|
||||||
return
|
|
||||||
datain_kfrec0 = readsection(datain, datain_kf8)
|
|
||||||
firstimage = getint(datain_rec0, first_image_record)
|
|
||||||
lastimage = getint(datain_rec0, last_content_index, 'H')
|
|
||||||
|
|
||||||
if not newKindle:
|
|
||||||
# create the standalone mobi7
|
|
||||||
num_sec = getint(datain, number_of_pdb_records, 'H')
|
|
||||||
# remove BOUNDARY up to but not including ELF record
|
|
||||||
self.result_file = deletesectionrange(datain, datain_kf8-1, num_sec-2)
|
|
||||||
# check if there are SRCS records and delete them
|
|
||||||
srcs = getint(datain_rec0, srcs_index)
|
|
||||||
num_srcs = getint(datain_rec0, srcs_count)
|
|
||||||
if srcs != 0xffffffff and num_srcs > 0:
|
|
||||||
self.result_file = deletesectionrange(self.result_file, srcs, srcs+num_srcs-1)
|
|
||||||
datain_rec0 = writeint(datain_rec0, srcs_index, 0xffffffff)
|
|
||||||
datain_rec0 = writeint(datain_rec0, srcs_count, 0)
|
|
||||||
# reset the EXTH 121 KF8 Boundary meta data to 0xffffffff
|
|
||||||
datain_rec0 = write_exth(datain_rec0, 121, struct.pack('>L', 0xffffffff))
|
|
||||||
# datain_rec0 = del_exth(datain_rec0,121)
|
|
||||||
# datain_rec0 = del_exth(datain_rec0,534)
|
|
||||||
# don't remove the EXTH 125 KF8 Count of Resources, seems to be present in mobi6 files as well
|
|
||||||
# set the EXTH 129 KF8 Masthead / Cover Image string to the null string
|
|
||||||
datain_rec0 = write_exth(datain_rec0, 129, b'')
|
|
||||||
# don't remove the EXTH 131 KF8 Unidentified Count, seems to be present in mobi6 files as well
|
|
||||||
|
|
||||||
# Make sure we have an ASIN & cdeType set...
|
|
||||||
# if len(read_exth(datain_rec0, 113)) == 0:
|
|
||||||
# datain_rec0 = add_exth(datain_rec0, 113, fake_asin)
|
|
||||||
# if len(read_exth(datain_rec0, 504)) == 0:
|
|
||||||
# datain_rec0 = add_exth(datain_rec0, 504, fake_asin)
|
|
||||||
if len(read_exth(datain_rec0, 501)) == 0:
|
|
||||||
datain_rec0 = add_exth(datain_rec0, 501, b'EBOK')
|
|
||||||
|
|
||||||
# need to reset flags stored in 0x80-0x83
|
|
||||||
# old mobi with exth: 0x50, mobi7 part with exth: 0x1850, mobi8 part with exth: 0x1050
|
|
||||||
# Bit Flags
|
|
||||||
# 0x1000 = Bit 12 indicates if embedded fonts are used or not
|
|
||||||
# 0x0800 = means this Header points to *shared* images/resource/fonts ??
|
|
||||||
# 0x0080 = unknown new flag, why is this now being set by Kindlegen 2.8?
|
|
||||||
# 0x0040 = exth exists
|
|
||||||
# 0x0010 = Not sure but this is always set so far
|
|
||||||
fval, = struct.unpack_from('>L', datain_rec0, 0x80)
|
|
||||||
# need to remove flag 0x0800 for KindlePreviewer 2.8 and unset Bit 12 for embedded fonts
|
|
||||||
fval &= 0x07FF
|
|
||||||
datain_rec0 = datain_rec0[:0x80] + struct.pack('>L', fval) + datain_rec0[0x84:]
|
|
||||||
self.result_file = writesection(self.result_file, 0, datain_rec0)
|
|
||||||
if lastimage == 0xffff:
|
|
||||||
# find the lowest of the next sections and copy up to that.
|
|
||||||
ofs_list = [(kf8_last_content_index, 'L'), (fcis_index, 'L'), (flis_index, 'L'), (datp_index, 'L'),
|
|
||||||
(hufftbloff, 'L')]
|
|
||||||
for ofs, sz in ofs_list:
|
|
||||||
n = getint(datain_kfrec0, ofs, sz)
|
|
||||||
if 0 < n < lastimage:
|
|
||||||
lastimage = n-1
|
|
||||||
|
|
||||||
# Try to null out FONT and RES, but leave the (empty) PDB record so image refs remain valid
|
|
||||||
for i in range(firstimage, lastimage):
|
|
||||||
imgsec = readsection(self.result_file, i)
|
|
||||||
if imgsec[0:4] in ['RESC', 'FONT']:
|
|
||||||
self.result_file = nullsection(self.result_file, i)
|
|
||||||
# mobi7 finished
|
|
||||||
else:
|
|
||||||
# create standalone mobi8
|
|
||||||
self.result_file = deletesectionrange(datain, 0, datain_kf8-1)
|
|
||||||
target = getint(datain_kfrec0, first_image_record)
|
|
||||||
self.result_file = insertsectionrange(datain, firstimage, lastimage, self.result_file, target)
|
|
||||||
datain_kfrec0 = readsection(self.result_file, 0)
|
|
||||||
|
|
||||||
# Only keep the correct EXTH 116 StartOffset, KG 2.5 carries over the one from the mobi7 part,
|
|
||||||
# which then points at garbage in the mobi8 part, and confuses FW 3.4
|
|
||||||
kf8starts = read_exth(datain_kfrec0, 116)
|
|
||||||
# If we have multiple StartOffset, keep only the last one
|
|
||||||
kf8start_count = len(kf8starts)
|
|
||||||
while kf8start_count > 1:
|
|
||||||
kf8start_count -= 1
|
|
||||||
datain_kfrec0 = del_exth(datain_kfrec0, 116)
|
|
||||||
|
|
||||||
# update the EXTH 125 KF8 Count of Images/Fonts/Resources
|
|
||||||
datain_kfrec0 = write_exth(datain_kfrec0, 125, struct.pack('>L', lastimage-firstimage+1))
|
|
||||||
|
|
||||||
# Same dance for the KF8, we want an ASIN & cdeType :)
|
|
||||||
# if len(read_exth(datain_kfrec0, 113)) == 0:
|
|
||||||
# datain_kfrec0 = add_exth(datain_kfrec0, 113, fake_asin)
|
|
||||||
# if len(read_exth(datain_kfrec0, 504)) == 0:
|
|
||||||
# datain_kfrec0 = add_exth(datain_kfrec0, 504, fake_asin)
|
|
||||||
if len(read_exth(datain_kfrec0, 501)) == 0:
|
|
||||||
datain_kfrec0 = add_exth(datain_kfrec0, 501, b'EBOK')
|
|
||||||
|
|
||||||
# need to reset flags stored in 0x80-0x83
|
|
||||||
# old mobi with exth: 0x50, mobi7 part with exth: 0x1850, mobi8 part with exth: 0x1050
|
|
||||||
# standalone mobi8 with exth: 0x0050
|
|
||||||
# Bit Flags
|
|
||||||
# 0x1000 = Bit 12 indicates if embedded fonts are used or not
|
|
||||||
# 0x0800 = means this Header points to *shared* images/resource/fonts ??
|
|
||||||
# 0x0080 = unknown new flag, why is this now being set by Kindlegen 2.8?
|
|
||||||
# 0x0040 = exth exists
|
|
||||||
# 0x0010 = Not sure but this is always set so far
|
|
||||||
fval, = struct.unpack_from('>L', datain_kfrec0, 0x80)
|
|
||||||
fval &= 0x1FFF
|
|
||||||
fval |= 0x0800
|
|
||||||
datain_kfrec0 = datain_kfrec0[:0x80] + struct.pack('>L', fval) + datain_kfrec0[0x84:]
|
|
||||||
|
|
||||||
# properly update other index pointers that have been shifted by the insertion of images
|
|
||||||
ofs_list = [(kf8_last_content_index, 'L'), (fcis_index, 'L'), (flis_index, 'L'), (datp_index, 'L'),
|
|
||||||
(hufftbloff, 'L')]
|
|
||||||
for ofs, sz in ofs_list:
|
|
||||||
n = getint(datain_kfrec0, ofs, sz)
|
|
||||||
if n != 0xffffffff:
|
|
||||||
datain_kfrec0 = writeint(datain_kfrec0, ofs, n+lastimage-firstimage+1, sz)
|
|
||||||
self.result_file = writesection(self.result_file, 0, datain_kfrec0)
|
|
||||||
# mobi8 finished
|
|
||||||
except Exception:
|
|
||||||
raise
|
|
||||||
|
|
||||||
def getResult(self):
|
|
||||||
return self.result_file
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Based upon the code snippet by Ned Batchelder
|
# Based upon the code snippet by Ned Batchelder
|
||||||
# (http://nedbatchelder.com/blog/200712/extracting_jpgs_from_pdfs.html)
|
# (http://nedbatchelder.com/blog/200712/extracting_jpgs_from_pdfs.html)
|
||||||
@@ -20,7 +20,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
# Copyright (c) 2012-2014 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||||
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@vulturis.eu>
|
# Copyright (c) 2013-2014 Pawel Jastrzebski <pawelj@iosphe.re>
|
||||||
#
|
#
|
||||||
# Permission to use, copy, modify, and/or distribute this software for
|
# Permission to use, copy, modify, and/or distribute this software for
|
||||||
# any purpose with or without fee is hereby granted, provided that the
|
# any purpose with or without fee is hereby granted, provided that the
|
||||||
@@ -17,7 +17,7 @@
|
|||||||
#
|
#
|
||||||
|
|
||||||
__license__ = 'ISC'
|
__license__ = 'ISC'
|
||||||
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@vulturis.eu>'
|
__copyright__ = '2012-2014, Ciro Mattia Gonano <ciromattia@gmail.com>, Pawel Jastrzebski <pawelj@iosphe.re>'
|
||||||
__docformat__ = 'restructuredtext en'
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
|||||||
Binary file not shown.
Binary file not shown.
67
setup.py
67
setup.py
@@ -1,12 +1,12 @@
|
|||||||
#!/usr/bin/env python3
|
#!/usr/bin/env python3
|
||||||
"""
|
"""
|
||||||
cx_Freeze build script for KCC.
|
py2exe/py2app build script for KCC.
|
||||||
|
|
||||||
|
Usage (Windows):
|
||||||
|
python setup.py py2exe
|
||||||
|
|
||||||
Usage (Mac OS X):
|
Usage (Mac OS X):
|
||||||
python setup.py py2app
|
python setup.py py2app
|
||||||
|
|
||||||
Usage (Windows):
|
|
||||||
python setup.py build
|
|
||||||
"""
|
"""
|
||||||
from sys import platform, version_info
|
from sys import platform, version_info
|
||||||
if version_info[0] != 3:
|
if version_info[0] != 3:
|
||||||
@@ -14,7 +14,7 @@ if version_info[0] != 3:
|
|||||||
exit(1)
|
exit(1)
|
||||||
|
|
||||||
NAME = "KindleComicConverter"
|
NAME = "KindleComicConverter"
|
||||||
VERSION = "4.0.1"
|
VERSION = "4.3"
|
||||||
MAIN = "kcc.py"
|
MAIN = "kcc.py"
|
||||||
|
|
||||||
if platform == "darwin":
|
if platform == "darwin":
|
||||||
@@ -55,42 +55,51 @@ if platform == "darwin":
|
|||||||
)
|
)
|
||||||
)
|
)
|
||||||
elif platform == "win32":
|
elif platform == "win32":
|
||||||
|
# noinspection PyUnresolvedReferences
|
||||||
|
import py2exe
|
||||||
import platform as arch
|
import platform as arch
|
||||||
from cx_Freeze import setup, Executable
|
from distutils.core import setup
|
||||||
if arch.architecture()[0] == '64bit':
|
if arch.architecture()[0] == '64bit':
|
||||||
library = 'libEGL64.dll'
|
suffix = '_64'
|
||||||
else:
|
else:
|
||||||
library = 'libEGL32.dll'
|
suffix = ''
|
||||||
base = "Win32GUI"
|
additional_files = [('platforms', ['C:\Python34' + suffix +
|
||||||
|
'\Lib\site-packages\PyQt5\plugins\platforms\qwindows.dll']),
|
||||||
|
('', ['LICENSE.txt',
|
||||||
|
'other\\7za.exe',
|
||||||
|
'other\\UnRAR.exe',
|
||||||
|
'other\\Additional-LICENSE.txt',
|
||||||
|
'C:\Python34' + suffix + '\Lib\site-packages\PyQt5\libEGL.dll'])]
|
||||||
extra_options = dict(
|
extra_options = dict(
|
||||||
options={"build_exe": {"optimize": 2,
|
options={'py2exe': {"bundle_files": 1,
|
||||||
"include_files": ['LICENSE.txt',
|
"dll_excludes": ["tcl85.dll", "tk85.dll"],
|
||||||
['other/UnRAR.exe', 'UnRAR.exe'],
|
"dist_dir": "dist" + suffix,
|
||||||
['other/7za.exe', '7za.exe'],
|
"compressed": True,
|
||||||
['other/Additional-LICENSE.txt', 'Additional-LICENSE.txt'],
|
"includes": ["sip"],
|
||||||
['other/' + library, 'libEGL.dll']
|
"excludes": ["tkinter"],
|
||||||
],
|
"optimize": 2}},
|
||||||
"copy_dependent_files": True,
|
windows=[{"script": MAIN,
|
||||||
"create_shared_zip": False,
|
"dest_base": "KCC",
|
||||||
"append_script_to_exe": True,
|
"version": VERSION,
|
||||||
"replace_paths": '*=',
|
"copyright": "Ciro Mattia Gonano, Pawel Jastrzebski © 2014",
|
||||||
"excludes": ['tkinter']}},
|
"legal_copyright": "ISC License (ISCL)",
|
||||||
executables=[Executable(MAIN,
|
"product_version": VERSION,
|
||||||
base=base,
|
"product_name": "Kindle Comic Converter",
|
||||||
targetName="KCC.exe",
|
"file_description": "Kindle Comic Converter",
|
||||||
icon="icons/comic2ebook.ico",
|
"icon_resources": [(1, "icons\comic2ebook.ico")]}],
|
||||||
compress=False)])
|
zipfile=None,
|
||||||
|
data_files=additional_files)
|
||||||
else:
|
else:
|
||||||
print('Please use setup.sh to build Linux package.')
|
print('Please use setup.sh to build Linux package.')
|
||||||
exit()
|
exit()
|
||||||
|
|
||||||
#noinspection PyUnboundLocalVariable
|
# noinspection PyUnboundLocalVariable
|
||||||
setup(
|
setup(
|
||||||
name=NAME,
|
name=NAME,
|
||||||
version=VERSION,
|
version=VERSION,
|
||||||
author="Ciro Mattia Gonano, Pawel Jastrzebski",
|
author="Ciro Mattia Gonano, Pawel Jastrzebski",
|
||||||
author_email="ciromattia@gmail.com, pawelj@vulturis.eu",
|
author_email="ciromattia@gmail.com, pawelj@iosphe.re",
|
||||||
description="A tool to convert comics (CBR/CBZ/PDFs/image folders) to MOBI.",
|
description="Kindle Comic Converter",
|
||||||
license="ISC License (ISCL)",
|
license="ISC License (ISCL)",
|
||||||
keywords="kindle comic mobipocket mobi cbz cbr manga",
|
keywords="kindle comic mobipocket mobi cbz cbr manga",
|
||||||
url="http://github.com/ciromattia/kcc",
|
url="http://github.com/ciromattia/kcc",
|
||||||
|
|||||||
Reference in New Issue
Block a user