mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Nat Geo
add options for hi-res images
This commit is contained in:
parent
3d092909d6
commit
62173e30f1
@ -163,6 +163,14 @@ class NatGeo(BasicNewsRecipe):
|
|||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
|
|
||||||
|
recipe_specific_options = {
|
||||||
|
'res': {
|
||||||
|
'short': 'For hi-res images, select a resolution from the\nfollowing options: 800, 1000, 1200 or 1500',
|
||||||
|
'long': 'This is useful for non e-ink devices, and for a lower file size\nthan the default, use 400 or 300.',
|
||||||
|
'default': '600'
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
blockquote { color:#404040; }
|
blockquote { color:#404040; }
|
||||||
.byline, i { font-style:italic; color:#202020; }
|
.byline, i { font-style:italic; color:#202020; }
|
||||||
@ -223,8 +231,11 @@ class NatGeo(BasicNewsRecipe):
|
|||||||
for h2 in soup.findAll('h2'):
|
for h2 in soup.findAll('h2'):
|
||||||
h2.name = 'h4'
|
h2.name = 'h4'
|
||||||
for img in soup.findAll('img', src=True):
|
for img in soup.findAll('img', src=True):
|
||||||
# for high res images use '?w=2000&h=2000'
|
res = '?w=600'
|
||||||
img['src'] = img['src'] + '?w=600&h=600'
|
w = self.recipe_specific_options.get('res')
|
||||||
|
if w and isinstance(w, str):
|
||||||
|
res = '?w=' + w
|
||||||
|
img['src'] = img['src'] + res
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def populate_article_metadata(self, article, soup, first):
|
def populate_article_metadata(self, article, soup, first):
|
||||||
|
@ -176,6 +176,11 @@ class NatGeo(BasicNewsRecipe):
|
|||||||
'date': {
|
'date': {
|
||||||
'short': 'The date of the edition to download (Month-YYYY format)',
|
'short': 'The date of the edition to download (Month-YYYY format)',
|
||||||
'long': 'For example, March-2023'
|
'long': 'For example, March-2023'
|
||||||
|
},
|
||||||
|
'res': {
|
||||||
|
'short': 'For hi-res images, select a resolution from the\nfollowing options: 800, 1000, 1200 or 1500',
|
||||||
|
'long': 'This is useful for non e-ink devices, and for a lower file size\nthan the default, use 400 or 300.',
|
||||||
|
'default': '600'
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -231,8 +236,11 @@ class NatGeo(BasicNewsRecipe):
|
|||||||
for h2 in soup.findAll('h2'):
|
for h2 in soup.findAll('h2'):
|
||||||
h2.name = 'h4'
|
h2.name = 'h4'
|
||||||
for img in soup.findAll('img', src=True):
|
for img in soup.findAll('img', src=True):
|
||||||
# for high res images use '?w=2000&h=2000'
|
res = '?w=600'
|
||||||
img['src'] = img['src'] + '?w=600&h=600'
|
w = self.recipe_specific_options.get('res')
|
||||||
|
if w and isinstance(w, str):
|
||||||
|
res = '?w=' + w
|
||||||
|
img['src'] = img['src'] + res
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def populate_article_metadata(self, article, soup, first):
|
def populate_article_metadata(self, article, soup, first):
|
||||||
|
Loading…
x
Reference in New Issue
Block a user