Skip to content

Commit

Permalink
Don't save cover image size for dedup_img_files - Calibre might repla…
Browse files Browse the repository at this point in the history
…ce it. Also fixes #561
  • Loading branch information
JimmXinu committed Sep 30, 2020
1 parent 8cb0b88 commit 76e9861
Showing 1 changed file with 8 additions and 2 deletions.
10 changes: 8 additions & 2 deletions fanficfare/story.py
Original file line number Diff line number Diff line change
Expand Up @@ -1284,15 +1284,18 @@ def addImgUrl(self,parenturl,url,fetch,cover=False,coverexclusion=None):
if cover and cover_big_enough:
if len(self.imgtuples) > 0 and 'cover' in self.imgtuples[0]['newsrc']:
# remove existing cover, if there is one.
self.imgsizes[len(self.imgtuples[0]['data'])].remove(0)
# could have only come from first image and is assumed index 0.
del self.imgurls[0]
del self.imgtuples[0]
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})
self.imgsizes[len(data)].append(0)
## *Don't* include cover in imgsizes because it can be
## replaced by Calibre etc. So don't re-use it.
## Also saves removing it above.
# self.imgsizes[len(data)].append(0)
else:
if self.getConfig('dedup_img_files',False):
same_sz_imgs = self.imgsizes[len(data)]
Expand All @@ -1319,6 +1322,9 @@ def addImgUrl(self,parenturl,url,fetch,cover=False,coverexclusion=None):
self.setMetadata('cover_image','first')
self.imgtuples.append({'newsrc':newsrc,'mime':mime,'data':data})
self.imgurls.append(imgurl)
## *Don't* include cover in imgsizes because it can be
## replaced by Calibre etc. So don't re-use it.
# self.imgsizes[len(data)].append(len(self.imgtuples)-1)

newsrc = "images/%s-%s.%s"%(
prefix,
Expand Down

0 comments on commit 76e9861

Please sign in to comment.