mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-08 12:36:11 +02:00
Fix to allow retrying, compress mobi chunks, Working/Finished/Failed in status.html title, keep 3 days worth.
This commit is contained in:
parent
302a8f12a3
commit
1f303013bd
4 changed files with 36 additions and 6 deletions
35
main.py
35
main.py
|
|
@ -17,6 +17,7 @@
|
|||
|
||||
import os
|
||||
import sys
|
||||
import zlib
|
||||
import logging
|
||||
import traceback
|
||||
import StringIO
|
||||
|
|
@ -121,8 +122,19 @@ class FileServer(webapp.RequestHandler):
|
|||
self.response.headers['Content-disposition'] = 'attachment; filename=' + name + '.mobi'
|
||||
|
||||
data = DownloadData.all().filter("download =", fanfic).order("index")
|
||||
# epub, txt and html are all already compressed.
|
||||
# Each chunk is compress individually to avoid having
|
||||
# to hold the whole in memory just for the
|
||||
# compress/uncompress
|
||||
if fanfic.format == 'mobi':
|
||||
def dc(data):
|
||||
return zlib.decompress(data)
|
||||
else:
|
||||
def dc(data):
|
||||
return data
|
||||
|
||||
for datum in data:
|
||||
self.response.out.write(datum.blob)
|
||||
self.response.out.write(dc(datum.blob))
|
||||
|
||||
class FileStatusServer(webapp.RequestHandler):
|
||||
def get(self):
|
||||
|
|
@ -196,6 +208,7 @@ class FanfictionDownloader(webapp.RequestHandler):
|
|||
else:
|
||||
download = q[0]
|
||||
download.completed=False
|
||||
download.failure=None
|
||||
for c in download.data_chunks:
|
||||
c.delete()
|
||||
|
||||
|
|
@ -307,7 +320,11 @@ class FanfictionDownloaderTask(webapp.RequestHandler):
|
|||
else:
|
||||
writerClass = output.TextWriter
|
||||
|
||||
loader = FanficLoader(adapter, writerClass, quiet = True, inmemory=True, compress=False)
|
||||
loader = FanficLoader(adapter,
|
||||
writerClass,
|
||||
quiet = True,
|
||||
inmemory=True,
|
||||
compress=False)
|
||||
try:
|
||||
data = loader.download()
|
||||
|
||||
|
|
@ -347,10 +364,22 @@ class FanfictionDownloaderTask(webapp.RequestHandler):
|
|||
download.author = self._printableVersion(adapter.getAuthorName())
|
||||
download.put()
|
||||
index=0
|
||||
|
||||
# epub, txt and html are all already compressed.
|
||||
# Each chunk is compressed individually to avoid having
|
||||
# to hold the whole in memory just for the
|
||||
# compress/uncompress.
|
||||
if format == 'mobi':
|
||||
def c(data):
|
||||
return zlib.compress(data)
|
||||
else:
|
||||
def c(data):
|
||||
return data
|
||||
|
||||
while( len(data) > 0 ):
|
||||
DownloadData(download=download,
|
||||
index=index,
|
||||
blob=data[:1000000]).put()
|
||||
blob=c(data[:1000000])).put()
|
||||
index += 1
|
||||
data = data[1000000:]
|
||||
download.completed=True
|
||||
|
|
|
|||
|
|
@ -49,7 +49,7 @@
|
|||
{% if not fic.completed and not fic.failure %}
|
||||
Request Processing...<br />
|
||||
{% endif %}
|
||||
<small><a href="{{ fic.url }}">{{ fic.url }}</a> ({{ fic.format }})</small>
|
||||
<small><a href="{{ fic.url }}">{{ fic.url }}</a></small>
|
||||
|
||||
</p>
|
||||
{% endfor %}
|
||||
|
|
|
|||
|
|
@ -2,7 +2,7 @@
|
|||
<html>
|
||||
<head>
|
||||
<link href="css/index.css" rel="stylesheet" type="text/css">
|
||||
<title>Fanfiction Downloader - read fanfiction from twilighted.net, fanfiction.net, fictionpress.com, fictionalley.org, ficwad.com, potionsandsnitches.net, harrypotterfanfiction.com, mediaminer.org on Kindle, Nook, Sony Reader, iPad, iPhone, Android, Aldiko, Stanza</title>
|
||||
<title>{% if fic.completed %} Finished {% else %} {% if fic.failure %} Failed {% else %} Working... {% endif %} {% endif %} - Fanfiction Downloader</title>
|
||||
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8">
|
||||
<meta name="google-site-verification" content="kCFc-G4bka_pJN6Rv8CapPBcwmq0hbAUZPkKWqRsAYU" />
|
||||
{% if not fic.completed and not fic.failure %}
|
||||
|
|
@ -48,6 +48,7 @@
|
|||
<p>Not done yet. This page will periodically poll to see if your story has finished.</p>
|
||||
{% endif %}
|
||||
{% endif %}
|
||||
<p>Or see your personal list of <a href="/recent">previously downloaded fanfics</a>.</p>
|
||||
</div>
|
||||
</div>
|
||||
<div style='text-align: center'>
|
||||
|
|
|
|||
|
|
@ -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=3)
|
||||
theDate = datetime.date.today() - datetime.timedelta(days=2)
|
||||
logging.debug("Will delete stuff older than %s" % theDate)
|
||||
|
||||
fics = DownloadMeta.all()
|
||||
|
|
|
|||
Loading…
Reference in a new issue