1
0
mirror of https://github.com/ciromattia/kcc synced 2025-12-13 01:36:27 +00:00

Fix for hardcoded kindlegen HD path.

This commit is contained in:
Ciro Mattia Gonano
2012-12-18 11:39:35 +01:00
parent dd90ab5908
commit fba598d5bf
5 changed files with 65 additions and 49 deletions

View File

@@ -57,7 +57,7 @@
<key>positionOfDivider</key>
<real>568</real>
<key>savedFrame</key>
<string>188 368 889 690 0 0 1920 1058 </string>
<string>666 338 889 690 0 0 1680 1028 </string>
<key>selectedTabView</key>
<string>event log</string>
</dict>

View File

@@ -130,56 +130,67 @@ 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())
'Written 2012 by Ciro Mattia Gonano.' % globals())
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"
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(argv)==4:
title = argv[3]
else:
title = "comic"
filelist = []
try:
print "Splitting double pages..."
for file in os.listdir(dir):
if (getImageFileName(file) != None):
img = image.ComicPage(dir+'/'+file, profile)
img.splitPage(dir)
for file in os.listdir(dir):
if (getImageFileName(file) != None):
print "Optimizing " + file + " for " + profile
img = image.ComicPage(dir+'/'+file, profile)
img.resizeImage()
#img.frameImage()
img.quantizeImage()
img.saveToDir(dir)
except ImportError:
print "Could not load PIL, not optimizing image"
for file in os.listdir(dir):
if (getImageFileName(file) != None and isInFilelist(file,filelist) == False):
# put credits at the end
if "credits" in file.lower():
os.rename(dir+'/'+file, dir+'/ZZZ999_'+file)
file = 'ZZZ999_'+file
filename = HTMLbuilder(dir,file).getResult()
if (filename != None):
filelist.append(filename)
NCXbuilder(dir,title)
# 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:
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"
Usage()
sys.exit(1)
else:
profile = sys.argv[1]
dir = sys.argv[2]
cbx = cbxarchive.CBxArchive(dir)
if cbx.isCbxFile():
cbx.extract()
dir = cbx.getPath()
if len(sys.argv)==4:
title = sys.argv[3]
else:
title = "comic"
filelist = []
try:
print "Splitting double pages..."
for file in os.listdir(dir):
if (getImageFileName(file) != None):
img = image.ComicPage(dir+'/'+file, profile)
img.splitPage(dir)
for file in os.listdir(dir):
if (getImageFileName(file) != None):
print "Optimizing " + file + " for " + profile
img = image.ComicPage(dir+'/'+file, profile)
img.resizeImage()
#img.frameImage()
img.quantizeImage()
img.saveToDir(dir)
except ImportError:
print "Could not load PIL, not optimizing image"
for file in os.listdir(dir):
if (getImageFileName(file) != None and isInFilelist(file,filelist) == False):
# put credits at the end
if "credits" in file.lower():
os.rename(dir+'/'+file, dir+'/ZZZ999_'+file)
file = 'ZZZ999_'+file
filename = HTMLbuilder(dir,file).getResult()
if (filename != None):
filelist.append(filename)
NCXbuilder(dir,title)
# ensure we're sorting files alphabetically
filelist = sorted(filelist, key=lambda name: name[0])
OPFBuilder(dir,title,filelist)
main()
sys.exit(0)

View File

@@ -1699,6 +1699,10 @@ def custom_popen(cmd):
if sys.platform == 'win32':
creationflags = 0x08000000 # CREATE_NO_WINDOW
out_file = open("/tmp/test.txt","w")
out_file.write('[%s]' % ', '.join(map(str, cmd)))
out_file.close()
# run command
p = Popen(cmd, bufsize = 0, stdout = PIPE, stdin = PIPE, stderr = STDOUT,
creationflags = creationflags)

View File

@@ -4,3 +4,4 @@ cp -a resources/Scripts resources/description.rtfd resources/droplet.rsrc Kindle
cp resources/Info.plist KindleComicConverter.app/Contents/
cp resources/comic2ebook.icns KindleComicConverter.app/Contents/Resources/droplet.icns
cp kcc/*.py KindleComicConverter.app/Contents/Resources/
cp `which unrar` KindleComicConverter.app/Contents/Resources/