diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 2270fbc..310a3e1 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -1070,6 +1070,23 @@ extracategories:In Death ## cover image. This lets you exclude them. cover_exclusion_regexp:/public/style_emoticons/.* +[it-could-happen.net] +## Some sites do not require a login, but do require the user to +## confirm they are adult for adult content. In commandline version, +## this should go in your personal.ini, not defaults.ini. +#is_adult:true + +## RPF == http://en.wikipedia.org/wiki/Real_person_fiction +## Site dedicated to these categories/characters/ships +extracategories:Glee RPF +extracharacters:Darren Criss, Chris Colfer +extraships:Darren Criss/Chris Colfer + +## Virtually all eFiction Base adapters allow downloading the whole story in +## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both +## metadata and chapters can be loaded in one step +bulk_load:true + [ksarchive.com] ## Site dedicated to these categories/characters/ships extracategories:Star Trek diff --git a/fanficfare/adapters/__init__.py b/fanficfare/adapters/__init__.py index ffb99ad..606e0c5 100644 --- a/fanficfare/adapters/__init__.py +++ b/fanficfare/adapters/__init__.py @@ -134,6 +134,7 @@ import adapter_fhsarchivecom import adapter_fanfictionjunkiesde import adapter_devianthearts import adapter_tgstorytimecom +import adapter_itcouldhappennet ## This bit of complexity allows adapters to be added by just adding ## importing. It eliminates the long if/else clauses we used to need @@ -196,6 +197,12 @@ def getAdapter(config,url,anyurl=False): def getConfigSections(): return [cls.getConfigSection() for cls in __class_list] +def get_bulk_load_sites(): + # for now, all eFiction Base adapters are assumed to allow bulk_load. + return [cls.getConfigSection().replace('www.','') for cls in + filter( lambda x : issubclass(x,base_efiction_adapter.BaseEfictionAdapter), + __class_list)] + def getSiteExamples(): l=[] for cls in sorted(__class_list, key=lambda x : x.getConfigSection()): diff --git a/fanficfare/adapters/adapter_itcouldhappennet.py b/fanficfare/adapters/adapter_itcouldhappennet.py new file mode 100644 index 0000000..7e6329c --- /dev/null +++ b/fanficfare/adapters/adapter_itcouldhappennet.py @@ -0,0 +1,46 @@ +# -*- coding: utf-8 -*- + +# Copyright 2015 FanFicFare team +# +# Licensed under the Apache License, Version 2.0 (the "License"); +# you may not use this file except in compliance with the License. +# You may obtain a copy of the License at +# +# http://www.apache.org/licenses/LICENSE-2.0 +# +# Unless required by applicable law or agreed to in writing, software +# distributed under the License is distributed on an "AS IS" BASIS, +# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. +# See the License for the specific language governing permissions and +# limitations under the License. +# + +# Software: eFiction +import re +from base_efiction_adapter import BaseEfictionAdapter + +class ItCouldHappenNetSiteAdapter(BaseEfictionAdapter): + + @staticmethod + def getSiteDomain(): + return 'it-could-happen.net' + + @classmethod + def getSiteAbbrev(seluuf): + return 'ich' + + @classmethod + def getDateFormat(self): + return "%B %d, %Y" + + def handleMetadataPair(self, key, value): + # This site is all one 'category' as it's usually defined and + # uses Category for what is usually genre. + if key == 'Categories': + for val in re.split("\s*,\s*", value): + self.story.addToList('genre', val) + else: + super(ItCouldHappenNetSiteAdapter, self).handleMetadataPair(key, value) + +def getClass(): + return ItCouldHappenNetSiteAdapter diff --git a/fanficfare/adapters/base_efiction_adapter.py b/fanficfare/adapters/base_efiction_adapter.py index d0beeb4..e306d4e 100644 --- a/fanficfare/adapters/base_efiction_adapter.py +++ b/fanficfare/adapters/base_efiction_adapter.py @@ -89,7 +89,6 @@ class BaseEfictionAdapter(BaseSiteAdapter): """ return ["Windows-1252", "utf8"] - @classmethod def getPathToArchive(cls): """ diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index b7cf376..d0bb323 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -118,16 +118,10 @@ def get_valid_set_options(): 'universe_as_series':(['storiesonline.net'],None,boollist), 'strip_text_links':(['bloodshedverse.com'],None,boollist), - # eFiction Base - 'bulk_load':(['fannation.shades-of-moonlight.com', - 'fhsarchive.com', - 'lotrfanfiction.com', - 'themaplebookshelf.com', - 'devianthearts.com', - 'thehookupzone.net', - 'libraryofmoria.com', - 'tgstorytime.com', - ],None,boollist), + # eFiction Base adapters allow bulk_load + # kept forgetting to add them, so now it's automatic. + 'bulk_load':(adapters.get_bulk_load_sites(), + None,boollist), 'include_logpage':(None,['epub'],boollist+['smart']), @@ -137,6 +131,7 @@ def get_valid_set_options(): 'grayscale_images':(None,['epub','html'],boollist), 'no_image_processing':(None,['epub','html'],boollist), } + return dict(valdict) def get_valid_scalar_entries(): diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index eb83cf6..dbd26a7 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -758,7 +758,7 @@ extraships:Spike/Buffy ## this should go in your personal.ini, not defaults.ini. #is_adult:true -## Virtually all eFiction-based sites allow downloading the whole story in +## Virtually all eFiction Base adapters allow downloading the whole story in ## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both ## metadata and chapters can be loaded in one step bulk_load:true @@ -925,7 +925,7 @@ extraships:Harry Potter/Hermione Granger #username:YourName #password:yourpassword -## Virtually all eFiction-based sites allow downloading the whole story in +## Virtually all eFiction Base adapters allow downloading the whole story in ## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both ## metadata and chapters can be loaded in one step bulk_load:true @@ -1065,6 +1065,23 @@ extracategories:In Death ## cover image. This lets you exclude them. cover_exclusion_regexp:/public/style_emoticons/.* +[it-could-happen.net] +## Some sites do not require a login, but do require the user to +## confirm they are adult for adult content. In commandline version, +## this should go in your personal.ini, not defaults.ini. +#is_adult:true + +## RPF == http://en.wikipedia.org/wiki/Real_person_fiction +## Site dedicated to these categories/characters/ships +extracategories:Glee RPF +extracharacters:Darren Criss, Chris Colfer +extraships:Darren Criss/Chris Colfer + +## Virtually all eFiction Base adapters allow downloading the whole story in +## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both +## metadata and chapters can be loaded in one step +bulk_load:true + [ksarchive.com] ## Site dedicated to these categories/characters/ships extracategories:Star Trek @@ -1084,7 +1101,7 @@ eroticatags_label:Erotica Tags extra_titlepage_entries: eroticatags [lotrfanfiction.com] -## Virtually all eFiction-based sites allow downloading the whole story in +## Virtually all eFiction Base adapters allow downloading the whole story in ## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both ## metadata and chapters can be loaded in one step bulk_load:true @@ -1338,7 +1355,7 @@ extracategories:Transgender ## confirm they are adult for adult content. #is_adult:true -## Virtually all eFiction-based sites allow downloading the whole story in +## Virtually all eFiction Base adapters allow downloading the whole story in ## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both ## metadata and chapters can be loaded in one step bulk_load:true @@ -1362,7 +1379,7 @@ extraships:Harry Potter/Draco Malfoy ## personal.ini, not defaults.ini. #is_adult:true -## Virtually all eFiction-based sites allow downloading the whole story in +## Virtually all eFiction Base adapters allow downloading the whole story in ## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both ## metadata and chapters can be loaded in one step bulk_load:true @@ -1376,7 +1393,7 @@ extracategories:Criminal Minds ## personal.ini, not defaults.ini. #is_adult:true -## Virtually all eFiction-based sites allow downloading the whole story in +## Virtually all eFiction Base adapters allow downloading the whole story in ## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both ## metadata and chapters can be loaded in one step bulk_load:true @@ -1722,7 +1739,7 @@ extraships:InuYasha/Kagome ## Site dedicated to these categories/characters/ships extracategories:Lord of the Rings -## Virtually all eFiction-based sites allow downloading the whole story in +## Virtually all eFiction Base adapters allow downloading the whole story in ## bulk using the 'Print' feature. If 'bulk_load' is set to 'true', both ## metadata and chapters can be loaded in one step bulk_load:true