This commit is contained in:
Kovid Goyal 2025-04-06 20:07:00 +05:30
commit 9f9e3478ee
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 13 additions and 8 deletions

View File

@ -5,6 +5,7 @@ import base64
import json
import re
from collections import defaultdict
from calibre.web.feeds.news import BasicNewsRecipe
@ -102,8 +103,6 @@ class Barrons(BasicNewsRecipe):
raw=True,
)
feeds = []
scrn = json.loads(archive)['screens'][0]['frames']
self.log(
'Available Editions: ',
@ -123,20 +122,25 @@ class Barrons(BasicNewsRecipe):
self.timefmt = ' [' + nme[6:] + ']'
break
feeds_dict = defaultdict(list)
data = json.loads(self.index_to_soup(index + bseurl, raw=True))
for x in data['screens'][0]['frames']:
if x['type'] != 'article':
continue
url = index + theatre + cid + '?screen_ids=' + x['articleId']
title = x['title']['text']
section = 'Articles'
if x.get('label'):
section = x['label'].get('text', 'Articles').split('|')[0].strip()
desc = ''
if x.get('summary'):
desc = x['summary']['text']
if x.get('byline'):
desc = x['byline']['text'] + ' | ' + desc
self.log(' ', title, '\n\t', desc)
feeds.append({'title': title, 'description': desc, 'url': url})
return [('Articles', feeds)]
feeds_dict[section].append({'title': title, 'url': url, 'description': desc})
return list(feeds_dict.items())
def preprocess_raw_html(self, raw, url):
rdata = json.loads(raw)

View File

@ -3,7 +3,7 @@
import json
import re
from collections import defaultdict
from datetime import date
from datetime import date, timedelta
from calibre.web.feeds.news import BasicNewsRecipe, classes
@ -15,9 +15,9 @@ def absurl(url):
class TheHindu(BasicNewsRecipe):
title = 'The Hindu'
title = 'The Hindu Print Edition'
__author__ = 'unkn0wn'
description = "Articles from The Hindu, Today's Paper."
description = "Articles from The Hindu, Today\'s Paper. This recipe now works only for yesterday\'s edition."
language = 'en_IN'
no_stylesheets = True
masthead_url = 'https://www.thehindu.com/theme/images/th-online/thehindu-logo.svg'
@ -68,6 +68,7 @@ class TheHindu(BasicNewsRecipe):
return soup
def parse_index(self):
self.title = 'The Hindu'
local_edition = 'th_chennai'
d = self.recipe_specific_options.get('location')
if d and isinstance(d, str):
@ -75,7 +76,7 @@ class TheHindu(BasicNewsRecipe):
past_edition = self.recipe_specific_options.get('date')
dt = date.today()
dt = date.today() - timedelta(days=1)
if past_edition and isinstance(past_edition, str):
year, month, day = (int(x) for x in past_edition.split('-'))
dt = date(year, month, day)