From 0e28d86a7bbd3a20f8e83a571d3dfb87c5ea3383 Mon Sep 17 00:00:00 2001
From: Jim Miller
Date: Thu, 5 May 2011 20:47:39 -0500
Subject: [PATCH] Fix for zip files, status in epub.
---
fanficdownloader/epubmerge.py | 8 ++++++++
fanficdownloader/writers/base_writer.py | 4 ++++
fanficdownloader/writers/writer_epub.py | 11 ++++++++++-
index.html | 16 +++++-----------
utils/remover.py | 2 +-
5 files changed, 28 insertions(+), 13 deletions(-)
diff --git a/fanficdownloader/epubmerge.py b/fanficdownloader/epubmerge.py
index 6d35be6a..88b0bcb6 100644
--- a/fanficdownloader/epubmerge.py
+++ b/fanficdownloader/epubmerge.py
@@ -81,6 +81,10 @@ def main():
outputepub = ZipFile(outputopt, "w", compression=ZIP_STORED)
outputepub.debug = 3
outputepub.writestr("mimetype", "application/epub+zip")
+ # declares all the files created by Windows. otherwise, when
+ # it runs in appengine, windows unzips the files as 000 perms.
+ for zf in outputepub.filelist:
+ zf.create_system = 0
outputepub.close()
## Re-open file for content.
@@ -277,6 +281,10 @@ def main():
outputepub.writestr("content.opf",contentdom.toxml('utf-8'))
outputepub.writestr("toc.ncx",tocncxdom.toxml('utf-8'))
+ # declares all the files created by Windows. otherwise, when
+ # it runs in appengine, windows unzips the files as 000 perms.
+ for zf in outputepub.filelist:
+ zf.create_system = 0
outputepub.close()
## Utility method for creating new tags.
diff --git a/fanficdownloader/writers/base_writer.py b/fanficdownloader/writers/base_writer.py
index f8866d55..7e8d13c3 100644
--- a/fanficdownloader/writers/base_writer.py
+++ b/fanficdownloader/writers/base_writer.py
@@ -159,6 +159,10 @@ class BaseStoryWriter(Configurable):
self.writeStoryImpl(out)
zipout = ZipFile(outstream, 'w', compression=ZIP_DEFLATED)
zipout.writestr(filename,out.getvalue())
+ # declares all the files created by Windows. otherwise, when
+ # it runs in appengine, windows unzips the files as 000 perms.
+ for zf in zipout.filelist:
+ zf.create_system = 0
zipout.close()
out.close()
else:
diff --git a/fanficdownloader/writers/writer_epub.py b/fanficdownloader/writers/writer_epub.py
index a7d149c6..150ab7ab 100644
--- a/fanficdownloader/writers/writer_epub.py
+++ b/fanficdownloader/writers/writer_epub.py
@@ -153,11 +153,13 @@ h6 { text-align: center; }
## ZipFile can't change compression type file-by-file, so we
## have to close and re-open
outputepub = ZipFile(zipio, 'w', compression=ZIP_STORED)
+ outputepub.debug=3
outputepub.writestr('mimetype','application/epub+zip')
outputepub.close()
## Re-open file for content.
outputepub = ZipFile(zipio, 'a', compression=ZIP_DEFLATED)
+ outputepub.debug=3
## Create META-INF/container.xml file. The only thing it does is
## point to content.opf
@@ -238,6 +240,8 @@ h6 { text-align: center; }
metadata.appendChild(newTag(contentdom,"dc:description",text=
self.getMetadata('description')))
+ metadata.appendChild(newTag(contentdom,"dc:subject",text=
+ self.getMetadata('status')))
# listables all go into dc:suject tags, but only if they are configured.
for (name,lst) in self.story.getLists().iteritems():
if name in self.getConfigList("include_subject_tags"):
@@ -387,7 +391,12 @@ h6 { text-align: center; }
fullhtml = fullhtml.replace('
','\n').replace('
','
\n')
outputepub.writestr("OEBPS/file%04d.xhtml"%(index+1),fullhtml.encode('utf-8'))
del fullhtml
-
+
+ # declares all the files created by Windows. otherwise, when
+ # it runs in appengine, windows unzips the files as 000 perms.
+ logging.debug("outputepub create_system")
+ for zf in outputepub.filelist:
+ zf.create_system = 0
outputepub.close()
out.write(zipio.getvalue())
zipio.close()
diff --git a/index.html b/index.html
index 51d6cd57..b3ec8843 100644
--- a/index.html
+++ b/index.html
@@ -35,23 +35,17 @@ src="http://pagead2.googlesyndication.com/pagead/show_ads.js">
Hi, {{ nickname }}! This is a fan fiction downloader, which makes reading stories from various websites
much easier.
-
For Amazon Kindle use Mobi output(see notice below), for Sony Reader, Nook and iPad use ePub
Or see your personal list of previously downloaded fanfics.
- Experimental New Feature
+ Experimental New Version!
- If you select EPub format, when it's done you will also be given a 'Convert' link.
+ This version is a new re-org/re-write of the code
- That link will take you to convertfiles.com where you can
- directly convert your new story to FictionBook (fb2), Mobipocket (mobi), MS Reader (lit) or Adobe Portable
- Document Format(pdf).
- There's also a 'Convert' link for EPubs on your recent downloads
- page. We'd really like to hear from users about this in our Google Group.
+ So far, only a few sites are supported: fanfiction.net, twilighted.net and whofic.com.
- We'd especially like Kindle and other Mobi users to try it. The convertfiles.com Mobi file
- appears to be more correct than our Mobi output.
+ Mobi support (for Kindle) is only via EPub conversion in this version.
diff --git a/utils/remover.py b/utils/remover.py
index d9aa8249..d81fe85f 100644
--- a/utils/remover.py
+++ b/utils/remover.py
@@ -21,7 +21,7 @@ class Remover(webapp.RequestHandler):
logging.debug("Starting r3m0v3r")
user = users.get_current_user()
logging.debug("Working as user %s" % user)
- theDate = datetime.date.today() - datetime.timedelta(days=5)
+ theDate = datetime.date.today() - datetime.timedelta(days=7)
logging.debug("Will delete stuff older than %s" % theDate)
fics = DownloadMeta.all()