ficbook.net Add chapter dates for TOC (#1065)

* Fix the broken stuff

* Last correction

* Add chapter dates
This commit is contained in:
dbhmw 2024-04-24 21:57:23 +00:00 committed by GitHub
parent 8674b54753
commit 951acf61b4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 42 additions and 28 deletions

View file

@ -1932,8 +1932,9 @@ add_to_output_css:
white-space: pre-wrap;
}
# 'collections' may generate a lot requests if the work is in many collections. For every 30 there will be additional request made.
extra_valid_entries:dedication,authorcomment,likes,follows,reviews,bookmarks,numcollections,pages,collections
# 'collections' may generate a lot of requests if the work is included in many
# collections. For every 30 there will be additional request made.
extra_valid_entries:dedication,authorcomment,likes,follows,reviews,bookmarks,numcollections,pages
dedication_label:Dedication
authorcomment_label:Author Comment
@ -1943,9 +1944,11 @@ reviews_label:Reviews
bookmarks_label:Bookmarks
numcollections_label:Collections
pages_label:Pages
collections_label:Collections
# add_to_titlepage_entries:, likes, follows, reviews, bookmarks, numcollections, pages
add_to_wide_titlepage_entries:,dedication, authorcomment
# add_to_titlepage_entries:,likes,follows,reviews,bookmarks,numcollections,pages,dedication,authorcomment
add_to_wide_titlepage_entries:,dedication,authorcomment
# exclude_notes: headnotes,footnotes

View file

@ -105,6 +105,19 @@ class FicBookNetAdapter(BaseSiteAdapter):
self.story.setMetadata('author',a.text)
logger.debug("Author: (%s)"%self.story.getMetadata('author'))
fullmon = {"yanvarya":"01", u"января":"01",
"fievralya":"02", u"февраля":"02",
"marta":"03", u"марта":"03",
"aprielya":"04", u"апреля":"04",
"maya":"05", u"мая":"05",
"iyunya":"06", u"июня":"06",
"iyulya":"07", u"июля":"07",
"avghusta":"08", u"августа":"08",
"sentyabrya":"09", u"сентября":"09",
"oktyabrya":"10", u"октября":"10",
"noyabrya":"11", u"ноября":"11",
"diekabrya":"12", u"декабря":"12" }
# Find the chapters:
pubdate = None
chapters = soup.find('ul', {'class' : 'list-of-fanfic-parts'})
@ -112,7 +125,16 @@ class FicBookNetAdapter(BaseSiteAdapter):
for chapdiv in chapters.findAll('li', {'class':'part'}):
chapter=chapdiv.find('a',href=re.compile(r'/readfic/'+self.story.getMetadata('storyId')+r"/\d+#part_content$"))
churl='https://'+self.host+chapter['href']
self.add_chapter(chapter,churl)
# Find the dates
date_str = chapdiv.find('span', {'title': True})['title'].split(' г.')[0]
# Remove additional characters
date_str = date_str.replace('\u202f', '').replace('г. в', '').strip()
for month_name, month_num in fullmon.items():
date_str = date_str.replace(month_name, month_num)
chapterdate = makeDate(date_str,"%d %m %Y %H:%M")
self.add_chapter(chapter,churl,
{'date':chapterdate.strftime(self.getConfig("datechapter_format",self.getConfig("datePublished_format","%Y-%m-%d %H:%M")))})
datespan = chapdiv.find('span')
if pubdate == None and datespan:
@ -133,19 +155,6 @@ class FicBookNetAdapter(BaseSiteAdapter):
pubdate=pubdate.split(',')[0]
update=update.split(',')[0]
fullmon = {"yanvarya":"01", u"января":"01",
"fievralya":"02", u"февраля":"02",
"marta":"03", u"марта":"03",
"aprielya":"04", u"апреля":"04",
"maya":"05", u"мая":"05",
"iyunya":"06", u"июня":"06",
"iyulya":"07", u"июля":"07",
"avghusta":"08", u"августа":"08",
"sentyabrya":"09", u"сентября":"09",
"oktyabrya":"10", u"октября":"10",
"noyabrya":"11", u"ноября":"11",
"diekabrya":"12", u"декабря":"12" }
for (name,num) in fullmon.items():
if name in pubdate:
pubdate = pubdate.replace(name,num)
@ -264,26 +273,25 @@ class FicBookNetAdapter(BaseSiteAdapter):
for coll in targetcoll:
o = coll.find('a', href=re.compile(r'/collections/'))
self.story.addToList('collections', stripHTML(o))
if self.getMetadata('collections') != num_collections:
logger.debug("Collections mismatch: (" + self.story.getMetadata('collections') + '/' + num_collections)
logger.debug("Collections: (%s)"%self.story.getMetadata('collections'))
targetpages = soup.find('strong',string='Размер:').find_next('div')
if targetpages:
pages = re.findall(r'([\d,]+)\s+страницы', targetpages.text)
self.story.setMetadata('pages', pages)
pages = int(', '.join(re.findall(r'([\d,]+)\s+(?:страницы|страниц)', targetpages.text)))
if pages != None and pages > 0:
self.story.setMetadata('pages', pages)
# Find dedication.
ded = soup.find('div', {'class' : 'js-public-beta-dedication'})
if ded != None:
self.story.setMetadata('dedication',stripHTML(ded))
self.story.setMetadata('dedication',ded)
# Find author comment
comm = soup.find('div', {'class' : 'js-public-beta-author-comment'})
if comm != None:
self.story.setMetadata('authorcomment',stripHTML(comm))
self.story.setMetadata('authorcomment',comm)
# grab the text for an individual chapter.

View file

@ -1927,8 +1927,9 @@ add_to_output_css:
white-space: pre-wrap;
}
# 'collections' may generate a lot requests if the work is in many collections. For every 30 there will be additional request made.
extra_valid_entries:dedication,authorcomment,likes,follows,reviews,bookmarks,numcollections,pages,collections
# 'collections' may generate a lot of requests if the work is included in many
# collections. For every 30 there will be additional request made.
extra_valid_entries:dedication,authorcomment,likes,follows,reviews,bookmarks,numcollections,pages
dedication_label:Dedication
authorcomment_label:Author Comment
@ -1938,9 +1939,11 @@ reviews_label:Reviews
bookmarks_label:Bookmarks
numcollections_label:Collections
pages_label:Pages
collections_label:Collections
# add_to_titlepage_entries:, likes, follows, reviews, bookmarks, numcollections, pages
add_to_wide_titlepage_entries:,dedication, authorcomment
# add_to_titlepage_entries:,likes,follows,reviews,bookmarks,numcollections,pages,dedication,authorcomment
add_to_wide_titlepage_entries:,dedication,authorcomment
# exclude_notes: headnotes,footnotes