From 3748d47fafdfeeb3af23bc80068f060f3747e990 Mon Sep 17 00:00:00 2001 From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com> Date: Wed, 11 Oct 2023 21:37:59 +0530 Subject: [PATCH] Scroll.in recipe --- recipes/icons/scroll.png | Bin 0 -> 298 bytes recipes/scroll.recipe | 63 +++++++++++++++++++++++++++++++++++++++ recipes/wash_post.recipe | 2 +- 3 files changed, 64 insertions(+), 1 deletion(-) create mode 100644 recipes/icons/scroll.png create mode 100644 recipes/scroll.recipe diff --git a/recipes/icons/scroll.png b/recipes/icons/scroll.png new file mode 100644 index 0000000000000000000000000000000000000000..ceabdfe3383acce39bec9e2b8a253dc80a029c3b GIT binary patch literal 298 zcmV+_0oDGAP)o@aog7Zg&6x z0DnnDK~xx(eUHlygD?yPvrdBTkPx60`lRju|70r#iHJkzU}^TSwvG9RJ-CL})gDuq z`zp}^&3M`aJK@Y+-230)0dpy}vRqn25lM>AxZ>trkFAjJ`SA?YWC)dDP2$MEFmh@4 wZv<88K9RP4yyP`u)%|X#VG<@&LC3FZz9+W?dGWzpQ2+n{07*qoM6N<$f)wPEi~s-t literal 0 HcmV?d00001 diff --git a/recipes/scroll.recipe b/recipes/scroll.recipe new file mode 100644 index 0000000000..4989a74806 --- /dev/null +++ b/recipes/scroll.recipe @@ -0,0 +1,63 @@ +from calibre.web.feeds.news import BasicNewsRecipe, classes +from calibre.ptempfile import PersistentTemporaryFile + +class scroll(BasicNewsRecipe): + title = 'Scroll.in' + __author__ = 'unkn0wn' + description = ( + 'The leading destination for original reporting on news, politics, and culture in India. ' + 'Our award-winning team of journalists brings readers insightful analysis and opinion on the day’s ' + 'headlines alongside a fresh mix of features on music, books, and cinema.' + ) + language = 'en_IN' + masthead_url = 'https://scroll.in/static/assets/scroll-logo.0f68c78dd023e2598248ea107feba562.003.svg' + + no_stylesheets = True + remove_javascript = True + + ignore_duplicate_articles = {'title', 'url'} + remove_attributes = ['style', 'height', 'width'] + + articles_are_obfuscated = True + + def get_obfuscated_article(self, url): + br = self.get_browser() + try: + br.open(url) + except Exception as e: + url = e.hdrs.get('location') + soup = self.index_to_soup(url) + link = soup.find('a', href=True) + skip_sections =[ # add sections you want to skip + '/video/', '/videos/', '/announcements/' + ] + if any(x in link['href'] for x in skip_sections): + self.log('Aborting Article ', link['href']) + self.abort_article('skipping video links') + + self.log('Downloading ', link['href']) + html = br.open(link['href']).read() + pt = PersistentTemporaryFile('.html') + pt.write(html) + pt.close() + return pt.name + + extra_css = ''' + .orange-tag, .article-meta-container { font-size:small; } + .featured-image, .cms-block-image { text-align:center; font-size:small; } + ''' + + keep_only_tags = [ + dict(name = 'header'), + classes('featured-image article-body') + ] + + remove_tags = [classes('comments-entry-point-meta')] + + feeds = [('Articles', 'https://news.google.com/rss/search?q=when:27h+allinurl:https%3A%2F%2Fscroll.in&hl=en-IN&gl=IN&ceid=IN:en')] + + def populate_article_metadata(self, article, soup, first): + # article.url = '' + article.summary = self.tag_to_string(soup.find('h2')) + article.text_summary = self.tag_to_string(soup.find('h2')) + article.title = article.title.replace(' - Scroll.in', '') diff --git a/recipes/wash_post.recipe b/recipes/wash_post.recipe index 1e275ebc1c..8e9e980633 100644 --- a/recipes/wash_post.recipe +++ b/recipes/wash_post.recipe @@ -15,7 +15,7 @@ class TheWashingtonPost(BasicNewsRecipe): description = 'Leading source for news, video and opinion on politics, business, world and national news, science, travel, entertainment and more. Our local coverage includes reporting on education, crime, weather, traffic, real estate, jobs and cars for DC, Maryland and Virginia. Offering award-winning opinion writing, entertainment information and restaurant reviews.' # noqa publisher = 'The Washington Post Company' category = 'news, politics, USA' - oldest_article = 2 + oldest_article = 1.2 max_articles_per_feed = 200 no_stylesheets = True encoding = 'utf8'