Skip to content

Commit fad178b

Browse files
committed
Merge branch 'master' of https://github.com/unkn0w7n/calibre
2 parents 23e87b0 + a43ada9 commit fad178b

3 files changed

Lines changed: 30 additions & 49 deletions

File tree

recipes/livemint.recipe

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ class LiveMint(BasicNewsRecipe):
102102
classes(
103103
'trendingSimilarHeight moreNews mobAppDownload label msgError msgOk taboolaHeight gadgetSlider'
104104
' socialHolder imgbig disclamerText disqus-comment-count openinApp2 lastAdSlot bs_logo author-widget'
105-
' datePublish sepStory premiumSlider moreStory Joinus moreAbout milestone benefitText'
105+
' datePublish sepStory premiumSlider moreStory Joinus moreAbout milestone benefitText checkCibilBtn'
106106
)
107107
]
108108

recipes/slate.recipe

Lines changed: 29 additions & 47 deletions
Original file line numberDiff line numberDiff line change
@@ -20,66 +20,48 @@ class Slate(BasicNewsRecipe):
2020
title = 'Slate'
2121
description = 'A general-interest publication offering analysis and commentary about politics, news and culture.'
2222
__author__ = 'Kovid Goyal'
23-
timefmt = ''
2423
no_stylesheets = True
2524
language = 'en'
2625
encoding = 'utf-8'
27-
remove_attributes = ['style']
26+
remove_attributes = ['style', 'height', 'width']
27+
oldest_article = 2 # days
2828
INDEX = 'https://slate.com'
29-
compress_news_images = True
29+
resolve_internal_links = True
30+
remove_empty_feeds = True
31+
ignore_duplicate_articles = {'url'}
32+
33+
extra_css = '''
34+
.article__rubric { font-size:small; color:#404040; }
35+
.article__byline, time { font-size:small; }
36+
.article__top-image, .image__credit, .image__meta { font-size:small; text-align:center; }
37+
em, blockquote, .alternativeHeadline { color:#202020; }
38+
'''
3039

3140
keep_only_tags = [
32-
classes('article__header article__content'),
41+
classes('article__header article__top-image article__content article-hotseats__body'),
3342
]
3443
remove_tags = [
44+
dict(name=['aside', 'svg', 'iframe']),
3545
classes('social-share slate-ad newsletter-signup in-article-recirc'),
3646
]
3747

3848
def preprocess_html(self, soup):
49+
for h2 in soup.findAll('h2'):
50+
h2.name = 'h4'
3951
for img in soup.findAll('img', attrs={'data-srcset': True}):
40-
img['src'] = img['data-srcset'].split()[0]
52+
img['src'] = img['data-src'] + '&width=600'
4153
return soup
4254

43-
def parse_index(self):
44-
ans = []
45-
for sectitle, url in (
46-
('News & Politics', '/articles/news_and_politics.html'),
47-
('Technology', '/articles/technology.html'),
48-
('Business', '/articles/business.html'),
49-
('Arts', '/articles/arts.html'),
50-
('Life', '/articles/life.html'),
51-
('Health & Science', '/articles/health_and_science.html'),
52-
('Sports', '/articles/sports.html'),
53-
('Double X', '/articles/double_x.html'),
54-
):
55-
url = self.INDEX + url
56-
self.log('\nFound section:', sectitle, url)
57-
articles = self.slate_section_articles(self.index_to_soup(url))
58-
if articles:
59-
ans.append((sectitle, articles))
60-
if self.test and len(ans) > 1:
61-
break
62-
return ans
55+
feeds = [
56+
('News & Politics', 'https://slate.com/feeds/news-and-politics.rss'),
57+
('Culture', 'https://slate.com/feeds/culture.rss'),
58+
('Technology', 'https://slate.com/feeds/technology.rss'),
59+
('Business', 'https://slate.com/feeds/business.rss'),
60+
('Human Interest', 'https://slate.com/feeds/human-interest.rss'),
61+
('Others', 'https://slate.com/feeds/all.rss')
62+
]
6363

64-
def slate_section_articles(self, soup):
65-
ans = []
66-
main = soup.find('section', **classes('main'))
67-
if main is None:
68-
return ans
69-
for div in main.findAll(**classes('section-feed__item')):
70-
a = div.find('a')
71-
url = a['href']
72-
if url.endswith('/'):
73-
continue
74-
h = a.find(['h2', 'h3', 'h4'])
75-
title = self.tag_to_string(h)
76-
desc = ''
77-
for q in ('byline', 'dek'):
78-
span = div.find(attrs={'class': lambda x: x and ('-' + q) in x})
79-
if span is not None:
80-
desc += self.tag_to_string(span).strip()
81-
self.log('\t' + title)
82-
self.log('\t\t' + url)
83-
ans.append({'title': title, 'description': desc.strip(),
84-
'date': '', 'url': url})
85-
return ans
64+
def get_article_url(self, article):
65+
url = BasicNewsRecipe.get_article_url(self, article)
66+
if '/podcasts/' not in url:
67+
return url.split('?')[0]

recipes/wsj.recipe

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,5 +196,4 @@ class WSJ(BasicNewsRecipe):
196196
article.url = lnk['title']
197197
art = soup.find('h1', attrs={'title':True})
198198
if art:
199-
self.log('found art ', art['title'])
200199
article.url = art['title']

0 commit comments

Comments
 (0)