From 5ca33837d4c06a1ddf509e5f180f5090d2d91a46 Mon Sep 17 00:00:00 2001 From: wassname Date: Wed, 26 Oct 2016 14:22:10 +0800 Subject: [PATCH] fix list index out of range error - fixes "Failed List Index Out of Range" on url "http://royalroadl.com/fiction/1612" --- fanficfare/adapters/adapter_royalroadl.py | 8 +++++--- 1 file changed, 5 insertions(+), 3 deletions(-) diff --git a/fanficfare/adapters/adapter_royalroadl.py b/fanficfare/adapters/adapter_royalroadl.py index 7b36d2d2..0b28e34a 100644 --- a/fanficfare/adapters/adapter_royalroadl.py +++ b/fanficfare/adapters/adapter_royalroadl.py @@ -115,9 +115,11 @@ class RoyalRoadAdapter(BaseSiteAdapter): # Find authorid and URL from... author url. author = soup.find('',{'class':'mt-card-social'}) - authorId = author.findAll('li')[1].a['href'].split('=')[-1] - self.story.setMetadata('authorId',authorId) - self.story.setMetadata('authorUrl','http://'+self.host+'/member.php?action=profile&uid='+authorId) + author_link = author.findAll('li')[-1] + if author_link: + authorId = author_link.a['href'].split('=')[-1] + self.story.setMetadata('authorId', authorId) + self.story.setMetadata('authorUrl','http://'+self.host+'/member.php?action=profile&uid='+authorId) self.story.setMetadata('author',soup.find(attrs=dict(property="books:author"))['content'])