mirror of
https://github.com/kemayo/leech
synced 2026-05-09 05:20:46 +02:00
Xenforo: if fetching a specific threadmark category, add it to the title
Unless it's 1, since that's always "threadmarks" and the main story. Refs #79
This commit is contained in:
parent
64d97b09d0
commit
172877410b
1 changed files with 10 additions and 0 deletions
|
|
@ -69,6 +69,12 @@ class XenForo(Site):
|
|||
|
||||
story = self._base_story(soup)
|
||||
|
||||
threadmark_categories = {}
|
||||
# Note to self: in the source this is data-categoryId, but the parser
|
||||
# in bs4 lowercases tags and attributes...
|
||||
for cat in soup.find_all('a', attrs={'data-categoryid': True}):
|
||||
threadmark_categories[int(cat['data-categoryid'])] = cat['title']
|
||||
|
||||
if url.endswith('/reader'):
|
||||
reader_url = url
|
||||
elif soup.find('a', class_='readerToggle'):
|
||||
|
|
@ -80,6 +86,10 @@ class XenForo(Site):
|
|||
reader_url = False
|
||||
|
||||
if reader_url:
|
||||
if m := re.search(r'\d+/(\d+)/reader', reader_url):
|
||||
cat = int(m.group(1))
|
||||
if cat != 1 and cat in threadmark_categories:
|
||||
story.title = f'{story.title} ({threadmark_categories[cat]})'
|
||||
idx = 0
|
||||
while reader_url:
|
||||
reader_url = self._join_url(base, reader_url)
|
||||
|
|
|
|||
Loading…
Reference in a new issue