From 2b623ed429c529bd492ad4a1221f97cc33bc9e04 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Fri, 18 Dec 2015 15:54:33 -0600 Subject: [PATCH] Add centeredcat_to_characters, pairingcat_to_characters_ships, romancecat_to_characters_ships features to TtH adapter. --- calibre-plugin/plugin-defaults.ini | 22 ++++++++++++++++++++ fanficfare/adapters/adapter_tthfanficorg.py | 23 +++++++++++++++++++-- fanficfare/defaults.ini | 22 ++++++++++++++++++++ 3 files changed, 65 insertions(+), 2 deletions(-) diff --git a/calibre-plugin/plugin-defaults.ini b/calibre-plugin/plugin-defaults.ini index 517c33e..f21fc7e 100644 --- a/calibre-plugin/plugin-defaults.ini +++ b/calibre-plugin/plugin-defaults.ini @@ -2131,6 +2131,28 @@ collect_series: false #username:YourName #password:yourpassword +## TtH uses 'category' Buffy-Centered, Xander-Centered, etc. If +## centeredcat_to_characters:true, they will not be included in the +## category list and Buffy, Xander, etc will instead be included in +## the characters list. +centeredcat_to_characters:true + +## TtH uses 'category' Pairing: Dawn, Pairing: Willow, etc, but only +## if there's already been a -Centered category, like Xander-Centered. +## If pairingcat_to_characters_ships:true, Pairing: Whomever will not +## be included in the category list and Dawn, Willow, etc will instead +## be included in the characters list *and* an entry added to the +## ships list for Centered character / Pairing character. IE, +## category: Xander-Centered, Pairing: Dawn becomes characters: +## Xander, Dawn and ships: Xander/Dawn. +pairingcat_to_characters_ships:true + +## TtH uses 'category' Romance followed by a pairing 'category', such +## as Romance > Buffy/Spike. If romancecat_to_characters_ships:true, +## Romance will still be added to category, but Buffy/Spike will +## instead be added to characters Buffy, Spike and ships Buffy/Spike +romancecat_to_characters_ships:true + [www.twilightarchives.com] ## Site dedicated to these categories/characters/ships extracategories:Twilight diff --git a/fanficfare/adapters/adapter_tthfanficorg.py b/fanficfare/adapters/adapter_tthfanficorg.py index 3749917..cefad8b 100644 --- a/fanficfare/adapters/adapter_tthfanficorg.py +++ b/fanficfare/adapters/adapter_tthfanficorg.py @@ -247,9 +247,28 @@ class TwistingTheHellmouthSiteAdapter(BaseSiteAdapter): BtVS = True BtVSNonX = False + char=None + romance=False for cat in verticaltable.findAll('a', href=re.compile(r"^/Category-")): - if cat.string not in ['General', 'Non-BtVS/AtS Stories', 'Non-BTVS/AtS Stories', 'BtVS/AtS Non-Crossover', 'Non-BtVS Crossovers']: - self.story.addToList('category',cat.string) + # assumes only one -Centered and one Pairing: cat can ever + # be applied to one story. + if self.getConfig('centeredcat_to_characters') and cat.string.endswith('-Centered'): + char = cat.string[:-len('-Centered')] + self.story.addToList('characters',char) + elif self.getConfig('pairingcat_to_characters_ships') and cat.string.startswith('Pairing: '): + pair = cat.string[len('Pairing: '):] + self.story.addToList('characters',pair) + self.story.addToList('ships',char+'/'+pair) + elif cat.string not in ['General', 'Non-BtVS/AtS Stories', 'Non-BTVS/AtS Stories', 'BtVS/AtS Non-Crossover', 'Non-BtVS Crossovers']: + # assumed only ship category after Romance cat. + if self.getConfig('romancecat_to_characters_ships') and romance: + self.story.addToList('ships',cat.string) + for c in cat.string.split('/'): + self.story.addToList('characters',c) + else: + self.story.addToList('category',cat.string) + if cat.string == 'Romance': + romance=True else: if 'Non-BtVS' in cat.string or 'Non-BTVS' in cat.string: BtVS = False diff --git a/fanficfare/defaults.ini b/fanficfare/defaults.ini index e103155..6ab9530 100644 --- a/fanficfare/defaults.ini +++ b/fanficfare/defaults.ini @@ -2113,6 +2113,28 @@ collect_series: false #username:YourName #password:yourpassword +## TtH uses 'category' Buffy-Centered, Xander-Centered, etc. If +## centeredcat_to_characters:true, they will not be included in the +## category list and Buffy, Xander, etc will instead be included in +## the characters list. +centeredcat_to_characters:true + +## TtH uses 'category' Pairing: Dawn, Pairing: Willow, etc, but only +## if there's already been a -Centered category, like Xander-Centered. +## If pairingcat_to_characters_ships:true, Pairing: Whomever will not +## be included in the category list and Dawn, Willow, etc will instead +## be included in the characters list *and* an entry added to the +## ships list for Centered character / Pairing character. IE, +## category: Xander-Centered, Pairing: Dawn becomes characters: +## Xander, Dawn and ships: Xander/Dawn. +pairingcat_to_characters_ships:true + +## TtH uses 'category' Romance followed by a pairing 'category', such +## as Romance > Buffy/Spike. If romancecat_to_characters_ships:true, +## Romance will still be added to category, but Buffy/Spike will +## instead be added to characters Buffy, Spike and ships Buffy/Spike +romancecat_to_characters_ships:true + [www.twilightarchives.com] ## Site dedicated to these categories/characters/ships extracategories:Twilight