mirror of
https://github.com/ciromattia/kcc
synced 2025-12-26 08:01:52 +00:00
@@ -123,7 +123,9 @@ The app relies and includes the following scripts/binaries:
|
||||
Added generic CSS file
|
||||
Optimized archive extraction for zip/rar files (#40)
|
||||
- 2.9: 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
|
||||
Filenames slugifications (#28, #31, #9, #8)
|
||||
|
||||
|
||||
## COPYRIGHT
|
||||
|
||||
@@ -128,7 +128,7 @@ def buildNCX(dstdir, title, chapters):
|
||||
f = open(ncxfile, "w")
|
||||
f.writelines(["<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n",
|
||||
"<!DOCTYPE ncx PUBLIC \"-//NISO//DTD ncx 2005-1//EN\" ",
|
||||
"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd\">\n",
|
||||
"\"http://www.daisy.org/z3986/2005/ncx-2005-1.dtd\">\n",
|
||||
"<ncx version=\"2005-1\" xml:lang=\"en-US\" xmlns=\"http://www.daisy.org/z3986/2005/ncx/\">\n",
|
||||
"<head>\n",
|
||||
"<meta name=\"dtb:uid\" content=\"015ffaec-9340-42f8-b163-a0c5ab7d0611\"/>\n",
|
||||
@@ -356,6 +356,7 @@ def genEpubStruct(path):
|
||||
chapterlist = []
|
||||
cover = None
|
||||
_, deviceres, _, _, panelviewsize = image.ProfileData.Profiles[options.profile]
|
||||
slugifyFileTree(path)
|
||||
os.mkdir(os.path.join(path, 'OEBPS', 'Text'))
|
||||
f = open(os.path.join(path, 'OEBPS', 'Text', 'style.css'), 'w')
|
||||
#DON'T COMPRESS CSS. KINDLE WILL FAIL TO PARSE IT.
|
||||
@@ -535,6 +536,29 @@ def getWorkFolder(afile):
|
||||
return path
|
||||
|
||||
|
||||
def slugify(value):
|
||||
"""
|
||||
Normalizes string, converts to lowercase, removes non-alpha characters,
|
||||
and converts spaces to hyphens.
|
||||
"""
|
||||
import unicodedata
|
||||
value = unicodedata.normalize('NFKD', unicode(value)).encode('ascii', 'ignore')
|
||||
value = re.sub('[^\w\s-]', '', value).strip()
|
||||
value = re.sub('[-\s]+', '-', value)
|
||||
return value
|
||||
|
||||
|
||||
def slugifyFileTree(filetree):
|
||||
for root, dirs, files in os.walk(filetree):
|
||||
for name in files:
|
||||
splitname = os.path.splitext(name)
|
||||
os.rename(os.path.join(root, name),
|
||||
os.path.join(root, slugify(splitname[0]) + splitname[1]))
|
||||
for name in dirs:
|
||||
slugifyFileTree(os.path.join(root, name))
|
||||
os.rename(os.path.join(root, name), os.path.join(root, slugify(name)))
|
||||
|
||||
|
||||
def Copyright():
|
||||
print ('comic2ebook v%(__version__)s. '
|
||||
'Written 2012 by Ciro Mattia Gonano.' % globals())
|
||||
|
||||
Reference in New Issue
Block a user