diff --git a/recipes/hindu.recipe b/recipes/hindu.recipe index 442d6dba2b..c5e0c07801 100644 --- a/recipes/hindu.recipe +++ b/recipes/hindu.recipe @@ -1,7 +1,7 @@ import json import re from collections import defaultdict -from datetime import datetime +from datetime import date from calibre.web.feeds.news import BasicNewsRecipe, classes @@ -26,9 +26,10 @@ class TheHindu(BasicNewsRecipe): extra_css = ''' .caption {font-size:small; text-align:center;} - .author {font-size:small; font-weight:bold;} + .author, .dateLine {font-size:small; font-weight:bold;} .subhead, .subhead_lead {font-weight:bold;} img {display:block; margin:0 auto;} + .italic {font-style:italic; color:#202020;} ''' ignore_duplicate_articles = {'url'} @@ -52,20 +53,22 @@ class TheHindu(BasicNewsRecipe): BasicNewsRecipe.__init__(self, *args, **kwargs) if self.output_profile.short_name.startswith('kindle'): if not past_edition: - self.title = 'The Hindu ' + datetime.today().strftime('%b %d, %Y') + self.title = 'The Hindu ' + date.today().strftime('%b %d, %Y') def parse_index(self): + global local_edition if local_edition or past_edition: if local_edition is None: local_edition = 'th_chennai' - today = datetime.today().strftime('%Y-%m-%d') + today = date.today().strftime('%Y-%m-%d') if past_edition: today = past_edition self.log('Downloading past edition of', local_edition + ' from ' + today) url = absurl('/todays-paper/' + today + '/' + local_edition + '/') else: url = 'https://www.thehindu.com/todays-paper/' + raw = self.index_to_soup(url, raw=True) soup = self.index_to_soup(raw) ans = self.hindu_parse_index(soup) @@ -83,8 +86,8 @@ class TheHindu(BasicNewsRecipe): if not self.tag_to_string(script).strip().startswith('let grouped_articles = {}'): continue if script is not None: - art = re.search(r'grouped_articles = ({\"[^<]+?]})', self.tag_to_string(script)) - data = json.loads(art.group(1)) + art = re.search(r'grouped_articles = ({\".*)', self.tag_to_string(script)) + data = json.JSONDecoder().raw_decode(art.group(1))[0] feeds_dict = defaultdict(list)