mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-21 16:23:58 +01:00
epub zip is now produced correctly, also TOC works with Stanza now
This commit is contained in:
parent
d2d183430d
commit
f55e6d3c05
3 changed files with 12 additions and 6 deletions
|
|
@ -41,7 +41,7 @@ CONTENT_START = '''<?xml version="1.0"?>
|
|||
<dc:identifier id="BookId">urn:uuid:sigizmund.com062820072147132</dc:identifier>
|
||||
</metadata>
|
||||
<manifest>
|
||||
<item id="ncx" href="toc.ncx" media-type="text/xml" />
|
||||
<item id="ncx" href="toc.ncx" media-type="application/x-dtbncx+xml"/>
|
||||
<item id="style" href="stylesheet.css" media-type="text/css" />
|
||||
'''
|
||||
|
||||
|
|
|
|||
10
output.py
10
output.py
|
|
@ -69,6 +69,8 @@ class EPubFanficWriter(FanficWriter):
|
|||
v = entities[e]
|
||||
text = text.replace(e, v)
|
||||
|
||||
text = text.replace('&', '&')
|
||||
|
||||
return text
|
||||
|
||||
def writeChapter(self, title, text):
|
||||
|
|
@ -100,9 +102,10 @@ class EPubFanficWriter(FanficWriter):
|
|||
# cleanup(self.soup )
|
||||
|
||||
text = self.soup.prettify()
|
||||
print(text)
|
||||
|
||||
print >> f, XHTML_START % (title, title)
|
||||
tt = self._removeEntities(title)
|
||||
|
||||
print >> f, XHTML_START % (tt, tt)
|
||||
f.write(text)
|
||||
print >> f, XHTML_END
|
||||
|
||||
|
|
@ -147,6 +150,9 @@ class EPubFanficWriter(FanficWriter):
|
|||
|
||||
print >> opf, CONTENT_END
|
||||
|
||||
opf.close()
|
||||
toc.close()
|
||||
|
||||
print('Finished')
|
||||
|
||||
filename = self.directory + '.epub'
|
||||
|
|
|
|||
|
|
@ -21,7 +21,7 @@ def toZip(filename, directory):
|
|||
zippedHelp.close()
|
||||
|
||||
def addFolderToZip(zippedHelp,folder,fpath):
|
||||
print('addFolderToZip(%s)' % folder)
|
||||
#print('addFolderToZip(%s)' % folder)
|
||||
|
||||
if folder == '.' or folder == '..':
|
||||
return
|
||||
|
|
@ -29,11 +29,11 @@ def addFolderToZip(zippedHelp,folder,fpath):
|
|||
folderFiles = os.listdir(fpath)
|
||||
for f in folderFiles:
|
||||
if os.path.isfile(fpath + '/' + f):
|
||||
print('basename=%s' % os.path.basename(fpath + '/' + f))
|
||||
#print('basename=%s' % os.path.basename(fpath + '/' + f))
|
||||
zippedHelp.write(fpath + '/' + f, folder + '/' + f, zipfile.ZIP_DEFLATED)
|
||||
elif os.path.isdir(f):
|
||||
addFolderToZip(zippedHelp,f)
|
||||
|
||||
if __name__ == '__main__':
|
||||
toZip('sample.epub', "books/Harry's_Second_Chance:_Back_From_the_Future")
|
||||
toZip('sample.epub', "books/A_Time_To_Reflect")
|
||||
z = zipfile.ZipFile('sample.epub', 'r')
|
||||
Loading…
Reference in a new issue