mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update natgeomag.recipe
This commit is contained in:
parent
e9fa788d8f
commit
6a88069f01
@ -23,8 +23,10 @@ def classes(classes):
|
||||
def extract_json(raw):
|
||||
s = raw.find("window['__natgeo__']")
|
||||
script = raw[s:raw.find('</script>', s)]
|
||||
return json.loads(
|
||||
script[script.find('{'):].rstrip(';'))['page']['content']['article']
|
||||
data = json.loads(script[script.find('{'):].rstrip(';'))['page']['content']
|
||||
if 'article' in data:
|
||||
return data['article']
|
||||
return data['prismarticle']
|
||||
|
||||
|
||||
def parse_contributors(grp):
|
||||
@ -36,16 +38,17 @@ def parse_contributors(grp):
|
||||
|
||||
|
||||
def parse_lead_image(media):
|
||||
if 'dsc' in media['image']:
|
||||
yield '<p><div><img src="{}" alt="{}"></div>'.format(
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
||||
else:
|
||||
yield '<p><div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||
if 'caption' in media:
|
||||
yield '<div class="cap">' + media['caption'] + '</div>'
|
||||
if 'credit' in media:
|
||||
yield '<div class="cred">' + media['credit'] + '</div>'
|
||||
yield '</p>'
|
||||
if 'image' in media:
|
||||
if 'dsc' in media['image']:
|
||||
yield '<p><div><img src="{}" alt="{}"></div>'.format(
|
||||
escape(media['image']['src'], True), escape(media['image']['dsc'], True))
|
||||
else:
|
||||
yield '<p><div><img src="{}"></div>'.format(escape(media['image']['src'], True))
|
||||
if 'caption' in media:
|
||||
yield '<div class="cap">' + media['caption'] + '</div>'
|
||||
if 'credit' in media:
|
||||
yield '<div class="cred">' + media['credit'] + '</div>'
|
||||
yield '</p>'
|
||||
|
||||
|
||||
def parse_body(item):
|
||||
|
Loading…
x
Reference in New Issue
Block a user