mirror of
https://github.com/ciromattia/kcc
synced 2025-12-13 09:46:25 +00:00
Fixes folder handling, subfolders and issues with spaces and # on filenames.
This commit is contained in:
@@ -114,6 +114,7 @@ and installed in `/usr/local/bin/`
|
||||
- 2.1: Added basic error reporting
|
||||
- 2.2: Added (valid!) ePub 2.0 output
|
||||
Rename .zip files to .cbz to avoid overwriting
|
||||
- 2.3: Fixed win32 ePub generation, folder handling, filenames with spaces and subfolders.
|
||||
|
||||
## TODO
|
||||
- Add gracefully exit for CBR if no rarfile.py and no unrar executable are found
|
||||
|
||||
2
kcc.py
2
kcc.py
@@ -16,7 +16,7 @@
|
||||
# TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
|
||||
# PERFORMANCE OF THIS SOFTWARE.
|
||||
#
|
||||
__version__ = '2.2'
|
||||
__version__ = '2.3'
|
||||
__license__ = 'ISC'
|
||||
__copyright__ = '2012-2013, Ciro Mattia Gonano <ciromattia@gmail.com>'
|
||||
__docformat__ = 'restructuredtext en'
|
||||
|
||||
@@ -50,13 +50,17 @@ def buildHTML(path,file):
|
||||
filename = getImageFileName(file)
|
||||
if filename is not None:
|
||||
postfix = ''
|
||||
backref = 1
|
||||
head = path
|
||||
while True:
|
||||
head, tail = os.path.split(head)
|
||||
if tail == 'Images':
|
||||
htmlpath = os.path.join(head,'Text')
|
||||
htmlpath = os.path.join(head,'Text',postfix)
|
||||
break
|
||||
postfix = tail + "/" + postfix
|
||||
backref += 1
|
||||
if not os.path.exists(htmlpath):
|
||||
os.makedirs(htmlpath)
|
||||
htmlfile = os.path.join(htmlpath,filename[0] + '.html')
|
||||
f = open(htmlfile, "w")
|
||||
f.writelines(["<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.1//EN\" \"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd\">\n",
|
||||
@@ -66,7 +70,7 @@ def buildHTML(path,file):
|
||||
"<meta http-equiv=\"Content-Type\" content=\"text/html; charset=utf-8\"/>\n",
|
||||
"</head>\n",
|
||||
"<body>\n",
|
||||
"<div><img src=\"../Images/",postfix,file,"\" alt=\"",file,"\" /></div>\n",
|
||||
"<div><img src=\"","../" * backref,"Images/",postfix,file,"\" alt=\"",file,"\" /></div>\n",
|
||||
"</body>\n",
|
||||
"</html>"
|
||||
])
|
||||
@@ -133,7 +137,7 @@ def buildOPF(profile, dstdir, title, filelist, cover=None):
|
||||
filename = getImageFileName(path[1])
|
||||
uniqueid = os.path.join(folder,filename[0]).replace('/','_')
|
||||
reflist.append(uniqueid)
|
||||
f.write("<item id=\"page_" + uniqueid + "\" href=\"" + os.path.join(folder.replace('Images/','Text/'),filename[0])
|
||||
f.write("<item id=\"page_" + uniqueid + "\" href=\"" + os.path.join(folder.replace('Images','Text'),filename[0])
|
||||
+ ".html\" media-type=\"application/xhtml+xml\"/>\n")
|
||||
if '.png' == filename[1]:
|
||||
mt = 'image/png'
|
||||
|
||||
@@ -155,7 +155,7 @@ class MainWindow:
|
||||
if self.epub_only == 1:
|
||||
continue;
|
||||
try:
|
||||
retcode = call("kindlegen " + epub_path, shell=True)
|
||||
retcode = call("kindlegen \"" + epub_path + "\"", shell=True)
|
||||
if retcode < 0:
|
||||
print >>sys.stderr, "Child was terminated by signal", -retcode
|
||||
else:
|
||||
|
||||
Reference in New Issue
Block a user