mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 01:36:27 +00:00
Start to work on py2exe/py2app ready code.
This commit is contained in:
Binary file not shown.
13
README.md
13
README.md
@@ -1,19 +1,18 @@
|
||||
# KindleComicConverter
|
||||
|
||||
`KindleComicConverter` is a Python script wrapped by a MacOS X AppleScript droplet to convert image folders to a comic-type Mobipocket ebook to take advantage of the new Panel View mode on Amazon's Kindle.
|
||||
`KindleComicConverter` is a Python app which aim is to convert image folders to a comic-type (Mobipocket) ebook to take advantage of the new Panel View mode on Amazon's Kindle.
|
||||
|
||||
## REQUIREMENTS
|
||||
- Python (included in MacOS and Linux, follow the [official documentation](http://www.python.org/getit/windows/) to install on Windows)
|
||||
- `kindlegen` in /usr/local/bin/
|
||||
|
||||
### for standalone `comic2ebook.py` script:
|
||||
- [unrar](http://www.rarlab.com/download.htm) and [rarfile.py](http://developer.berlios.de/project/showfiles.php?group_id=5373&release_id=18844) for `calibre2ebook.py` automatic CBR extracting.
|
||||
|
||||
You are strongly encouraged to get the [Python Imaging Library](http://www.pythonware.com/products/pil/) that, altough optional, provides a bunch of comic optimizations like split double pages, resize to optimal resolution, improve contrast and palette, etc.
|
||||
### for compiling/running from source:
|
||||
- Python 2.7+ (included in MacOS and Linux, follow the [official documentation](http://www.python.org/getit/windows/) to install on Windows)
|
||||
- You are strongly encouraged to get the [Python Imaging Library](http://www.pythonware.com/products/pil/) that, altough optional, provides a bunch of comic optimizations like split double pages, resize to optimal resolution, improve contrast and palette, etc.
|
||||
Please refer to official documentation for installing into your system.
|
||||
|
||||
## USAGE
|
||||
Drop a folder or a CBZ/CBR file over the droplet, after a while you'll get a comic-type .mobi to sideload on your Kindle.
|
||||
Drop a folder or a CBZ/CBR file over the app, after a while you'll get a comic-type .mobi to sideload on your Kindle.
|
||||
The script takes care of calling `comic2ebook.py`, `kindlegen` and `kindlestrip.py`.
|
||||
|
||||
> **WARNING:** at the moment the droplet *ALWAYS* uses the **KHD** profile (*Kindle Paperwhite*).
|
||||
@@ -52,12 +51,12 @@ and installed in `/usr/local/bin/`
|
||||
- 1.20 - Comic optimizations! Split pages not target-oriented (landscape with portrait target or portrait
|
||||
with landscape target), add palette and other image optimizations from Mangle.
|
||||
WARNING: PIL is required for all image mangling!
|
||||
- 2.00 - GUI! AppleScript is gone and Tk is used to provide cross-platform GUI support.
|
||||
|
||||
## TODO
|
||||
- Add gracefully exit for CBR if no rarfile.py and no unrar executable are found
|
||||
- Improve error reporting
|
||||
- Recurse into dirtree for multiple comics
|
||||
- Create a GUI to allow user control more options
|
||||
- Support pages extraction from PDF files
|
||||
|
||||
## COPYRIGHT
|
||||
|
||||
44
kcc.py
Normal file
44
kcc.py
Normal file
@@ -0,0 +1,44 @@
|
||||
#!/usr/bin/env python
|
||||
#
|
||||
# Copyright (c) 2012 Ciro Mattia Gonano <ciromattia@gmail.com>
|
||||
#
|
||||
# Permission to use, copy, modify, and/or distribute this software for
|
||||
# any purpose with or without fee is hereby granted, provided that the
|
||||
# above copyright notice and this permission notice appear in all
|
||||
# copies.
|
||||
#
|
||||
# THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL
|
||||
# WARRANTIES WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED
|
||||
# WARRANTIES OF MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE
|
||||
# AUTHOR BE LIABLE FOR ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL
|
||||
# DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE, DATA
|
||||
# OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
|
||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
# Changelog
|
||||
# 1.00 - Initial version
|
||||
# 1.10 - Added support for CBZ/CBR files
|
||||
# 1.11 - Added support for ZIP/RAR extensions
|
||||
# 1.20 - Comic optimizations! Split pages not target-oriented (landscape
|
||||
# with portrait target or portrait with landscape target), add palette
|
||||
# and other image optimizations from Mangle.
|
||||
# WARNING: PIL is required for all image mangling!
|
||||
#
|
||||
# Todo:
|
||||
# - Add gracefully exit for CBR if no rarfile.py and no unrar
|
||||
# executable are found
|
||||
# - Improve error reporting
|
||||
# - recurse into dirtree for multiple comics
|
||||
|
||||
__version__ = '1.30'
|
||||
|
||||
import sys
|
||||
from kcc import comic2ebook
|
||||
|
||||
if __name__ == "__main__":
|
||||
print ('kcc v%(__version__)s. '
|
||||
'Written 2012 by Ciro Mattia Gonano.' % globals())
|
||||
for arg in sys.argv[1:]:
|
||||
comic2ebook.main(['','KHD',arg])
|
||||
sys.exit(0)
|
||||
@@ -130,25 +130,28 @@ def isInFilelist(file,list):
|
||||
seen = True
|
||||
return seen
|
||||
|
||||
if __name__ == "__main__":
|
||||
def Copyright():
|
||||
print ('comic2ebook v%(__version__)s. '
|
||||
'Written 2012 by Ciro Mattia Gonano.' % globals())
|
||||
if len(sys.argv)<3 or len(sys.argv)>4:
|
||||
|
||||
def Usage():
|
||||
print "Generates HTML, NCX and OPF for a Comic ebook from a bunch of images"
|
||||
print "Optimized for creating Mobipockets to be read into Kindle Paperwhite"
|
||||
print "Usage:"
|
||||
print " %s <profile> <dir> <title>" % sys.argv[0]
|
||||
print " <title> is optional"
|
||||
sys.exit(1)
|
||||
else:
|
||||
profile = sys.argv[1]
|
||||
dir = sys.argv[2]
|
||||
|
||||
def main(argv=None):
|
||||
if argv is None:
|
||||
argv = sys.argv
|
||||
profile = argv[1]
|
||||
dir = argv[2]
|
||||
cbx = cbxarchive.CBxArchive(dir)
|
||||
if cbx.isCbxFile():
|
||||
cbx.extract()
|
||||
dir = cbx.getPath()
|
||||
if len(sys.argv)==4:
|
||||
title = sys.argv[3]
|
||||
if len(argv)==4:
|
||||
title = argv[3]
|
||||
else:
|
||||
title = "comic"
|
||||
filelist = []
|
||||
@@ -182,4 +185,12 @@ if __name__ == "__main__":
|
||||
# ensure we're sorting files alphabetically
|
||||
filelist = sorted(filelist, key=lambda name: name[0])
|
||||
OPFBuilder(dir,title,filelist)
|
||||
|
||||
if __name__ == "__main__":
|
||||
Copyright()
|
||||
if len(sys.argv)<3 or len(sys.argv)>4:
|
||||
Usage()
|
||||
sys.exit(1)
|
||||
else:
|
||||
main()
|
||||
sys.exit(0)
|
||||
|
||||
25
setup.py
25
setup.py
@@ -21,7 +21,7 @@ VERSION="1.2.0"
|
||||
IDENTIFIER="com.github.ciromattia.kcc"
|
||||
EXENAME="KindleComicConverter"
|
||||
|
||||
APP = ['kcc/comic2ebook.py']
|
||||
APP = ['kcc.py']
|
||||
DATA_FILES = []
|
||||
OPTIONS = { 'argv_emulation': True,
|
||||
'iconfile': 'resources/comic2ebook.icns',
|
||||
@@ -36,20 +36,10 @@ if sys.platform == 'darwin':
|
||||
plist=dict(
|
||||
CFBundleName = NAME,
|
||||
CFBundleShortVersionString = VERSION,
|
||||
CFBundleGetInfoString = NAME + " " + VERSION,
|
||||
CFBundleGetInfoString = NAME + " " + VERSION + ", written 2012 by Ciro Mattia Gonano",
|
||||
CFBundleExecutable = EXENAME,
|
||||
CFBundleIdentifier = IDENTIFIER,
|
||||
CFBundleDocumentTypes = dict(
|
||||
CFBundleTypeExtensions=["zip","rar","cbz","cbr"],
|
||||
CFBundleTypeName="Comics",
|
||||
CFBundleTypeRole="Editor",
|
||||
LSItemContentTypes = [
|
||||
"public.plain-text",
|
||||
"public.text",
|
||||
"public.data",
|
||||
"com.apple.application-bundle"
|
||||
]
|
||||
)
|
||||
CFBundleSignature = 'dplt'
|
||||
)
|
||||
)
|
||||
)
|
||||
@@ -69,5 +59,14 @@ setup(
|
||||
name=NAME,
|
||||
app=APP,
|
||||
data_files=DATA_FILES,
|
||||
classifiers=[
|
||||
# make sure to use :: Python *and* :: Python :: 3 so
|
||||
# that pypi can list the package on the python 3 page
|
||||
'Programming Language :: Python',
|
||||
'Programming Language :: Python :: 3'
|
||||
],
|
||||
packages=['kcc'],
|
||||
# make sure to add custom_fixers to the MANIFEST.in
|
||||
include_package_data=True,
|
||||
**extra_options
|
||||
)
|
||||
|
||||
Reference in New Issue
Block a user