mirror of
https://github.com/ciromattia/kcc
synced 2026-05-17 21:11:47 +00:00
Added ComicRack metadata parser
This commit is contained in:
@@ -47,13 +47,14 @@ You can find the latest released binary at the following links:
|
|||||||
### Important tips:
|
### Important tips:
|
||||||
* Use high quality source files. **This little detail have a major impact on the final result.**
|
* Use high quality source files. **This little detail have a major impact on the final result.**
|
||||||
* Read tooltip of _High/Ultra quality_ option. There are many important informations there.
|
* Read tooltip of _High/Ultra quality_ option. There are many important informations there.
|
||||||
|
* **Uploading with Calibre will work only if file will not be modified by any of Calibre converters.**
|
||||||
* When converting images smaller than device resolution remember to enable upscaling.
|
* When converting images smaller than device resolution remember to enable upscaling.
|
||||||
* Panel View (auto zooming every part of page) can be disabled directly on Kindle. There is no KCC option to do that.
|
* Panel View (auto zooming every part of page) can be disabled directly on Kindle. There is no KCC option to do that.
|
||||||
* If you're converting color images and the end result is not satisfactory, experiment with gamma correction option (check 1.0 setting first).
|
* If you're converting color images and the end result is not satisfactory, experiment with gamma correction option (check 1.0 setting first).
|
||||||
* Check our [wiki](https://github.com/ciromattia/kcc/wiki/Other-devices) for a list of tested Non-Kindle E-Readers.
|
* Check our [wiki](https://github.com/ciromattia/kcc/wiki/Other-devices) for a list of tested Non-Kindle E-Readers.
|
||||||
* The first image found will be set as the comic's cover.
|
* The first image found will be set as the comic's cover.
|
||||||
* All files/directories will be added to EPUB in alphabetical order.
|
* All files/directories will be added to EPUB in alphabetical order.
|
||||||
* Output MOBI file should be uploaded via USB. Other methods might corrupt it.
|
* ComicRack metadata will be parsed only if they are saved in *ComicInfo.xml* file.
|
||||||
|
|
||||||
### GUI
|
### GUI
|
||||||
|
|
||||||
|
|||||||
@@ -32,6 +32,7 @@ import string
|
|||||||
from shutil import move, copyfile, copytree, rmtree, make_archive
|
from shutil import move, copyfile, copytree, rmtree, make_archive
|
||||||
from optparse import OptionParser, OptionGroup
|
from optparse import OptionParser, OptionGroup
|
||||||
from multiprocessing import Pool, freeze_support
|
from multiprocessing import Pool, freeze_support
|
||||||
|
from xml.dom.minidom import parse
|
||||||
try:
|
try:
|
||||||
from PyQt4 import QtCore
|
from PyQt4 import QtCore
|
||||||
except ImportError:
|
except ImportError:
|
||||||
@@ -216,9 +217,10 @@ def buildOPF(dstdir, title, filelist, cover=None):
|
|||||||
"xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n",
|
"xmlns:dc=\"http://purl.org/dc/elements/1.1/\">\n",
|
||||||
"<dc:title>", title.encode('utf-8'), "</dc:title>\n",
|
"<dc:title>", title.encode('utf-8'), "</dc:title>\n",
|
||||||
"<dc:language>en-US</dc:language>\n",
|
"<dc:language>en-US</dc:language>\n",
|
||||||
"<dc:identifier id=\"BookID\" opf:scheme=\"UUID\">", options.uuid, "</dc:identifier>\n",
|
"<dc:identifier id=\"BookID\" opf:scheme=\"UUID\">", options.uuid, "</dc:identifier>\n"])
|
||||||
"<dc:Creator>KCC</dc:Creator>\n",
|
for author in options.authors:
|
||||||
"<meta name=\"generator\" content=\"KindleComicConverter-" + __version__ + "\"/>\n",
|
f.writelines(["<dc:Creator>", author.encode('utf-8'), "</dc:Creator>\n"])
|
||||||
|
f.writelines(["<meta name=\"generator\" content=\"KindleComicConverter-" + __version__ + "\"/>\n",
|
||||||
"<meta name=\"RegionMagnification\" content=\"true\"/>\n",
|
"<meta name=\"RegionMagnification\" content=\"true\"/>\n",
|
||||||
"<meta name=\"region-mag\" content=\"true\"/>\n",
|
"<meta name=\"region-mag\" content=\"true\"/>\n",
|
||||||
"<meta name=\"cover\" content=\"cover\"/>\n",
|
"<meta name=\"cover\" content=\"cover\"/>\n",
|
||||||
@@ -573,6 +575,47 @@ def getWorkFolder(afile):
|
|||||||
return path
|
return path
|
||||||
|
|
||||||
|
|
||||||
|
def checkComicInfo(path):
|
||||||
|
xmlPath = os.path.join(path, 'ComicInfo.xml')
|
||||||
|
options.authors = ['KCC']
|
||||||
|
if os.path.exists(xmlPath):
|
||||||
|
try:
|
||||||
|
xml = parse(xmlPath)
|
||||||
|
except StandardError:
|
||||||
|
os.remove(xmlPath)
|
||||||
|
return
|
||||||
|
options.authors = []
|
||||||
|
if options.title == 'defaulttitle':
|
||||||
|
if len(xml.getElementsByTagName('Series')) != 0:
|
||||||
|
options.title = xml.getElementsByTagName('Series')[0].firstChild.nodeValue
|
||||||
|
if len(xml.getElementsByTagName('Volume')) != 0:
|
||||||
|
options.title += ' V' + xml.getElementsByTagName('Volume')[0].firstChild.nodeValue
|
||||||
|
if len(xml.getElementsByTagName('Number')) != 0:
|
||||||
|
options.title += ' #' + xml.getElementsByTagName('Number')[0].firstChild.nodeValue
|
||||||
|
if len(xml.getElementsByTagName('Writer')) != 0:
|
||||||
|
authorsTemp = string.split(xml.getElementsByTagName('Writer')[0].firstChild.nodeValue, ', ')
|
||||||
|
for author in authorsTemp:
|
||||||
|
options.authors.append(author)
|
||||||
|
if len(xml.getElementsByTagName('Penciller')) != 0:
|
||||||
|
authorsTemp = string.split(xml.getElementsByTagName('Penciller')[0].firstChild.nodeValue, ', ')
|
||||||
|
for author in authorsTemp:
|
||||||
|
options.authors.append(author)
|
||||||
|
if len(xml.getElementsByTagName('Inker')) != 0:
|
||||||
|
authorsTemp = string.split(xml.getElementsByTagName('Inker')[0].firstChild.nodeValue, ', ')
|
||||||
|
for author in authorsTemp:
|
||||||
|
options.authors.append(author)
|
||||||
|
if len(xml.getElementsByTagName('Colorist')) != 0:
|
||||||
|
authorsTemp = string.split(xml.getElementsByTagName('Colorist')[0].firstChild.nodeValue, ', ')
|
||||||
|
for author in authorsTemp:
|
||||||
|
options.authors.append(author)
|
||||||
|
if len(options.authors) > 0:
|
||||||
|
options.authors = list(set(options.authors))
|
||||||
|
options.authors.sort()
|
||||||
|
else:
|
||||||
|
options.authors = ['KCC']
|
||||||
|
os.remove(xmlPath)
|
||||||
|
|
||||||
|
|
||||||
def slugify(value):
|
def slugify(value):
|
||||||
# Normalizes string, converts to lowercase, removes non-alpha characters and converts spaces to hyphens.
|
# Normalizes string, converts to lowercase, removes non-alpha characters and converts spaces to hyphens.
|
||||||
import unicodedata
|
import unicodedata
|
||||||
@@ -853,6 +896,7 @@ def main(argv=None, qtGUI=None):
|
|||||||
parser.print_help()
|
parser.print_help()
|
||||||
return
|
return
|
||||||
path = getWorkFolder(args[0])
|
path = getWorkFolder(args[0])
|
||||||
|
checkComicInfo(path + "/OEBPS/Images/")
|
||||||
if options.webtoon:
|
if options.webtoon:
|
||||||
if GUI:
|
if GUI:
|
||||||
GUI.emit(QtCore.SIGNAL("progressBarTick"), 'status', 'Splitting images')
|
GUI.emit(QtCore.SIGNAL("progressBarTick"), 'status', 'Splitting images')
|
||||||
@@ -880,18 +924,18 @@ def main(argv=None, qtGUI=None):
|
|||||||
else:
|
else:
|
||||||
GUI.emit(QtCore.SIGNAL("progressBarTick"), 'status', 'Compressing EPUB files')
|
GUI.emit(QtCore.SIGNAL("progressBarTick"), 'status', 'Compressing EPUB files')
|
||||||
GUI.emit(QtCore.SIGNAL("progressBarTick"), len(tomes))
|
GUI.emit(QtCore.SIGNAL("progressBarTick"), len(tomes))
|
||||||
|
if options.title == 'defaulttitle':
|
||||||
|
if os.path.isdir(args[0]):
|
||||||
|
options.title = os.path.basename(args[0])
|
||||||
|
else:
|
||||||
|
options.title = os.path.splitext(os.path.basename(args[0]))[0]
|
||||||
|
options.baseTitle = options.title
|
||||||
for tome in tomes:
|
for tome in tomes:
|
||||||
if GUI:
|
if GUI:
|
||||||
GUI.emit(QtCore.SIGNAL("progressBarTick"))
|
GUI.emit(QtCore.SIGNAL("progressBarTick"))
|
||||||
if os.path.isdir(args[0]):
|
|
||||||
barePath = os.path.basename(args[0])
|
|
||||||
else:
|
|
||||||
barePath = os.path.splitext(os.path.basename(args[0]))[0]
|
|
||||||
if len(tomes) > 1:
|
if len(tomes) > 1:
|
||||||
tomeNumber += 1
|
tomeNumber += 1
|
||||||
options.title = barePath + ' ' + str(tomeNumber)
|
options.title = options.baseTitle + ' [' + str(tomeNumber) + '/' + str(len(tomes)) + ']'
|
||||||
elif options.title == 'defaulttitle':
|
|
||||||
options.title = barePath
|
|
||||||
if options.cbzoutput:
|
if options.cbzoutput:
|
||||||
# if CBZ output wanted, compress all images and return filepath
|
# if CBZ output wanted, compress all images and return filepath
|
||||||
print "\nCreating CBZ file..."
|
print "\nCreating CBZ file..."
|
||||||
|
|||||||
Reference in New Issue
Block a user