mirror of
https://github.com/JimmXinu/FanFicFare.git
synced 2025-12-29 04:05:47 +01:00
Add 'averrating' and tweak description: adapter_literotica
This commit is contained in:
parent
8e9870d4fd
commit
4a57d95eb2
3 changed files with 19 additions and 7 deletions
|
|
@ -1334,9 +1334,10 @@ crossoverfandom_label:Crossover Fandom
|
|||
extra_titlepage_entries:universe,crossoverfandom
|
||||
|
||||
[literotica.com]
|
||||
extra_valid_entries:eroticatags
|
||||
extra_valid_entries:eroticatags,averrating
|
||||
eroticatags_label:Erotica Tags
|
||||
extra_titlepage_entries: eroticatags
|
||||
averrating_label:Average Rating
|
||||
extra_titlepage_entries:eroticatags,averrating
|
||||
|
||||
[lotrfanfiction.com]
|
||||
extra_valid_entries: readings
|
||||
|
|
|
|||
|
|
@ -21,7 +21,6 @@ logger = logging.getLogger(__name__)
|
|||
import re
|
||||
import urllib2
|
||||
import urlparse
|
||||
import time
|
||||
|
||||
from bs4.element import Comment
|
||||
from ..htmlcleanup import stripHTML
|
||||
|
|
@ -173,6 +172,10 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
|
|||
self.story.setMetadata('datePublished', makeDate(date, self.dateformat))
|
||||
self.story.setMetadata('dateUpdated',makeDate(date, self.dateformat))
|
||||
self.chapterUrls = [(storyLink.text, self.url)]
|
||||
averrating = stripHTML(storyLink.parent)
|
||||
## title (0.00)
|
||||
averrating = averrating[averrating.rfind('(')+1:averrating.rfind(')')]
|
||||
self.story.setMetadata('averrating',averrating)
|
||||
else:
|
||||
seriesTr = urlTr.previousSibling
|
||||
while 'ser-ttl' not in seriesTr['class']:
|
||||
|
|
@ -185,8 +188,9 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
|
|||
self.chapterUrls = []
|
||||
dates = []
|
||||
descriptions = []
|
||||
ratings = []
|
||||
while chapterTr is not None and 'sl' in chapterTr['class']:
|
||||
descriptions.append(chapterTr.findAll("td")[1].text)
|
||||
descriptions.append("<br>\n%d. %s" % (len(descriptions)+1, stripHTML(chapterTr.findAll("td")[1])) )
|
||||
chapterLink = chapterTr.find("td", "fc").find("a")
|
||||
if not chapterLink["href"].startswith('http'):
|
||||
chapterLink["href"] = "http:" + chapterLink["href"]
|
||||
|
|
@ -194,9 +198,13 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
|
|||
self.story.addToList('eroticatags', chapterTr.findAll("td")[2].text)
|
||||
dates.append(makeDate(chapterTr.findAll('td')[-1].text, self.dateformat))
|
||||
chapterTr = chapterTr.nextSibling
|
||||
numrating = stripHTML(chapterLink.parent)
|
||||
## title (0.00)
|
||||
numrating = numrating[numrating.rfind('(')+1:numrating.rfind(')')]
|
||||
ratings.append(float(numrating))
|
||||
|
||||
## Set description to joint chapter descriptions
|
||||
self.story.setMetadata('description', " / ".join(descriptions))
|
||||
self.setDescription(authorurl,"".join(descriptions))
|
||||
|
||||
## Set the oldest date as publication date, the newest as update date
|
||||
dates.sort()
|
||||
|
|
@ -206,6 +214,8 @@ class LiteroticaSiteAdapter(BaseSiteAdapter):
|
|||
# normalize on first chapter URL.
|
||||
self._setURL(self.chapterUrls[0][1])
|
||||
|
||||
self.story.setMetadata('averrating','%4.2f' % (sum(ratings) / float(len(ratings))))
|
||||
|
||||
self.story.setMetadata('numChapters', len(self.chapterUrls))
|
||||
|
||||
# set storyId to 'title-author' to avoid duplicates
|
||||
|
|
|
|||
|
|
@ -1322,9 +1322,10 @@ crossoverfandom_label:Crossover Fandom
|
|||
extra_titlepage_entries:universe,crossoverfandom
|
||||
|
||||
[literotica.com]
|
||||
extra_valid_entries:eroticatags
|
||||
extra_valid_entries:eroticatags,averrating
|
||||
eroticatags_label:Erotica Tags
|
||||
extra_titlepage_entries: eroticatags
|
||||
averrating_label:Average Rating
|
||||
extra_titlepage_entries:eroticatags,averrating
|
||||
|
||||
[lotrfanfiction.com]
|
||||
extra_valid_entries: readings
|
||||
|
|
|
|||
Loading…
Reference in a new issue