mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-08 10:44:09 -04:00
Update Eenadu
This commit is contained in:
parent
946ae082e1
commit
336d6f55f9
@ -1,5 +1,4 @@
|
|||||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
||||||
import string
|
|
||||||
|
|
||||||
from datetime import date
|
from datetime import date
|
||||||
|
|
||||||
@ -13,9 +12,9 @@ class eenadu(BasicNewsRecipe):
|
|||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
remove_attributes = ['height', 'width', 'style']
|
remove_attributes = ['height', 'width', 'style']
|
||||||
ignore_duplicate_articles = {'url', 'title'}
|
ignore_duplicate_articles = {"title", "url"}
|
||||||
masthead_url = 'https://dxxd96tbpm203.cloudfront.net//img/logo.png'
|
masthead_url = 'https://dxxd96tbpm203.cloudfront.net//img/logo.png'
|
||||||
cover_url = 'https://www.ads2publish.com/assets/images/epaper/eenadu-newspaper-epaper.jpg'
|
cover_url = 'https://d66zsp32hue2v.cloudfront.net/Eenadu/2022/06/07/TEL/5_01/9de49f18_01_mr.jpg'
|
||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
@ -24,54 +23,40 @@ class eenadu(BasicNewsRecipe):
|
|||||||
dict(name='span', attrs={'id': 'PDSAIApbreak'}),
|
dict(name='span', attrs={'id': 'PDSAIApbreak'}),
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [classes('sshare-c')]
|
||||||
classes('sshare-c'),
|
|
||||||
]
|
|
||||||
|
|
||||||
def articles_from_soup(self, soup):
|
def articles_from_soup(self, soup):
|
||||||
ans = []
|
ans = []
|
||||||
for link in soup.findAll(attrs={'class': 'telugu_uni_body'}):
|
for link in soup.findAll(attrs={'class': ['telugu_uni_body', 'thumb-content-more', 'owl-carousel']}):
|
||||||
for a in link.findAll('a', attrs={'href': True}):
|
for a in link.findAll('a', attrs={'href': True}):
|
||||||
ul = a['href']
|
url = a['href']
|
||||||
if ul.startswith('https') is False:
|
if url.startswith('https') is False:
|
||||||
url = 'https://www.eenadu.net/' + ul
|
url = 'https://www.eenadu.net/' + url
|
||||||
else:
|
else:
|
||||||
url = ul
|
url = url
|
||||||
if url.__contains__("videos"):
|
|
||||||
url = 0
|
|
||||||
for h3 in a.findAll('h3'):
|
for h3 in a.findAll('h3'):
|
||||||
title = self.tag_to_string(h3)
|
title = self.tag_to_string(h3)
|
||||||
if not url or not title:
|
if not url or not title:
|
||||||
continue
|
continue
|
||||||
self.log('\t\tFound article:', title)
|
self.log('\t', title)
|
||||||
self.log('\t\t\t', url)
|
self.log('\t\t', url)
|
||||||
ans.append({
|
ans.append({
|
||||||
'title': title,
|
'title': title,
|
||||||
'url': url,
|
'url': url})
|
||||||
'description': '',
|
|
||||||
'date': ''
|
|
||||||
})
|
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def parse_index(self):
|
def parse_index(self):
|
||||||
soup = self.index_to_soup('https://www.eenadu.net/')
|
soup = self.index_to_soup('https://www.eenadu.net/')
|
||||||
nav_div = soup.find(id='navbar')
|
nav_div = soup.find(id='navbar')
|
||||||
section_list = [
|
section_list = [
|
||||||
# add links for your district edition here
|
|
||||||
('సంపాదకీయం', 'https://www.eenadu.net/telangana/editorial'),
|
('సంపాదకీయం', 'https://www.eenadu.net/telangana/editorial'),
|
||||||
(
|
|
||||||
'హైదరాబాద్',
|
|
||||||
'https://www.eenadu.net/telangana/districts/hyderabad'
|
|
||||||
),
|
|
||||||
# ('నిజామాబాద్', 'https://www.eenadu.net/telangana/districts/nizamabad'),
|
|
||||||
# ('నల్గొండ', 'https://www.eenadu.net/telangana/districts/nalgonda'),
|
|
||||||
]
|
]
|
||||||
|
|
||||||
# Finding all the section titles that are acceptable
|
# Finding all the section titles that are acceptable
|
||||||
for x in nav_div.findAll(['a']):
|
for x in nav_div.findAll(['a']):
|
||||||
if self.is_accepted_entry(x):
|
if self.is_accepted_entry(x):
|
||||||
section_list.append(
|
section_list.append(
|
||||||
(string.capwords(self.tag_to_string(x)), x['href'])
|
(self.tag_to_string(x), x['href'])
|
||||||
)
|
)
|
||||||
feeds = []
|
feeds = []
|
||||||
|
|
||||||
@ -79,12 +64,11 @@ class eenadu(BasicNewsRecipe):
|
|||||||
for section in section_list:
|
for section in section_list:
|
||||||
section_title = section[0]
|
section_title = section[0]
|
||||||
section_url = section[1]
|
section_url = section[1]
|
||||||
self.log('Found section:', section_title, section_url)
|
self.log(section_title, section_url)
|
||||||
soup = self.index_to_soup(section_url)
|
soup = self.index_to_soup(section_url)
|
||||||
articles = self.articles_from_soup(soup)
|
articles = self.articles_from_soup(soup)
|
||||||
if articles:
|
if articles:
|
||||||
feeds.append((section_title, articles))
|
feeds.append((section_title, articles))
|
||||||
|
|
||||||
return feeds
|
return feeds
|
||||||
|
|
||||||
def is_accepted_entry(self, entry):
|
def is_accepted_entry(self, entry):
|
||||||
@ -94,12 +78,15 @@ class eenadu(BasicNewsRecipe):
|
|||||||
if is_sunday:
|
if is_sunday:
|
||||||
omit_list = [
|
omit_list = [
|
||||||
'net/',
|
'net/',
|
||||||
|
'javascript:void(0)',
|
||||||
'#',
|
'#',
|
||||||
'sports',
|
'sports',
|
||||||
'movies',
|
'movies',
|
||||||
'women',
|
'women',
|
||||||
'technology',
|
'technology',
|
||||||
'business',
|
'business',
|
||||||
|
'stories.eenadu.net',
|
||||||
|
'calendar',
|
||||||
'devotional',
|
'devotional',
|
||||||
'youth',
|
'youth',
|
||||||
'recipes',
|
'recipes',
|
||||||
@ -107,7 +94,7 @@ class eenadu(BasicNewsRecipe):
|
|||||||
'temples',
|
'temples',
|
||||||
'kathalu',
|
'kathalu',
|
||||||
'viral-videos',
|
'viral-videos',
|
||||||
'nri',
|
'Nri',
|
||||||
'videos',
|
'videos',
|
||||||
'explained',
|
'explained',
|
||||||
'agriculture',
|
'agriculture',
|
||||||
@ -121,12 +108,15 @@ class eenadu(BasicNewsRecipe):
|
|||||||
else:
|
else:
|
||||||
omit_list = [
|
omit_list = [
|
||||||
'net/',
|
'net/',
|
||||||
|
'javascript:void(0)',
|
||||||
'#',
|
'#',
|
||||||
'sports',
|
'sports',
|
||||||
'movies',
|
'movies',
|
||||||
'women',
|
'women',
|
||||||
'technology',
|
'technology',
|
||||||
'business',
|
'business',
|
||||||
|
'stories.eenadu.net',
|
||||||
|
'calendar',
|
||||||
'devotional',
|
'devotional',
|
||||||
'youth',
|
'youth',
|
||||||
'recipes',
|
'recipes',
|
||||||
@ -134,7 +124,7 @@ class eenadu(BasicNewsRecipe):
|
|||||||
'temples',
|
'temples',
|
||||||
'kathalu',
|
'kathalu',
|
||||||
'viral-videos',
|
'viral-videos',
|
||||||
'nri',
|
'Nri',
|
||||||
'videos',
|
'videos',
|
||||||
'explained',
|
'explained',
|
||||||
'agriculture',
|
'agriculture',
|
||||||
|
Loading…
x
Reference in New Issue
Block a user