diff --git a/recipes/bloomberg-business-week.recipe b/recipes/bloomberg-business-week.recipe index e9812e7157..5d45e6151d 100644 --- a/recipes/bloomberg-business-week.recipe +++ b/recipes/bloomberg-business-week.recipe @@ -176,14 +176,14 @@ class Bloomberg(BasicNewsRecipe): caption = '' + data['lede']['alt'] + '' if m: - time.sleep(5) + time.sleep(3) body = data['body'] else: body = '' body_data = data['body']['content'] for x in body_data: body += get_contents(x) - pause = random.choice((4, 5, 6, 7, 8, 9)) + pause = random.choice((3, 4, 5, 6)) self.log('Delay: ', pause, ' seconds') time.sleep(pause) return '' + cat + title + subhead + auth + lede + caption + '
' + body + '
' diff --git a/recipes/bloomberg.recipe b/recipes/bloomberg.recipe index b7ee45be05..50fe1033c1 100644 --- a/recipes/bloomberg.recipe +++ b/recipes/bloomberg.recipe @@ -170,14 +170,14 @@ class Bloomberg(BasicNewsRecipe): caption = '' + data['lede']['alt'] + '' if m: - time.sleep(5) + time.sleep(3) body = data['body'] elif m2: body = '' body_data = data['body']['content'] for x in body_data: body += get_contents(x) - pause = random.choice((4, 5, 6, 7, 8, 9)) + pause = random.choice((3, 4, 5, 6)) self.log('Delay: ', pause, ' seconds') time.sleep(pause) return '' + cat + title + subhead + auth + lede + caption + '
' + body + '
' diff --git a/recipes/hindu.recipe b/recipes/hindu.recipe index 35650d11c9..c8a1a75e70 100644 --- a/recipes/hindu.recipe +++ b/recipes/hindu.recipe @@ -30,6 +30,7 @@ if past_edition: class TheHindu(BasicNewsRecipe): title = 'The Hindu' __author__ = 'unkn0wn' + description = 'Articles from The Hindu, Today\'s Paper.' language = 'en_IN' no_stylesheets = True masthead_url = 'https://www.thehindu.com/theme/images/th-online/thehindu-logo.svg' diff --git a/recipes/hindufeeds.recipe b/recipes/hindufeeds.recipe new file mode 100644 index 0000000000..f724d5813d --- /dev/null +++ b/recipes/hindufeeds.recipe @@ -0,0 +1,86 @@ +from calibre.web.feeds.news import BasicNewsRecipe, classes +from datetime import date + +class TheHindufeeds(BasicNewsRecipe): + title = 'The Hindu (Feeds)' + __author__ = 'unkn0wn' + description = 'The Hindu, based on RSS feeds.' + language = 'en_IN' + no_stylesheets = True + masthead_url = 'https://www.thehindu.com/theme/images/th-online/thehindu-logo.svg' + remove_attributes = ['style', 'height', 'width'] + resolve_internal_links = True + remove_empty_feeds = True + max_articles_per_feed = 25 + oldest_article = 1.15 # days + + extra_css = ''' + .caption {font-size:small; text-align:center;} + .author, .dateLine, .publish-time {font-size:small; font-weight:bold;} + .subhead, .subhead_lead, .bold {font-weight:bold;} + img {display:block; margin:0 auto;} + .italic {font-style:italic; color:#202020;} + ''' + + ignore_duplicate_articles = {'url'} + + keep_only_tags = [ + classes('article-section') + ] + + remove_tags = [ + dict(name='button'), + dict(attrs={'target':'_self'}), + classes( + 'hide-mobile comments-shares share-page editiondetails breadcrumb' + ' related-topics related-stories also-read premium-label' + ) + ] + + def preprocess_html(self, soup): + for cap in soup.findAll('p', attrs={'class':'caption'}): + cap.name = 'figcaption' + for img in soup.findAll('img', attrs={'data-original':True}): + if img['data-original'].endswith('1x1_spacer.png'): + source = img.findPrevious('source', srcset=True) + img.extract() + if source: + source['src'] = source['srcset'].replace('_320','_1200') + source.name = 'img' + else: + img['src'] = img['data-original'] + for img in soup.findAll('img', attrs={'data-src-template':True}): + img['src'] = img['data-src-template'] + return soup + + def postprocess_html(self, soup, first_fetch): + for src in soup.findAll('source'): + src.extract() + return soup + + def __init__(self, *args, **kwargs): + BasicNewsRecipe.__init__(self, *args, **kwargs) + if self.output_profile.short_name.startswith('kindle'): + self.title = 'The Hindu (Feeds)' + date.today().strftime('%b %d, %Y') + + + def get_cover_url(self): + soup = self.index_to_soup('https://www.thehindu.com/todays-paper/') + if cover := soup.find(attrs={'class':'hindu-ad'}): + return cover.img['src'] + + # https://www.thehindu.com/rssfeeds/ + feeds = [ + ('India', 'https://www.thehindu.com/news/national/feeder/default.rss'), + ('States', 'https://www.thehindu.com/news/states/feeder/default.rss'), + # ('Cities', 'https://www.thehindu.com/news/cities/feeder/default.rss'), + ('Opinion', 'https://www.thehindu.com/opinion/feeder/default.rss'), + ('Business', 'https://www.thehindu.com/business/feeder/default.rss'), + ('World', 'https://www.thehindu.com/news/international/feeder/default.rss'), + # ('Sport', 'https://www.thehindu.com/sport/feeder/default.rss'), + ('Entertainment', 'https://www.thehindu.com/entertainment/feeder/default.rss'), + # ('Crossword', 'https://crossword.thehindu.com/?utm_source=thehindu&utm_medium=mainmenufeeder/default.rss'), + ('Science', 'https://www.thehindu.com/sci-tech/science/feeder/default.rss'), + ('Life and Style', 'https://www.thehindu.com/life-and-style/feeder/default.rss'), + ('thRead', 'https://www.thehindu.com/thread/feeder/default.rss') + ] diff --git a/recipes/icons/hindufeeds.png b/recipes/icons/hindufeeds.png new file mode 100644 index 0000000000..07c4828a31 Binary files /dev/null and b/recipes/icons/hindufeeds.png differ diff --git a/recipes/livemint.recipe b/recipes/livemint.recipe index 3418fc249a..3831728eb4 100644 --- a/recipes/livemint.recipe +++ b/recipes/livemint.recipe @@ -81,7 +81,7 @@ class LiveMint(BasicNewsRecipe): extra_css = ''' img {display:block; margin:0 auto;} #img-cap {font-size:small; text-align:center;} - .summary, .highlights { + .summary, .highlights, .synopsis { font-weight:normal !important; font-style:italic; color:#202020; } h2 {font-size:normal !important;}