From c9a15371901fc35ecbff0b8b063f714ac18d4747 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Thu, 30 May 2013 12:52:57 -0500 Subject: [PATCH] Fix for numeric site specific values into float/int custom columns. --- calibre-plugin/ffdl_plugin.py | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index 2adb8dd..13ab597 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -1395,7 +1395,11 @@ class FanFictionDownLoaderPlugin(InterfaceAction): if flag == 'r' or book['added']: # flag 'n' isn't actually needed--*always* set if configured and new book. if coldef['datatype'] in ('int','float'): # for favs, etc--site specific metadata. - val = unicode(book['all_metadata'][meta]).replace(",","") + if meta in book['anthology_meta_list']: + # re-split list, strip commas, convert to floats, sum up. + val = sum([ float(x.replace(",","")) for x in book['all_metadata'][meta].split(", ") ]) + else: + val = unicode(book['all_metadata'][meta]).replace(",","") else: val = book['all_metadata'][meta] db.set_custom(book_id, val, label=label, commit=False) @@ -1674,6 +1678,7 @@ class FanFictionDownLoaderPlugin(InterfaceAction): book['tags'] = [] book['url'] = '' book['all_metadata'] = {} + book['anthology_meta_list'] = {} book['comment'] = '' book['added'] = True book['good'] = True @@ -1740,6 +1745,10 @@ class FanFictionDownLoaderPlugin(InterfaceAction): book['all_metadata'][k]=book['all_metadata'][k]+"\n\n"+v else: book['all_metadata'][k]=book['all_metadata'][k]+", "+v + # flag psuedo list element. Used so numeric + # cust cols can convert back to numbers and + # add. + book['anthology_meta_list'][k]=True if existingbook: book['title'] = deftitle = existingbook['title']