mirror of
https://github.com/kemayo/leech
synced 2025-12-06 08:22:56 +01:00
xenforo: minor fixes around images in spoilers
This commit is contained in:
parent
3c5a4bb75a
commit
81189f4e1d
1 changed files with 19 additions and 28 deletions
|
|
@ -296,6 +296,14 @@ class XenForo(Site):
|
||||||
del tag['style']
|
del tag['style']
|
||||||
for tag in post.select('.quoteExpand, .bbCodeBlock-expandLink, .bbCodeBlock-shrinkLink'):
|
for tag in post.select('.quoteExpand, .bbCodeBlock-expandLink, .bbCodeBlock-shrinkLink'):
|
||||||
tag.decompose()
|
tag.decompose()
|
||||||
|
for tag in post.find_all('noscript'):
|
||||||
|
# TODO: strip the noscript from these?
|
||||||
|
# mostly this will be the lazyload images
|
||||||
|
tag.decompose()
|
||||||
|
for tag in post.select('img.lazyload[data-src]'):
|
||||||
|
tag['src'] = tag['data-url']
|
||||||
|
if tag['src'].startswith('proxy.php'):
|
||||||
|
tag['src'] = f"{self.domain}/{tag['src']}"
|
||||||
self._clean(post, base)
|
self._clean(post, base)
|
||||||
self._clean_spoilers(post, chapterid)
|
self._clean_spoilers(post, chapterid)
|
||||||
return post.prettify()
|
return post.prettify()
|
||||||
|
|
@ -303,23 +311,6 @@ class XenForo(Site):
|
||||||
def _clean_spoilers(self, post, chapterid):
|
def _clean_spoilers(self, post, chapterid):
|
||||||
# spoilers don't work well, so turn them into epub footnotes
|
# spoilers don't work well, so turn them into epub footnotes
|
||||||
for spoiler in post.find_all(class_='ToggleTriggerAnchor'):
|
for spoiler in post.find_all(class_='ToggleTriggerAnchor'):
|
||||||
spoilerTarget = spoiler.find(class_='SpoilerTarget')
|
|
||||||
|
|
||||||
# This is a bit of a hack, but it works
|
|
||||||
# This downloads the spoiler image
|
|
||||||
img_exist = list(spoilerTarget.find_all('img'))
|
|
||||||
if len(img_exist) > 0:
|
|
||||||
for i in img_exist:
|
|
||||||
# For some weird reason, the images are duplicated, so this should skip some
|
|
||||||
if img_exist.index(i) % 2 == 0:
|
|
||||||
i.decompose()
|
|
||||||
else:
|
|
||||||
if not i.has_attr('src'):
|
|
||||||
i['src'] = i['data-url']
|
|
||||||
if i['src'].startswith('proxy.php'):
|
|
||||||
i['src'] = f"{self.domain}/{i['src']}"
|
|
||||||
spoiler.replace_with(spoiler.find(class_='SpoilerTarget'))
|
|
||||||
else:
|
|
||||||
spoiler_title = spoiler.find(class_='SpoilerTitle')
|
spoiler_title = spoiler.find(class_='SpoilerTitle')
|
||||||
if self.options['skip_spoilers']:
|
if self.options['skip_spoilers']:
|
||||||
link = self._footnote(spoiler.find(class_='SpoilerTarget').extract(), chapterid)
|
link = self._footnote(spoiler.find(class_='SpoilerTarget').extract(), chapterid)
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue