From 48e1bc7aa48a661c8fae9973153af78363c53bba Mon Sep 17 00:00:00 2001 From: Jim Miller Date: Mon, 20 Apr 2015 20:32:34 -0500 Subject: [PATCH] Add cover_image meta-metadata for source of cover image: specific, first, old or default. --- fanficfare/adapters/base_adapter.py | 2 ++ fanficfare/configurable.py | 1 + fanficfare/story.py | 2 ++ 3 files changed, 5 insertions(+) diff --git a/fanficfare/adapters/base_adapter.py b/fanficfare/adapters/base_adapter.py index e7ae20b..0b6fe23 100644 --- a/fanficfare/adapters/base_adapter.py +++ b/fanficfare/adapters/base_adapter.py @@ -379,10 +379,12 @@ class BaseSiteAdapter(Configurable): self.getConfig('allow_unsafe_filename')), self._fetchUrlRaw, cover=True) + self.story.setMetadata('cover_image','default') # no new cover, set old cover, if there is one. if not self.story.cover and self.oldcover: self.story.oldcover = self.oldcover + self.story.setMetadata('cover_image','old') # cheesy way to carry calibre bookmark file forward across update. if self.calibrebookmark: diff --git a/fanficfare/configurable.py b/fanficfare/configurable.py index d0bb323..6cb9646 100644 --- a/fanficfare/configurable.py +++ b/fanficfare/configurable.py @@ -159,6 +159,7 @@ def get_valid_scalar_entries(): 'seriesHTML', 'langcode', 'output_css', + 'cover_image', ]) def get_valid_entries(): diff --git a/fanficfare/story.py b/fanficfare/story.py index 9d78fd8..5d4853d 100644 --- a/fanficfare/story.py +++ b/fanficfare/story.py @@ -874,6 +874,7 @@ class Story(Configurable): self.imgurls.insert(0,imgurl) newsrc = "images/cover.%s"%ext self.cover=newsrc + self.setMetadata('cover_image','specific') self.imgtuples.insert(0,{'newsrc':newsrc,'mime':mime,'data':data}) else: self.imgurls.append(imgurl) @@ -888,6 +889,7 @@ class Story(Configurable): not (coverexclusion and re.search(coverexclusion,imgurl)): newsrc = "images/cover.%s"%ext self.cover=newsrc + self.setMetadata('cover_image','first') self.imgtuples.append({'newsrc':newsrc,'mime':mime,'data':data}) self.imgurls.append(imgurl)