mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge branch 'master' of https://github.com/unkn0w7n/calibre
This commit is contained in:
commit
065fad39c5
@ -40,7 +40,7 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
'erode, hyderabad, international, kochi, kolkata,\n'
|
'erode, hyderabad, international, kochi, kolkata,\n'
|
||||||
'kozhikode, madurai, mangalore, mumbai, thiruvananthapuram, '
|
'kozhikode, madurai, mangalore, mumbai, thiruvananthapuram, '
|
||||||
'tiruchirapalli, vijayawada, visakhapatnam'),
|
'tiruchirapalli, vijayawada, visakhapatnam'),
|
||||||
'default': 'international'
|
'default': 'chennai'
|
||||||
},
|
},
|
||||||
'date': {
|
'date': {
|
||||||
'short': 'The date of the edition to download (YYYY-MM-DD format)',
|
'short': 'The date of the edition to download (YYYY-MM-DD format)',
|
||||||
@ -68,7 +68,7 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
return soup
|
return soup
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
local_edition = 'th_international'
|
local_edition = 'th_chennai'
|
||||||
d = self.recipe_specific_options.get('location')
|
d = self.recipe_specific_options.get('location')
|
||||||
if d and isinstance(d, str):
|
if d and isinstance(d, str):
|
||||||
local_edition = 'th_' + d
|
local_edition = 'th_' + d
|
||||||
|
@ -4,7 +4,7 @@ from calibre.web.feeds.news import BasicNewsRecipe, classes
|
|||||||
|
|
||||||
|
|
||||||
class TheHindufeeds(BasicNewsRecipe):
|
class TheHindufeeds(BasicNewsRecipe):
|
||||||
title = 'The Hindu (Feeds)'
|
title = 'The Hindu News'
|
||||||
__author__ = 'unkn0wn'
|
__author__ = 'unkn0wn'
|
||||||
description = 'The Hindu, based on RSS feeds.'
|
description = 'The Hindu, based on RSS feeds.'
|
||||||
language = 'en_IN'
|
language = 'en_IN'
|
||||||
@ -20,6 +20,7 @@ class TheHindufeeds(BasicNewsRecipe):
|
|||||||
.caption {font-size:small; text-align:center;}
|
.caption {font-size:small; text-align:center;}
|
||||||
.author, .dateLine, .publish-time {font-size:small; font-weight:bold;}
|
.author, .dateLine, .publish-time {font-size:small; font-weight:bold;}
|
||||||
.subhead, .subhead_lead, .bold {font-weight:bold;}
|
.subhead, .subhead_lead, .bold {font-weight:bold;}
|
||||||
|
.update-publish-time, .publish-time-new {font-size:small; }
|
||||||
img {display:block; margin:0 auto;}
|
img {display:block; margin:0 auto;}
|
||||||
.italic {font-style:italic; color:#202020;}
|
.italic {font-style:italic; color:#202020;}
|
||||||
'''
|
'''
|
||||||
@ -28,7 +29,7 @@ class TheHindufeeds(BasicNewsRecipe):
|
|||||||
'days': {
|
'days': {
|
||||||
'short': 'Oldest article to download from this news source. In days ',
|
'short': 'Oldest article to download from this news source. In days ',
|
||||||
'long': 'For example, 0.5, gives you articles from the past 12 hours',
|
'long': 'For example, 0.5, gives you articles from the past 12 hours',
|
||||||
'default': str(oldest_article)
|
'default': str(oldest_article),
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -40,33 +41,35 @@ class TheHindufeeds(BasicNewsRecipe):
|
|||||||
|
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [classes('article-section')]
|
||||||
classes('article-section')
|
|
||||||
]
|
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name='button'),
|
dict(name='button'),
|
||||||
dict(attrs={'target':'_self'}),
|
dict(attrs={'target': '_self'}),
|
||||||
classes(
|
classes(
|
||||||
'hide-mobile comments-shares share-page editiondetails breadcrumb'
|
'hide-mobile comments-shares share-page editiondetails '
|
||||||
' related-topics related-stories also-read premium-label'
|
'breadcrumb related-stories-inline related-topics related-stories '
|
||||||
)
|
'also-read premium-label article-ad'
|
||||||
|
),
|
||||||
]
|
]
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for cap in soup.findAll('p', attrs={'class':'caption'}):
|
for cap in soup.findAll('p', attrs={'class': 'caption'}):
|
||||||
cap.name = 'figcaption'
|
cap.name = 'figcaption'
|
||||||
for img in soup.findAll('img', attrs={'data-original':True}):
|
for img in soup.findAll('img', attrs={'data-original': True}):
|
||||||
if img['data-original'].endswith('1x1_spacer.png'):
|
if img['data-original'].endswith('1x1_spacer.png'):
|
||||||
source = img.findPrevious('source', srcset=True)
|
source = img.findPrevious('source', srcset=True)
|
||||||
img.extract()
|
img.extract()
|
||||||
if source:
|
if source:
|
||||||
source['src'] = source['srcset'].replace('_320','_1200')
|
source['src'] = source['srcset'].replace('_320', '_1200')
|
||||||
source.name = 'img'
|
source.name = 'img'
|
||||||
else:
|
else:
|
||||||
img['src'] = img['data-original']
|
img['src'] = img['data-original']
|
||||||
for img in soup.findAll('img', attrs={'data-src-template':True}):
|
for img in soup.findAll('img', attrs={'data-src-template': True}):
|
||||||
img['src'] = img['data-src-template']
|
img['src'] = img['data-src-template']
|
||||||
|
if h2 := soup.find(**classes('sub-title')):
|
||||||
|
h2.name = 'p'
|
||||||
|
h2['class'] = 'italic'
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
def postprocess_html(self, soup, first_fetch):
|
def postprocess_html(self, soup, first_fetch):
|
||||||
@ -76,15 +79,15 @@ class TheHindufeeds(BasicNewsRecipe):
|
|||||||
|
|
||||||
def get_cover_url(self):
|
def get_cover_url(self):
|
||||||
soup = self.index_to_soup('https://www.thehindu.com/todays-paper/')
|
soup = self.index_to_soup('https://www.thehindu.com/todays-paper/')
|
||||||
if cover := soup.find(attrs={'class':'hindu-ad'}):
|
if cover := soup.find(attrs={'class': 'hindu-ad'}):
|
||||||
return cover.img['src']
|
return cover.img['src']
|
||||||
|
|
||||||
# https://www.thehindu.com/rssfeeds/
|
# https://www.thehindu.com/rssfeeds/
|
||||||
feeds = [
|
feeds = [
|
||||||
|
('Opinion', 'https://www.thehindu.com/opinion/feeder/default.rss'),
|
||||||
('India', 'https://www.thehindu.com/news/national/feeder/default.rss'),
|
('India', 'https://www.thehindu.com/news/national/feeder/default.rss'),
|
||||||
('States', 'https://www.thehindu.com/news/states/feeder/default.rss'),
|
('States', 'https://www.thehindu.com/news/states/feeder/default.rss'),
|
||||||
# ('Cities', 'https://www.thehindu.com/news/cities/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'),
|
('Business', 'https://www.thehindu.com/business/feeder/default.rss'),
|
||||||
('World', 'https://www.thehindu.com/news/international/feeder/default.rss'),
|
('World', 'https://www.thehindu.com/news/international/feeder/default.rss'),
|
||||||
# ('Sport', 'https://www.thehindu.com/sport/feeder/default.rss'),
|
# ('Sport', 'https://www.thehindu.com/sport/feeder/default.rss'),
|
||||||
@ -92,5 +95,5 @@ class TheHindufeeds(BasicNewsRecipe):
|
|||||||
# ('Crossword', 'https://crossword.thehindu.com/?utm_source=thehindu&utm_medium=mainmenufeeder/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'),
|
('Science', 'https://www.thehindu.com/sci-tech/science/feeder/default.rss'),
|
||||||
('Life and Style', 'https://www.thehindu.com/life-and-style/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')
|
('thRead', 'https://www.thehindu.com/thread/feeder/default.rss'),
|
||||||
]
|
]
|
||||||
|
Loading…
x
Reference in New Issue
Block a user