From 29809dec651fd6975645ad460dc885580e223357 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 9 Jan 2013 10:09:38 -0600 Subject: [PATCH] Handle errors in job download correctly. PI only. --- calibre-plugin/ffdl_plugin.py | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index b99aab4..8d2e0fd 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -922,7 +922,8 @@ make_firstimage_cover:true book_list = job.result good_list = filter(lambda x : x['good'], book_list) - bad_list = filter(lambda x : x['calibre_id'] and not x['good'], book_list) + bad_list = filter(lambda x : not x['good'], book_list) + print("book_list:%s"%book_list) payload = (good_list, bad_list, options) msg = ''' @@ -937,14 +938,14 @@ make_firstimage_cover:true status = book['status'] else: status = 'Good' - htmllog = htmllog + '' + ''.join([status,book['title'],", ".join(book['author']),book['comment'],book['url']]) + '' + htmllog = htmllog + '' + ''.join([escapehtml(status),escapehtml(book['title']),escapehtml(", ".join(book['author'])),escapehtml(book['comment']),book['url']]) + '' for book in bad_list: if 'status' in book: status = book['status'] else: status = 'Bad' - htmllog = htmllog + '' + ''.join([status,book['title'],", ".join(book['author']),book['comment'],book['url']]) + '' + htmllog = htmllog + '' + ''.join([escapehtml(status),escapehtml(book['title']),escapehtml(", ".join(book['author'])),escapehtml(book['comment']),book['url']]) + '' htmllog = htmllog + '' @@ -953,7 +954,6 @@ make_firstimage_cover:true 'FFDL log', 'FFDL download complete', msg, show_copy_button=False) - def _do_download_list_update(self, payload): (good_list,bad_list,options) = payload @@ -1423,3 +1423,6 @@ def get_url_list(urls): # set removes dups. return set(filter(f,urls.strip().splitlines())) +def escapehtml(txt): + return txt.replace("&","&").replace(">",">").replace("<","<") +