Skip to content

Commit

Permalink
adapter_literotica: Improved description collection. #1058
Browse files Browse the repository at this point in the history
  • Loading branch information
JimmXinu committed Apr 27, 2024
1 parent 6116a19 commit 4436001
Showing 1 changed file with 9 additions and 12 deletions.
21 changes: 9 additions & 12 deletions fanficfare/adapters/adapter_literotica.py
Original file line number Diff line number Diff line change
Expand Up @@ -173,6 +173,15 @@ def extractChapterUrlsAndMetadata(self):

self.story.extendList('eroticatags', [ stripHTML(t).title() for t in soup.select('div#tabpanel-tags a.av_as') ])

## look first for 'Series Introduction', then Info panel short desc
## series can have either, so put in common code.
introtag = soup.select_one('div.bp_rh p')
descdiv = soup.select_one('div#tabpanel-info div.bn_B')
if introtag:
self.setDescription(self.url,introtag)
elif descdiv:
self.setDescription(self.url,descdiv)

if isSingleStory:
## one-shots don't *display* date info, but they have it
## hidden in <script>
Expand All @@ -189,11 +198,6 @@ def extractChapterUrlsAndMetadata(self):
## one-shots assumed completed.
self.story.setMetadata('status','Completed')


descdiv = soup.select_one('div#tabpanel-info div.bn_B')
if descdiv:
self.setDescription(self.url,descdiv)

# Add the category from the breadcumb.
self.story.addToList('category', soup.find('div', id='BreadCrumbComponent').findAll('a')[1].string)

Expand Down Expand Up @@ -275,13 +279,6 @@ def extractChapterUrlsAndMetadata(self):
# logger.debug("Chapter URL: " + chapurl)
self.add_chapter(chapter_title, chapurl)

descriptions = []
for i, chapterdesctag in enumerate(soup.select('p.br_rk')):
# get rid of category link
chapterdesctag.a.decompose()
descriptions.append("%d. %s" % (i + 1, stripHTML(chapterdesctag)))
self.setDescription(authorurl,"<p>"+"</p>\n<p>".join(descriptions)+"</p>")

# <img src="https://uploads.literotica.com/series/cover/813-1695143444-desktop-x1.jpg" alt="Series cover">
coverimg = soup.select_one('img[alt="Series cover"]')
if coverimg:
Expand Down

0 comments on commit 4436001

Please sign in to comment.