mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 02:34:06 -04:00
cover update2
This commit is contained in:
parent
93aed4db7a
commit
9b34bf899d
@ -7,7 +7,7 @@
|
||||
# been added through custom entries in the function my_parse_index.
|
||||
# 3) Fix the cover image so it doesnt disappear from the Kindle menu
|
||||
# ( cover image format is changed to .jpeg)
|
||||
#
|
||||
# 14 Jan 2021 - Add Mediapart Logo url as masthead_url
|
||||
from __future__ import unicode_literals
|
||||
|
||||
__license__ = 'GPL v3'
|
||||
@ -18,6 +18,7 @@ Mediapart
|
||||
|
||||
import re
|
||||
from datetime import date, datetime, timedelta
|
||||
from time import strftime
|
||||
|
||||
from calibre.web.feeds import feeds_from_index
|
||||
from calibre.web.feeds.news import BasicNewsRecipe
|
||||
@ -50,6 +51,7 @@ class Mediapart(BasicNewsRecipe):
|
||||
remove_tags = [classes('login-subscribe print-source_url')]
|
||||
conversion_options = {'smarten_punctuation': True}
|
||||
|
||||
masthead_url = "https://raw.githubusercontent.com/lhoupert/calibre_contrib/main/mediapart_masthead.png"
|
||||
cover_url = 'https://raw.githubusercontent.com/lhoupert/calibre_contrib/main/mediapart.jpeg'
|
||||
|
||||
# --
|
||||
@ -240,3 +242,22 @@ class Mediapart(BasicNewsRecipe):
|
||||
br['password'] = self.password
|
||||
br.submit()
|
||||
return br
|
||||
|
||||
def default_cover(self, cover_file):
|
||||
"""
|
||||
Create a generic cover for recipes that don't have a cover
|
||||
This override adds time to the cover
|
||||
"""
|
||||
try:
|
||||
from calibre.ebooks import calibre_cover
|
||||
title = self.title if isinstance(self.title, unicode) else \
|
||||
self.title.decode('utf-8', 'replace')
|
||||
date = strftime(self.timefmt)
|
||||
time = strftime('%a %d %b %Y %-H:%M')
|
||||
img_data = calibre_cover(title, date, time)
|
||||
cover_file.write(img_data)
|
||||
cover_file.flush()
|
||||
print(f'title: {title}\ndate: {date}\ntime: {time}')
|
||||
except:
|
||||
self.log.exception('Failed to generate default cover')
|
||||
return False
|
||||
|
Loading…
x
Reference in New Issue
Block a user