Update scmp.recipe

This commit is contained in:
unkn0w7n 2024-09-09 10:36:00 +05:30
parent abe8c8b2a8
commit 2bfa86c16d

View File

@ -47,9 +47,6 @@ def ts_date(x):
dt = datetime.fromtimestamp(x/1000 + time.timezone) dt = datetime.fromtimestamp(x/1000 + time.timezone)
return dt.strftime('%b %d, %Y at %I:%M %p') return dt.strftime('%b %d, %Y at %I:%M %p')
def auth(x):
return ', '.join([a['name'] for a in x])
def load_article_from_json(raw, root): def load_article_from_json(raw, root):
# open('/t/raw.json', 'w').write(raw) # open('/t/raw.json', 'w').write(raw)
data = json.loads(raw)['props']['pageProps']['payload']['data']['article'] data = json.loads(raw)['props']['pageProps']['payload']['data']['article']
@ -62,7 +59,8 @@ def load_article_from_json(raw, root):
# E(article, 'p', replace_entities(data['subHeadline']['text']), style='font-style: italic; color:#202020;') # E(article, 'p', replace_entities(data['subHeadline']['text']), style='font-style: italic; color:#202020;')
for subh in data['subHeadline']['json']: for subh in data['subHeadline']['json']:
process_node(subh, article) process_node(subh, article)
auth = ts_date(data['publishedDate']) + ' | ' + data['readingTime'] or '' + ' min read | ' + auth(data['authors']) auth = ts_date(data['publishedDate']) + ' | ' + str(data.get('readingTime', '')) + ' min read | ' \
+ ', '.join([a['name'] for a in data['authors']])
E(article, 'p', auth, style='color: #202020; font-size:small;') E(article, 'p', auth, style='color: #202020; font-size:small;')
main_image_url = sub_img = '' main_image_url = sub_img = ''
for l in data['images']: for l in data['images']: