diff --git a/recipes/hindu.recipe b/recipes/hindu.recipe index 616e123cdd..cb285f743b 100644 --- a/recipes/hindu.recipe +++ b/recipes/hindu.recipe @@ -60,10 +60,13 @@ class TheHindu(BasicNewsRecipe): return soup def parse_index(self): - mag_url = None + local_edition = self.recipe_specific_options.get('location') if local_edition: local_edition = 'th_' + local_edition + else: + local_edition = 'th_international' + past_edition = self.recipe_specific_options.get('date') dt = date.today() @@ -71,36 +74,20 @@ class TheHindu(BasicNewsRecipe): year, month, day = (int(x) for x in past_edition.split('-')) dt = date(year, month, day) - is_monday = dt.weekday() == 0 - is_friday = dt.weekday() == 4 - is_saturday = dt.weekday() == 5 - is_sunday = dt.weekday() == 6 + today = dt.strftime('%Y-%m-%d') + self.log('Downloading The Hindu, ' + local_edition[3:] + ' edition, ' + today) + url = absurl('/todays-paper/' + today + '/' + local_edition + '/') - if local_edition or past_edition: - if local_edition is None: - local_edition = 'th_chennai' - 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 + '/') - if is_monday: - mag_url = url + '?supplement=' + local_edition + '-epbs' - if is_saturday: - mag_url = url + '?supplement=' + local_edition + '-mp' - if is_sunday: - mag_url = url + '?supplement=' + local_edition + '-sm' - else: - url = 'https://www.thehindu.com/todays-paper/' - if is_monday: - mag_url = url + '?supplement=th_chennai-epbs' - if is_friday: - mag_url = url + '?supplement=th_chennai-fr' - if is_saturday: - mag_url = url + '?supplement=th_chennai-mp' - if is_sunday: - mag_url = url + '?supplement=th_chennai-sm' + mag_url = None + if dt.weekday() == 0: + mag_url = url + '?supplement=' + local_edition + '-epbs' + if dt.weekday() == 4: + mag_url = url + '?supplement=' + local_edition + '-fr' + if dt.weekday() == 5: + mag_url = url + '?supplement=' + local_edition + '-mp' + if dt.weekday() == 6: + mag_url = url + '?supplement=' + local_edition + '-sm' raw = self.index_to_soup(url, raw=True) soup = self.index_to_soup(raw) @@ -139,7 +126,7 @@ class TheHindu(BasicNewsRecipe): title = item['articleheadline'] url = absurl(item['href']) desc = 'Page no.' + item['pageno'] + ' | ' + item['teaser_text'] or '' - self.log('\t', title, '\n\t\t', url) + self.log(' ', title, '\n\t', url) feeds_dict[section].append({"title": title, "url": url, "description": desc}) return [(section, articles) for section, articles in feeds_dict.items()] else: