Update wsj.recipe

This commit is contained in:
unkn0w7n 2024-08-06 09:10:23 +05:30
parent 5031269baf
commit a954ae08af

View File

@ -140,20 +140,18 @@ class WSJ(BasicNewsRecipe):
def parse_index(self): def parse_index(self):
index = 'https://bartender.mobile.dowjones.io' index = 'https://bartender.mobile.dowjones.io'
catalog = json.loads(self.index_to_soup(index + '/catalogs/v1/wsj/us/catalog.json', raw=True)) catalog = json.loads(self.index_to_soup(index + '/catalogs/v1/wsj/us/catalog.json', raw=True))
edit = [''.join([n for n in itm['key'] if n.isdigit()]) for itm in catalog['items'] if itm['type'] == 'ITPNEXTGEN'][1:] edit = [''.join([n for n in itm['key'] if n.isdigit()]) for itm in catalog['items'] if itm['type'] == 'ITP'][1:]
self.log('**Past Editions available :', ', '.join(edit)) self.log('**Past Editions available :', ', '.join(edit))
past_edition = self.recipe_specific_options.get('date') past_edition = self.recipe_specific_options.get('date')
for itm in catalog['items']: for itm in catalog['items']:
if past_edition and isinstance(past_edition, str): if past_edition and isinstance(past_edition, str):
if itm['key'] == 'ITPNEXTGEN' + past_edition: if past_edition in itm['key']:
key = itm['key']
manifest = itm['manifest'] manifest = itm['manifest']
date = itm['date'] date = itm['date']
break break
elif itm['type'] == 'ITPNEXTGEN': elif itm['type'] == 'ITP':
key = itm['key']
manifest = itm['manifest'] manifest = itm['manifest']
date = itm['date'] date = itm['date']
break break
@ -183,7 +181,7 @@ class WSJ(BasicNewsRecipe):
for art in data: for art in data:
title = data[art]['headline'] title = data[art]['headline']
desc = data[art]['summary'] desc = data[art]['summary']
url = index + '/contents/v1/wsj/us/' + key + '/' + data[art]['filename'] url = index + manifest.rsplit('/', 1)[0] + '/' + data[art]['filename']
self.log(' ', title, '\n\t', desc) self.log(' ', title, '\n\t', desc)
articles.append({'title': title, 'description':desc, 'url': url}) articles.append({'title': title, 'description':desc, 'url': url})
feeds.append((section, articles)) feeds.append((section, articles))