Compare commits

...
6 changed files with 34 additions and 12 deletions
+1 -1
View File
@@ -26,7 +26,7 @@ class FanFictionDownLoaderBase(InterfaceActionBase):
description = 'UI plugin to download FanFiction stories from various sites.'
supported_platforms = ['windows', 'osx', 'linux']
author = 'Jim Miller'
version = (1, 7, 38)
version = (1, 7, 39)
minimum_calibre_version = (0, 8, 57)
#: This field defines the GUI plugin class that contains all the code
+21 -11
View File
@@ -1112,7 +1112,7 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
try:
self.update_metadata(db, book['calibre_id'], book, mi, options)
except:
det_msg = "".join(traceback.format_exception(*sys.exc_info()))+"\nStory Details:\n%s"%book
det_msg = "".join(traceback.format_exception(*sys.exc_info()))+"\nStory Details:\n%s"%pretty_book(book)
print("Error Updating Metadata:\n%s"%det_msg)
error_dialog(self.gui,
"Error Updating Metadata",
@@ -1170,10 +1170,20 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
self.gui.library_view.sort_by_named_field('marked', True)
self.gui.status_bar.show_message(_('Finished Adding/Updating %d books.'%(len(update_list) + len(add_list))), 3000)
1+1
print("all done, remove temp dir.")
1+1
remove_dir(options['tdir'])
1+1
print("removed temp dir.")
if 'Count Pages' in self.gui.iactions and len(prefs['countpagesstats']) and len(all_ids):
cp_plugin = self.gui.iactions['Count Pages']
cp_plugin.count_statistics(all_ids,prefs['countpagesstats'])
@@ -1430,6 +1440,8 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
pass
db.set_metadata(book_id,mi)
# mi.authors gets run through the string_to_authors and split on '&' ',' 'and' and 'with'
db.set_authors(book_id,book['author']) # author is a list.
# do configured column updates here.
#print("all_metadata: %s"%book['all_metadata'])
@@ -1519,23 +1531,21 @@ class FanFictionDownLoaderPlugin(InterfaceAction):
if 'authorUrl' in book['all_metadata']:
authurls = book['all_metadata']['authorUrl'].split(", ")
if hasattr(db, 'new_api'): # new_api starts in calibre 1.0.0
authorids = db.new_api.get_item_ids('authors',book['author'])
authorlist = [ a.replace('&',';') for a in book['author'] ]
authorids = db.new_api.get_item_ids('authors',authorlist)
authordata = db.new_api.author_data(authorids.values())
# print("\n\nauthorids:%s"%authorids)
# print("authordata:%s"%authordata)
author_id_to_link_map = dict()
for i, author in enumerate(book['author']):
aid = authorids[author]
# this additional check shouldn't be needed after calibre 1.0.0
if authordata[aid]['link'] != authurls[i]:
author_id_to_link_map[aid] = authurls[i]
for i, author in enumerate(authorlist):
author_id_to_link_map[authorids[author]] = authurls[i]
# print("author_id_to_link_map:%s\n\n"%author_id_to_link_map)
db.new_api.set_link_for_authors(author_id_to_link_map)
else:
# keep for pre-calibre 1.0.0
for i, auth in enumerate(book['author']):
for i, auth in enumerate(authorlist):
#print("===Update author url for %s to %s"%(auth,authurls[i]))
autid=db.get_author_id(auth)
db.set_link_field_for_author(autid, unicode(authurls[i]),
@@ -1935,8 +1945,8 @@ def escapehtml(txt):
def pretty_book(d, indent=0, spacer=' '):
kindent = spacer * indent
if isinstance(d, list):
return '\n'.join([(pretty_book(v, indent, spacer)) for v in d])
# if isinstance(d, list):
# return '\n'.join([(pretty_book(v, indent, spacer)) for v in d])
if isinstance(d, dict):
for k in ('password','username'):
+3
View File
@@ -152,6 +152,9 @@ extratags: FanFiction
#extraships:
#extrawarnings:
## Add this to genre if there's more than one category.
#add_genre_when_multi_category: Crossover
## number of seconds to sleep between calls to the story site. May by
## useful if pulling large numbers of stories or if the site is slow.
#slow_down_sleep_time:0.5
+3
View File
@@ -411,6 +411,9 @@ class Story(Configurable):
if not value in self.metadata[listname]:
self.metadata[listname].append(value)
if listname == 'category' and self.getConfig('add_genre_when_multi_category') and len(self.metadata[listname]) > 1:
self.addToList('genre',self.getConfig('add_genre_when_multi_category'))
def isList(self,listname):
'Everything set with an include_in_* is considered a list.'
return self.hasConfig("include_in_"+listname) or \
+3
View File
@@ -124,6 +124,9 @@ extratags: FanFiction
#extraships:
#extrawarnings:
## Add this to genre if there's more than one category.
#add_genre_when_multi_category: Crossover
## number of seconds to sleep between calls to the story site. May by
## useful if pulling large numbers of stories or if the site is slow.
#slow_down_sleep_time:0.5
+3
View File
@@ -15,6 +15,9 @@
#strip_chapter_numbers:true
#add_chapter_numbers:true
## Add this to genre if there's more than one category.
#add_genre_when_multi_category: Crossover
[epub]
## include images from img tags in the body and summary of stories.
## Images will be converted to jpg for size if possible. Images work