diff --git a/calibre-plugin/config.py b/calibre-plugin/config.py index f3422d47..5bdb6caa 100644 --- a/calibre-plugin/config.py +++ b/calibre-plugin/config.py @@ -736,10 +736,10 @@ permitted_values = { 'description', 'author', 'authorUrl', - 'formatname' + 'formatname', + 'version' #,'formatext' # not useful information. #,'siteabbrev' - #,'version' ] } # no point copying the whole list. diff --git a/calibre-plugin/ffdl_plugin.py b/calibre-plugin/ffdl_plugin.py index f4786cf7..4980d357 100644 --- a/calibre-plugin/ffdl_plugin.py +++ b/calibre-plugin/ffdl_plugin.py @@ -36,7 +36,7 @@ from calibre.gui2.actions import InterfaceAction from calibre_plugins.fanfictiondownloader_plugin.common_utils import (set_plugin_icon_resources, get_icon, create_menu_action_unique, get_library_uuid) -from calibre_plugins.fanfictiondownloader_plugin.fanficdownloader import adapters, writers, exceptions +from calibre_plugins.fanfictiondownloader_plugin.fanficdownloader import adapters, exceptions from calibre_plugins.fanfictiondownloader_plugin.fanficdownloader.configurable import Configuration from calibre_plugins.fanfictiondownloader_plugin.fanficdownloader.epubutils import get_dcsource, get_dcsource_chaptercount, get_story_url_from_html from calibre_plugins.fanfictiondownloader_plugin.fanficdownloader.geturls import get_urls_from_page @@ -486,7 +486,10 @@ make_firstimage_cover:true # let other exceptions percolate up. story = adapter.getStoryMetadataOnly() - writer = writers.getWriter(options['fileform'],configuration,adapter) + + # set PI version instead of default. + if 'version' in options: + story.setMetadata('version',options['version']) book['all_metadata'] = story.getAllMetadata(removeallentities=True) book['title'] = story.getMetadata("title", removeallentities=True) diff --git a/calibre-plugin/jobs.py b/calibre-plugin/jobs.py index a5daeb42..2fad2e10 100644 --- a/calibre-plugin/jobs.py +++ b/calibre-plugin/jobs.py @@ -133,10 +133,12 @@ def do_download_for_worker(book,options): story = adapter.getStoryMetadataOnly() if 'calibre_series' in book: - # print("calibre_series:%s [%d]"%book['calibre_series']) adapter.setSeries(book['calibre_series'][0],book['calibre_series'][1]) - # else: - # print("no calibre_series") + + # set PI version instead of default. + if 'version' in options: + story.setMetadata('version',options['version']) + writer = writers.getWriter(options['fileform'],configuration,adapter) outfile = book['outfile'] diff --git a/defaults.ini b/defaults.ini index ce9c5a0b..d710ffe5 100644 --- a/defaults.ini +++ b/defaults.ini @@ -378,6 +378,17 @@ extracharacters:Reginald Smythe-Smythe,Mokona extraships:Smythe-Smythe/Mokona extrawarnings:Extreme Bogosity +extra_valid_entries:metaA,metaB,metaC,listX,listY,listZ,compositeJ,compositeK,compositeL + +include_in_compositeJ:dateCreated +include_in_compositeK:metaC,listX,compositeL,compositeJ,compositeK +include_in_compositeL:ships,metaA,listZ,datePublished,dateUpdated, + +#include_in_ships:compositeK,genre + +extra_titlepage_entries: metaA,metaB,metaC,listX,listY,listZ,compositeJ,compositeK,compositeL +extra_logpage_entries: metaA,metaB,metaC,listX,listY,listZ,compositeJ,compositeK,compositeL + ## If necessary, you can define [:] sections to ## customize the formats differently for the same site. Overrides ## defaults, format and site. @@ -501,9 +512,7 @@ extra_valid_entries:themes,hermiones,dracos,timeline,cliches include_in_cliches:hermiones,dracos ## For another example, you could, by uncommenting this line, include -## themes in with genre metadata. Note, however, that you couldn't -## use cliches. include_in_* can only include the original real -## entries, not other include_in_* values. +## themes in with genre metadata. #include_in_genre:genre, themes ## You can give each new valid entry a specific label for use on @@ -519,7 +528,7 @@ cliches_label:Character Cliches ## specific entries to titlepage/logpage without having to copy the ## entire titlepage_entries line. (But if you want them higher than ## the end, you will need to copy titlepage_entries.) -extra_titlepage_entries: themes,hermiones,dracos,timeline,cliches +#extra_titlepage_entries: themes,hermiones,dracos,timeline,cliches [erosnsappho.sycophanthex.com] ## Site dedicated to these categories/characters/ships diff --git a/fanficdownloader/adapters/adapter_test1.py b/fanficdownloader/adapters/adapter_test1.py index 1e0a1905..29e9d7d2 100644 --- a/fanficdownloader/adapters/adapter_test1.py +++ b/fanficdownloader/adapters/adapter_test1.py @@ -134,6 +134,25 @@ Some more longer description. "I suck at summaries!" "Better than it sounds!" self.story.addToList('characters','George Johnson') self.story.addToList('characters','Fred Smythe') + self.story.addToList('listX','xVal1') + self.story.addToList('listX','xVal2') + self.story.addToList('listX','xVal3') + self.story.addToList('listX','xVal4') + + self.story.addToList('listY','yVal1') + self.story.addToList('listY','yVal2') + self.story.addToList('listY','yVal3') + self.story.addToList('listY','yVal4') + + self.story.addToList('listZ','zVal1') + self.story.addToList('listZ','zVal2') + self.story.addToList('listZ','zVal3') + self.story.addToList('listZ','zVal4') + + self.story.setMetadata('metaA','98765') + self.story.setMetadata('metaB','01245') + self.story.setMetadata('metaC','The mighty metaC!') + self.chapterUrls = [(u'Prologue '+self.crazystring,self.url+"&chapter=1"), ('Chapter 1, Xenos on Cinnabar',self.url+"&chapter=2"), ('Chapter 2, Sinmay on Kintikin',self.url+"&chapter=3"), diff --git a/fanficdownloader/story.py b/fanficdownloader/story.py index a4ea20f8..1241f2b5 100644 --- a/fanficdownloader/story.py +++ b/fanficdownloader/story.py @@ -323,15 +323,17 @@ class Story(Configurable): def getList(self,listname, removeallentities=False, doreplacements=True, - doincludein=True): + includelist=[]): + #print("getList(%s,%s)"%(listname,includelist)) retlist = [] + if not self.isValidMetaEntry(listname): return retlist - # doincludein prevents recursion of include_in_'s - if doincludein and self.hasConfig("include_in_"+listname): + # includelist prevents infinite recursion of include_in_'s + if self.hasConfig("include_in_"+listname) and listname not in includelist: for k in self.getConfigList("include_in_"+listname): - retlist.extend(self.getList(k,removeallentities,doreplacements,doincludein=False)) + retlist.extend(self.getList(k,removeallentities,doreplacements,includelist=includelist+[listname])) else: if not self.isList(listname): @@ -339,14 +341,18 @@ class Story(Configurable): else: retlist = self.getMetadataRaw(listname) - if doreplacements: + if doreplacements and retlist: retlist = filter( lambda x : x!=None and x!='' , map(self.doReplacments,retlist) ) - if removeallentities: + if removeallentities and retlist: retlist = filter( lambda x : x!=None and x!='' , map(removeAllEntities,retlist) ) - return retlist + if retlist: + # remove dups and sort. + return sorted(list(set(retlist))) + else: + return [] def getSubjectTags(self, removeallentities=False): # set to avoid duplicates subject tags. diff --git a/plugin-defaults.ini b/plugin-defaults.ini index 9792280f..d39ba78a 100644 --- a/plugin-defaults.ini +++ b/plugin-defaults.ini @@ -70,6 +70,7 @@ extratags_label:Extra Tags version_label:FFDL Version ## Date formats used by FFDL. Published and Update don't have time. +## See http://docs.python.org/library/datetime.html#strftime-strptime-behavior ## Note that ini format requires % to be escaped as %%. dateCreated_format:%%Y-%%m-%%d %%H:%%M:%%S datePublished_format:%%Y-%%m-%%d @@ -358,6 +359,17 @@ extracharacters:Reginald Smythe-Smythe,Mokona extraships:Smythe-Smythe/Mokona extrawarnings:Extreme Bogosity +extra_valid_entries:metaA,metaB,metaC,listX,listY,listZ,compositeJ,compositeK,compositeL + +include_in_compositeJ:dateCreated +include_in_compositeK:metaC,listX,compositeL,compositeJ,compositeK +include_in_compositeL:ships,metaA,listZ,datePublished,dateUpdated, + +#include_in_ships:compositeK,genre + +extra_titlepage_entries: metaA,metaB,metaC,listX,listY,listZ,compositeJ,compositeK,compositeL +extra_logpage_entries: metaA,metaB,metaC,listX,listY,listZ,compositeJ,compositeK,compositeL + ## If necessary, you can define [:] sections to ## customize the formats differently for the same site. Overrides ## defaults, format and site. @@ -858,6 +870,10 @@ extracategories:Harry Potter ## Clear FanFiction from defaults, fictionpress.com is original fiction. extratags: +## Extra metadata that this adapter knows about. See [dramione.org] +## for examples of how to use them. +extra_valid_entries:reviews,favs,follows + [www.ficwad.com] ## Some sites require login (or login for some rated stories) The ## program can prompt you, or you can save it in config. In