fix list index out of range error

- fixes "Failed List Index Out of Range" on url
"http://royalroadl.com/fiction/1612"
This commit is contained in:
wassname 2016-10-26 14:22:10 +08:00
parent eade66f513
commit 5ca33837d4

View file

@ -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'])