From 23b76d2aace3b64487c4715cbc2371c5eb7b80f4 Mon Sep 17 00:00:00 2001 From: random human Date: Thu, 30 Aug 2018 03:50:28 +0530 Subject: [PATCH] Fix royalroadl.com chapter dates Since the timestamp provided with the chapter list is approximate, fetch the actual chapter in order to get unixtime. --- sites/royalroad.py | 4 +++- 1 file changed, 3 insertions(+), 1 deletion(-) diff --git a/sites/royalroad.py b/sites/royalroad.py index cb63dc2..5cd3d99 100644 --- a/sites/royalroad.py +++ b/sites/royalroad.py @@ -37,8 +37,10 @@ class RoyalRoad(Site): for chapter in soup.select('#chapters tbody tr[data-url]'): chapter_url = str(urllib.parse.urljoin(story.url, str(chapter.get('data-url')))) + # Have to get exact publishing time from the chapter page + chapter_soup = self._soup(chapter_url) updated = datetime.datetime.fromtimestamp( - int(chapter.find('time').get('unixtime')), + int(chapter_soup.find(class_="profile-info").find('time').get('unixtime')), ) story.add(Chapter(title=chapter.find('a', href=True).string.strip(), contents=self._chapter(chapter_url), date=updated))