mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2026-05-05 11:00:47 +02:00
Add chapter range to title if used. Can be disabled in ini.
This commit is contained in:
parent
cfbe3610af
commit
49c899df5d
6 changed files with 50 additions and 22 deletions
|
|
@ -1002,6 +1002,8 @@ class FanFicFarePlugin(InterfaceAction):
|
|||
return
|
||||
|
||||
adapter = get_fff_adapter(url,fileform)
|
||||
## chapter range for title_chapter_range_pattern
|
||||
adapter.setChaptersRange(book['begin'],book['end'])
|
||||
## save and share cookiejar and pagecache between all
|
||||
## downloads.
|
||||
if 'pagecache' not in options:
|
||||
|
|
|
|||
|
|
@ -261,6 +261,11 @@ keep_summary_html:true
|
|||
## kept. Some sites(AO3) use <a title="Translation">Foreign language</a>
|
||||
#keep_title_attr: false
|
||||
|
||||
## If a chapter range was given, use this pattern for the book title.
|
||||
## replace_metadata and include/exclude will be applied *after* this.
|
||||
## Set to empty value to disable.
|
||||
title_chapter_range_pattern:${title} (Ch ${first}-${last})
|
||||
|
||||
## Don't like the numbers at the start of chapter titles on some
|
||||
## sites? You can use strip_chapter_numbers to strip them off. Just
|
||||
## want to make them all look the same? Strip them off, then add them
|
||||
|
|
@ -1222,28 +1227,6 @@ extracategories:Lord of the Rings
|
|||
## Site dedicated to these categories/characters/ships
|
||||
extracategories:Harry Potter
|
||||
|
||||
[www.masseffect2.in]
|
||||
## Site dedicated to this fandom.
|
||||
extracategories: Mass Effect
|
||||
|
||||
## Ucoz.com engine, upon which MassEffect2.in is based, imposes an unspecified limit on request frequency.
|
||||
## Reports vary from `5 requests per second' to `2 requests per second for more than 10 per minute'.
|
||||
## With default settings, a several-hours IP ban may follow, so set it higher.
|
||||
slow_down_sleep_time: 2
|
||||
|
||||
## Whether to exclude editor signature from the bottom of chapter text.
|
||||
exclude_editor_signature: false
|
||||
|
||||
## Stories on the site almost never have cover image, and for the stories which do,
|
||||
## this may be adjusted in `personal.ini' before downloading.
|
||||
never_make_cover: true
|
||||
|
||||
## Titles for ratings identified by 1- or 2-letter codes from `ERATING system'
|
||||
## (`система Р.Е.Й.Т.И.Н.Г.'). MassEffect2.in and some other sites adopted it,
|
||||
## but changed titles and update them occasionally.
|
||||
rating_titles: R=RESTRICTED (16+), E=EXEMPT (18+), I=ART HOUSE, T=To every, A=IN=Иной мир, Nn=Новый мир, G=О\, Господи!
|
||||
adult_ratings: E,R
|
||||
|
||||
[merlinfic.dtwins.co.uk]
|
||||
## Some sites require login (or login for some rated stories) The
|
||||
## program can prompt you, or you can save it in config. In
|
||||
|
|
@ -1865,6 +1848,28 @@ extraships:InuYasha/Kagome
|
|||
## Site dedicated to these categories/characters/ships
|
||||
extracategories:Lord of the Rings
|
||||
|
||||
[www.masseffect2.in]
|
||||
## Site dedicated to this fandom.
|
||||
extracategories: Mass Effect
|
||||
|
||||
## Ucoz.com engine, upon which MassEffect2.in is based, imposes an unspecified limit on request frequency.
|
||||
## Reports vary from `5 requests per second' to `2 requests per second for more than 10 per minute'.
|
||||
## With default settings, a several-hours IP ban may follow, so set it higher.
|
||||
slow_down_sleep_time: 2
|
||||
|
||||
## Whether to exclude editor signature from the bottom of chapter text.
|
||||
exclude_editor_signature: false
|
||||
|
||||
## Stories on the site almost never have cover image, and for the stories which do,
|
||||
## this may be adjusted in `personal.ini' before downloading.
|
||||
never_make_cover: true
|
||||
|
||||
## Titles for ratings identified by 1- or 2-letter codes from `ERATING system'
|
||||
## (`система Р.Е.Й.Т.И.Н.Г.'). MassEffect2.in and some other sites adopted it,
|
||||
## but changed titles and update them occasionally.
|
||||
rating_titles: R=RESTRICTED (16+), E=EXEMPT (18+), I=ART HOUSE, T=To every, A=IN=Иной мир, Nn=Новый мир, G=О\, Господи!
|
||||
adult_ratings: E,R
|
||||
|
||||
[www.mediaminer.org]
|
||||
|
||||
[www.midnightwhispers.ca]
|
||||
|
|
|
|||
|
|
@ -355,6 +355,7 @@ class BaseSiteAdapter(Configurable):
|
|||
self.chapterFirst=int(first)-1
|
||||
if last:
|
||||
self.chapterLast=int(last)-1
|
||||
self.story.set_chapters_range(first,last)
|
||||
|
||||
# Does the download the first time it's called.
|
||||
def getStory(self):
|
||||
|
|
|
|||
|
|
@ -268,6 +268,11 @@ keep_summary_html:true
|
|||
## kept. Some sites(AO3) use <a title="Translation">Foreign language</a>
|
||||
#keep_title_attr: false
|
||||
|
||||
## If a chapter range was given, use this pattern for the book title.
|
||||
## replace_metadata and include/exclude will be applied *after* this.
|
||||
## Set to empty value to disable.
|
||||
title_chapter_range_pattern:${title} (Ch ${first}-${last})
|
||||
|
||||
## Don't like the numbers at the start of chapter titles on some
|
||||
## sites? You can use strip_chapter_numbers to strip them off. Just
|
||||
## want to make them all look the same? Strip them off, then add them
|
||||
|
|
|
|||
|
|
@ -416,6 +416,8 @@ class Story(Configurable):
|
|||
self.metadata = {'version':'4.4'}
|
||||
self.in_ex_cludes = {}
|
||||
self.chapters = [] # chapters will be namedtuple of Chapter(url,title,html,etc)
|
||||
self.chapter_first = None
|
||||
self.chapter_last = None
|
||||
self.imgurls = []
|
||||
self.imgtuples = []
|
||||
|
||||
|
|
@ -444,6 +446,10 @@ class Story(Configurable):
|
|||
iel = []
|
||||
self.in_ex_cludes[ie] = set_in_ex_clude(ies)
|
||||
|
||||
def set_chapters_range(self,first=None,last=None):
|
||||
self.chapter_first=first
|
||||
self.chapter_last=last
|
||||
|
||||
def join_list(self, key, vallist):
|
||||
return self.getConfig("join_string_"+key,u", ").replace(SPACE_REPLACE,' ').join(map(unicode, [ x for x in vallist if x is not None ]))
|
||||
|
||||
|
|
@ -644,6 +650,14 @@ class Story(Configurable):
|
|||
if key in ("datePublished","dateUpdated"):
|
||||
value = value.strftime(self.getConfig(key+"_format","%Y-%m-%d"))
|
||||
|
||||
if key == "title" and (self.chapter_first or self.chapter_last) and self.getConfig("title_chapter_range_pattern"):
|
||||
first = self.chapter_first or "1"
|
||||
last = self.chapter_last or self.getMetadata("numChapters")
|
||||
templ = string.Template(self.getConfig("title_chapter_range_pattern"))
|
||||
value = templ.substitute({'title':value,
|
||||
'first':commaGroups(first),
|
||||
'last':commaGroups(last)})
|
||||
|
||||
if doreplacements:
|
||||
value=self.doReplacements(value,key)
|
||||
if removeallentities and value != None:
|
||||
|
|
|
|||
|
|
@ -395,6 +395,7 @@ class FanfictionDownloader(UserConfigServer):
|
|||
return
|
||||
|
||||
adapter = adapters.getAdapter(configuration,url)
|
||||
adapter.setChaptersRange(ch_begin,ch_end)
|
||||
logging.info('Created an adaper: %s' % adapter)
|
||||
|
||||
if login or password:
|
||||
|
|
|
|||
Loading…
Reference in a new issue