From a95132e51b1f4f8d5caaa71c7af761758be54d07 Mon Sep 17 00:00:00 2001
From: unkn0w7n <51942695+unkn0w7n@users.noreply.github.com>
Date: Sun, 23 Jul 2023 13:09:38 +0530
Subject: [PATCH] add inc42.recipe
---
recipes/bloomberg-business-week.recipe | 12 ++---
recipes/bloomberg.recipe | 5 +-
recipes/icons/inc42.png | Bin 0 -> 985 bytes
recipes/inc42.recipe | 65 +++++++++++++++++++++++++
4 files changed, 73 insertions(+), 9 deletions(-)
create mode 100644 recipes/icons/inc42.png
create mode 100644 recipes/inc42.recipe
diff --git a/recipes/bloomberg-business-week.recipe b/recipes/bloomberg-business-week.recipe
index 2e594caf41..290cfe4ae9 100644
--- a/recipes/bloomberg-business-week.recipe
+++ b/recipes/bloomberg-business-week.recipe
@@ -21,7 +21,7 @@ def get_contents(x):
return '
' + x.get('value', '') + ''.join(map(get_contents, x.get('content'))) + '
'
elif otype == 'media':
if x['subType'] == 'photo':
- return ''.format(
+ return ''.format(
x['data']['photo']['src'], x['data']['photo']['caption'])
elif x['subType'] == 'chart':
if x['data'] and x['data']['chart']:
@@ -58,11 +58,11 @@ class Bloomberg(BasicNewsRecipe):
simultaneous_downloads = 3
extra_css = '''
- #bold {font-weight:bold;}
- #auth {font-size:small; font-weight:bold;}
- #time, .chart {font-size:small;}
- #subhead {font-style:italic; color:#404040;}
- .news-figure-caption-text, #cap, #img {font-size:small; text-align:center;}
+ .auth {font-size:small; font-weight:bold;}
+ .time, .chart {font-size:small;}
+ .subhead {font-style:italic; color:#404040;}
+ .cat {font-size:small; color:gray;}
+ .news-figure-caption-text, .cap, .img {font-size:small; text-align:center;}
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
'''
diff --git a/recipes/bloomberg.recipe b/recipes/bloomberg.recipe
index 19eb87da8d..e7d743d2e7 100644
--- a/recipes/bloomberg.recipe
+++ b/recipes/bloomberg.recipe
@@ -22,11 +22,11 @@ def get_contents(x):
return '' + x.get('value', '') + ''.join(map(get_contents, x.get('content'))) + '
'
elif otype == 'media':
if x['subType'] == 'photo':
- return ''.format(
+ return ''.format(
x['data']['photo']['src'], x['data']['photo']['caption'])
elif x['subType'] == 'chart':
if x['data'] and x['data']['chart']:
- return '
'.format(x['data']['chart']['fallback'])
+ return '
'.format(x['data']['chart']['fallback'])
elif otype == 'link':
if x['data'] and x['content'] and x['content'][0] and x['content'][0]['value']:
if 'href' in x['data']:
@@ -53,7 +53,6 @@ class Bloomberg(BasicNewsRecipe):
use_embedded_content = False
remove_attributes = ['style', 'height', 'width']
ignore_duplicate_articles = {'url', 'title'}
- resolve_internal_links = True
# delay = 7 # seconds
simultaneous_downloads = 3
diff --git a/recipes/icons/inc42.png b/recipes/icons/inc42.png
new file mode 100644
index 0000000000000000000000000000000000000000..9edc13d383c81c5e7099705124922a8ac195d57d
GIT binary patch
literal 985
zcmV;~119{5P)4`M}6Efw`3
zXhA$!kP>K7i3J5|Z{luB5uq;ZrbW}HTTPR#G~LbacHeJ2>?VDA-G6Psiy3%_H*aRX
z^Jc!knfG8-{_i5q3@%3o1MOlSG01(b2305mvn91xOStnJ(r4@1I?aN0NFWA$4XkSc
z`-Z}}t9m>jG7XfQIW$aQE*c8~?*R|D0DcL07dWvlomgnKT6Gi1MxF|Q?gO4{Ap^gab_J9L)8F)j4^?rX-qa?!tk^NLk
zy(p8wM*_JT0WzbRWbu~2JPmZzC~VlOZfMAXxo9jT6(&FEQ5O_G7WlnRU=q2U_XUD=
zW`ilCOL#}a1F|fED(m<9S+DSYN$pr)dP1|&SgpYAv(ce@45C$)TW8|U1;u0*??>+K
z=>|HN60o9!2KM_{Kc(oQzVyWP2BUODkRK{^0HD8yS;@kec@I|t$R@yX0Io)d)(RW|
z!d@rf)0@g~O^$MJ^{P{O{scZZ@J0XRnVSGtB2OBHodUl&e{3E!2H7L9-RFE-;Ameu
zVeewcxC%*uG2mMu-IJ;uzfrc*F6If~WgzZMl?z>4Oy`SjB5j@ke<>UcrQ&mU2&}+)
z;D|*}1d!>TR9u%9#m48k-ZsBk;jmO&;iTRJPHJE
zds%IAUA4_ZiUlDYk&6HzXW^&
zbT?hcJ1(9p0^hYl@oY5K>F>S3PvOalLX90W)+AgBn08p1kKDxr)Hd>fg<(tVI3=zHL6VTz1)Q00000NkvXX
Hu0mjf5dpv|
literal 0
HcmV?d00001
diff --git a/recipes/inc42.recipe b/recipes/inc42.recipe
new file mode 100644
index 0000000000..5aaa10ddb3
--- /dev/null
+++ b/recipes/inc42.recipe
@@ -0,0 +1,65 @@
+from calibre.ptempfile import PersistentTemporaryFile
+from calibre.web.feeds.news import BasicNewsRecipe, classes
+
+class inc42(BasicNewsRecipe):
+ title = 'Inc42'
+ __author__ = 'unkn0wn'
+ description = 'Inc42 is India’s largest tech media platform working with the mission to accelerate the GDP of India’s tech & startup economy.'
+ no_stylesheets = True
+ use_embedded_content = False
+ encoding = 'utf-8'
+ language = 'en_IN'
+ remove_attributes = ['style', 'height', 'width']
+ masthead_url = 'https://omcdn.inc42.com/users/d0ffd8ffa0d2/images/4477fc48bee71659696918-color-black-1-e1576150264134.png?width=224'
+
+ keep_only_tags = [
+ classes('entry-header entry-content'),
+ ]
+
+ remove_tags = [
+ dict(name='button'),
+ classes('also-read slick-list slides-three common-card'),
+ ]
+
+ ignore_duplicate_articles = {'title'}
+ remove_empty_feeds = True
+
+ 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/', '/media/'
+ ]
+ 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
+
+ feeds = []
+
+ sections = [
+ 'features', 'buzz', 'startups', 'resources'
+ ]
+
+ for sec in sections:
+ a = 'https://news.google.com/rss/search?q=when:27h+allinurl:inc42.com{}&hl=en-IN&gl=IN&ceid=IN:en'
+ feeds.append((sec.capitalize(), a.format('%2F' + sec + '%2F')))
+ feeds.append(('Others', a.format('')))
+
+ def preprocess_html(self, soup):
+ for img in soup.findAll('img', attrs={'data-src':True}):
+ img['src'] = img['data-src']
+ return soup