'.format(i['spanImageCrops'][0]['renditions'][0]['url'])
if i.get('caption'):
yield '
' + ''.join(parse_types(i['caption']))
if i.get('credit'):
@@ -23,13 +26,36 @@ def parse_image(i):
def parse_img_grid(g):
for grd in g.get('gridMedia', {}):
- yield ''.join(parse_image(grd))
+ yield '
'.join(parse_image(grd))
if g.get('caption'):
yield '
{}'.format(g['caption'])
if g.get('credit'):
yield ' ' + g['credit'] + ''
yield '
'
+def parse_vid(v):
+ if v.get('promotionalMedia'):
+ if v.get('headline'):
+ if v.get('url'):
+ yield '
Video: '.format(v['url'])\
+ + v['headline'].get('default', '') + ' '
+ elif v['headline'].get('default'):
+ yield '
' + v['headline']['default'] + '
'
+ yield ''.join(parse_types(v['promotionalMedia']))
+ if v.get('promotionalSummary'):
+ yield '
' + v['promotionalSummary'] + '
'
+
+def parse_emb(e):
+ if e.get('html') and 'datawrapper.dwcdn.net' in e['html']:
+ dw = re.search(r'datawrapper.dwcdn.net/(.{5})', e['html']).group(1)
+ yield '

'.format('https://datawrapper.dwcdn.net/' + dw + '/full.png') + '
'
+ elif e.get('promotionalMedia'):
+ if e.get('headline'):
+ yield '
' + e['headline']['default'] + '
'
+ yield ''.join(parse_types(e['promotionalMedia']))
+ if e.get('note'):
+ yield '
' + e['note'] + '
'
+
def parse_byline(byl):
for b in byl.get('bylines', {}):
yield '
' + b['renderedRepresentation'] + '
'
@@ -116,6 +142,16 @@ def parse_types(x):
elif x.get('__typename', '') == 'GridBlock':
yield ''.join(parse_img_grid(x))
+ elif x.get('__typename', '') == 'VideoBlock':
+ yield ''.join(parse_types(x['media']))
+ elif x.get('__typename', '') == 'Video':
+ yield ''.join(parse_vid(x))
+
+ elif x.get('__typename', '') == 'InteractiveBlock':
+ yield ''.join(parse_types(x['media']))
+ elif x.get('__typename', '') == 'EmbeddedInteractive':
+ yield ''.join(parse_emb(x))
+
elif x.get('__typename', '') == 'ListBlock':
yield '
' + ''.join(parse_cnt(x)) + '
'
elif x.get('__typename', '') == 'ListItemBlock':
@@ -181,7 +217,7 @@ class nytFeeds(BasicNewsRecipe):
},
'res': {
'short': 'For hi-res images, select a resolution from the following\noptions: popup, jumbo, mobileMasterAt3x, superJumbo',
- 'long': 'This is useful for non e-ink devices, and for a lower file size\nthan the default(articleLarge), use articleInline.',
+ 'long': 'This is useful for non e-ink devices, and for a lower file size\nthan the default, use articleInline.',
}
}
From bbb62ea6332b393db58205eae3c8065db5169803 Mon Sep 17 00:00:00 2001
From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com>
Date: Sat, 21 Sep 2024 10:52:16 +0530
Subject: [PATCH 2/2] ...
---
recipes/nytfeeds.recipe | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/recipes/nytfeeds.recipe b/recipes/nytfeeds.recipe
index e7e6a8ab31..3fed8877c2 100644
--- a/recipes/nytfeeds.recipe
+++ b/recipes/nytfeeds.recipe
@@ -46,7 +46,7 @@ def parse_vid(v):
yield '
' + v['promotionalSummary'] + '
'
def parse_emb(e):
- if e.get('html') and 'datawrapper.dwcdn.net' in e['html']:
+ if e.get('html') and 'datawrapper.dwcdn.net' in e.get('html', ''):
dw = re.search(r'datawrapper.dwcdn.net/(.{5})', e['html']).group(1)
yield '

'.format('https://datawrapper.dwcdn.net/' + dw + '/full.png') + '
'
elif e.get('promotionalMedia'):