1
0
Fork 0
mirror of https://github.com/kemayo/leech synced 2025-12-06 16:33:16 +01:00

RoyalRoad: don't error when covers are relative URLs

Only happens when the work has no set cover, because it gets a /dist/
URL rather than a CDN URL.

Fixes #77
This commit is contained in:
David Lynch 2022-02-22 12:19:58 -06:00
parent 7eb48c872d
commit 29589a0886

View file

@ -37,6 +37,8 @@ class RoyalRoad(Site):
soup = self._soup(f'https://www.{self.domain}.com/fiction/{workid}') soup = self._soup(f'https://www.{self.domain}.com/fiction/{workid}')
# should have gotten redirected, for a valid title # should have gotten redirected, for a valid title
base = soup.head.base and soup.head.base.get('href') or url
original_maxheaders = http.client._MAXHEADERS original_maxheaders = http.client._MAXHEADERS
http.client._MAXHEADERS = 1000 http.client._MAXHEADERS = 1000
@ -44,7 +46,7 @@ class RoyalRoad(Site):
title=soup.find('h1', property='name').string.strip(), title=soup.find('h1', property='name').string.strip(),
author=soup.find('meta', property='books:author').get('content').strip(), author=soup.find('meta', property='books:author').get('content').strip(),
url=soup.find('meta', property='og:url').get('content').strip(), url=soup.find('meta', property='og:url').get('content').strip(),
cover_url=soup.find('img', class_='thumbnail')['src'], cover_url=self._join_url(base, soup.find('img', class_='thumbnail')['src']),
summary=str(soup.find('div', property='description')).strip(), summary=str(soup.find('div', property='description')).strip(),
tags=[tag.get_text().strip() for tag in soup.select('span.tags a.fiction-tag')] tags=[tag.get_text().strip() for tag in soup.select('span.tags a.fiction-tag')]
) )