From 53a041538af30f6a8fcdd5632cda237db87f2397 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 11 Jun 2012 12:32:38 -0500 Subject: [PATCH] Allow 'Anonymous' author on www.archiveofourown.org. --- calibre-plugin/__init__.py | 2 +- .../adapters/adapter_archiveofourownorg.py | 10 +++++++--- 2 files changed, 8 insertions(+), 4 deletions(-) diff --git a/calibre-plugin/__init__.py b/calibre-plugin/__init__.py index c24e227..adb1f03 100644 --- a/calibre-plugin/__init__.py +++ b/calibre-plugin/__init__.py @@ -27,7 +27,7 @@ class FanFictionDownLoaderBase(InterfaceActionBase): description = 'UI plugin to download FanFiction stories from various sites.' supported_platforms = ['windows', 'osx', 'linux'] author = 'Jim Miller' - version = (1, 5, 31) + version = (1, 5, 32) minimum_calibre_version = (0, 8, 30) #: This field defines the GUI plugin class that contains all the code diff --git a/fanficdownloader/adapters/adapter_archiveofourownorg.py b/fanficdownloader/adapters/adapter_archiveofourownorg.py index feda891..958a1b1 100644 --- a/fanficdownloader/adapters/adapter_archiveofourownorg.py +++ b/fanficdownloader/adapters/adapter_archiveofourownorg.py @@ -106,9 +106,13 @@ class ArchiveOfOurOwnOrgAdapter(BaseSiteAdapter): # Find authorid and URL from... author url. a = soup.find('a', href=re.compile(r"^/users/\w+/pseuds/\w+")) - self.story.setMetadata('authorId',a['href'].split('/')[2]) - self.story.setMetadata('authorUrl','http://'+self.host+a['href']) - self.story.setMetadata('author',a.text) + if a == None: # ao3 allows for author 'Anonymous' with no author link. + self.story.setMetadata('author','Anonymous') + self.story.setMetadata('authorUrl',self.url) + else: + self.story.setMetadata('authorId',a['href'].split('/')[2]) + self.story.setMetadata('authorUrl','http://'+self.host+a['href']) + self.story.setMetadata('author',a.text) # Find the chapters: chapters=soup.findAll('a', href=re.compile(r'/works/'+self.story.getMetadata('storyId')+"/chapters/\d+$"))