From cefcb9ab9607cde2b1aa95cd0d44b3e37378efa5 Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Wed, 2 Jul 2014 19:47:48 -0500 Subject: [PATCH] Apply cover_exclusion_regexp to explicit covers, too. --- fanficdownloader/adapters/base_adapter.py | 3 ++- fanficdownloader/story.py | 8 ++++++-- 2 files changed, 8 insertions(+), 3 deletions(-) diff --git a/fanficdownloader/adapters/base_adapter.py b/fanficdownloader/adapters/base_adapter.py index b3070982..fd75e929 100644 --- a/fanficdownloader/adapters/base_adapter.py +++ b/fanficdownloader/adapters/base_adapter.py @@ -328,7 +328,8 @@ class BaseSiteAdapter(Configurable): def setCoverImage(self,storyurl,imgurl): if self.getConfig('include_images'): - self.story.addImgUrl(storyurl,imgurl,self._fetchUrlRaw,cover=True) + self.story.addImgUrl(storyurl,imgurl,self._fetchUrlRaw,cover=True, + coverexclusion=self.getConfig('cover_exclusion_regexp')) # This gives us a unicode object, not just a string containing bytes. # (I gave soup a unicode string, you'd think it could give it back...) diff --git a/fanficdownloader/story.py b/fanficdownloader/story.py index b45adfbc..6e7c70dc 100644 --- a/fanficdownloader/story.py +++ b/fanficdownloader/story.py @@ -768,6 +768,10 @@ class Story(Configurable): '','','')) #print("\n===========\nparsedUrl.path:%s\ntoppath:%s\nimgurl:%s\n\n"%(parsedUrl.path,toppath,imgurl)) + # apply coverexclusion to explicit covers, too. Primarily for ffnet imageu. + if cover and coverexclusion and re.search(coverexclusion,imgurl): + return + prefix='ffdl' if imgurl not in self.imgurls: parsedUrl = urlparse.urlparse(imgurl) @@ -799,7 +803,7 @@ class Story(Configurable): return "failedtoload" # explicit cover, make the first image. - if cover and not self.getConfig('never_make_cover'): + if cover: if len(self.imgtuples) > 0 and 'cover' in self.imgtuples[0]['newsrc']: # remove existing cover, if there is one. del self.imgurls[0] @@ -818,7 +822,7 @@ class Story(Configurable): if self.cover == None and \ self.getConfig('make_firstimage_cover') and \ not self.getConfig('never_make_cover') and \ - (not coverexclusion or not re.search(coverexclusion,imgurl)): + not (coverexclusion and re.search(coverexclusion,imgurl)): newsrc = "images/cover.%s"%ext self.cover=newsrc self.imgtuples.append({'newsrc':newsrc,'mime':mime,'data':data})