From 07c9bfd346a40135744495f46341bd934573adfa Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Tue, 16 Oct 2012 16:02:02 -0500 Subject: [PATCH] Make PI temp file name contain title/author for HTML format. --- calibre-plugin/ffdl_plugin.py | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index a0a81e2..1d33471 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -637,9 +637,12 @@ make_firstimage_cover:true if book['good']: # there shouldn't be any !'good' books at this point. # if still 'good', make a temp file to write the output to. - tmp = PersistentTemporaryFile(prefix='new-%s-'%book['calibre_id'], - suffix='.'+options['fileform'], - dir=options['tdir']) + # For HTML format users, make the filename inside the zip something reasonable. + # For crazy long titles/authors, limit it to 200chars. + # For weird/OS-unsafe characters, use file safe only. + tmp = PersistentTemporaryFile(prefix=story.formatFileName("${title}-${author}-",allowunsafefilename=False)[:100], + suffix='.'+options['fileform'], + dir=options['tdir']) print("title:"+book['title']) print("outfile:"+tmp.name) book['outfile'] = tmp.name