From 29589a0886fc764c2aded2d38c89f0797d668d02 Mon Sep 17 00:00:00 2001 From: David Lynch Date: Tue, 22 Feb 2022 12:19:58 -0600 Subject: [PATCH] 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 --- sites/royalroad.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sites/royalroad.py b/sites/royalroad.py index 465fbfc..9cf0bd2 100644 --- a/sites/royalroad.py +++ b/sites/royalroad.py @@ -37,6 +37,8 @@ class RoyalRoad(Site): soup = self._soup(f'https://www.{self.domain}.com/fiction/{workid}') # 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 http.client._MAXHEADERS = 1000 @@ -44,7 +46,7 @@ class RoyalRoad(Site): title=soup.find('h1', property='name').string.strip(), author=soup.find('meta', property='books:author').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(), tags=[tag.get_text().strip() for tag in soup.select('span.tags a.fiction-tag')] )