From 0f77c2428b70a4d58d8df706b0e41f3a5c21dd27 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Fri, 14 Sep 2012 17:43:48 -0500 Subject: [PATCH] Added cover images for dramione.org, thanks ilovejedd. --- fanficdownloader/adapters/adapter_dramioneorg.py | 16 ++++++++++++++++ 1 file changed, 16 insertions(+) diff --git a/fanficdownloader/adapters/adapter_dramioneorg.py b/fanficdownloader/adapters/adapter_dramioneorg.py index e296ae0c..ef05e993 100644 --- a/fanficdownloader/adapters/adapter_dramioneorg.py +++ b/fanficdownloader/adapters/adapter_dramioneorg.py @@ -160,6 +160,22 @@ class DramioneOrgAdapter(BaseSiteAdapter): self.story.setMetadata('authorUrl','http://'+self.host+'/'+a['href']) self.story.setMetadata('author',a.string) + # Use banner as cover if found + if self.getConfig('include_images'): + coverurl = '' + img = soup.find('img',{'class':'banner'}) + if img: + coverurl = img['src'] + #print "Cover: "+coverurl + a = soup.find(text="This story has a banner; click to view.") + if a: + #print "A: "+ ', '.join("(%s, %s)" %tup for tup in a.parent.attrs) + coverurl = a.parent['href'] + #print "Cover: "+coverurl + if coverurl: + self.story.addImgUrl(self,url,coverurl,self._fetchUrlRaw,cover=True) + + # Find the chapters: for chapter in soup.findAll('a', href=re.compile(r'viewstory.php\?sid='+self.story.getMetadata('storyId')+"&chapter=\d+$")): # just in case there's tags, like in chapter titles.