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
a25977271b
@ -95,11 +95,12 @@ class BusinessStandard(BasicNewsRecipe):
|
|||||||
if 'multiple_authors_name' in data:
|
if 'multiple_authors_name' in data:
|
||||||
auth = '<div><p class="auth">' + data['multiple_authors_name'] + ' | ' + data['placeName'] + ' | ' + date + '</p></div>'
|
auth = '<div><p class="auth">' + data['multiple_authors_name'] + ' | ' + data['placeName'] + ' | ' + date + '</p></div>'
|
||||||
|
|
||||||
if data['featuredImageObj'] and 'url' in data['featuredImageObj']:
|
if 'featuredImageObj' in data:
|
||||||
if img_url is not None:
|
if 'url' in data['featuredImageObj']:
|
||||||
lede = '<p class="cap"><img src="{}">'.format(img_url)
|
if img_url is not None:
|
||||||
else:
|
lede = '<p class="cap"><img src="{}">'.format(img_url)
|
||||||
lede = '<p class="cap"><img src="{}">'.format(data['featuredImageObj']['url'])
|
else:
|
||||||
|
lede = '<p class="cap"><img src="{}">'.format(data['featuredImageObj']['url'])
|
||||||
if 'alt_text' in data['featuredImageObj']:
|
if 'alt_text' in data['featuredImageObj']:
|
||||||
caption = '<span>' + data['featuredImageObj']['alt_text'] + '</span></p>'
|
caption = '<span>' + data['featuredImageObj']['alt_text'] + '</span></p>'
|
||||||
|
|
||||||
|
@ -12,25 +12,20 @@ class EpochTimes(BasicNewsRecipe):
|
|||||||
oldest_article = 1.2
|
oldest_article = 1.2
|
||||||
max_articles_per_feed = 20
|
max_articles_per_feed = 20
|
||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
remove_attributes = ['height', 'width']
|
remove_attributes = ['height', 'width', 'style']
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
masthead_url = 'https://epochtimes-ny.newsmemory.com/eeLayout/epochtimes/1.0.a/images/webapp/banner.png'
|
masthead_url = 'https://epochtimes-ny.newsmemory.com/eeLayout/epochtimes/1.0.a/images/webapp/banner.png'
|
||||||
extra_css = """
|
|
||||||
body{font-family: Arial,sans-serif }
|
|
||||||
.featured_caption{font-size: small}
|
|
||||||
.author,.date{font-size: small}
|
|
||||||
"""
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
classes('post-main'),
|
dict(name='article')
|
||||||
]
|
]
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
classes('print:hidden h-header'),
|
classes('print:hidden h-header shortcode aspect-square'),
|
||||||
dict(name='button'),
|
dict(name='button'),
|
||||||
]
|
]
|
||||||
#
|
|
||||||
# feeds can be found at https://www.theepochtimes.com/rssfeeds
|
|
||||||
|
|
||||||
|
# feeds can be found at https://www.theepochtimes.com/rssfeeds
|
||||||
feeds = [
|
feeds = [
|
||||||
('Special Series', 'https://feed.theepochtimes.com/health/special-series/feed'),
|
('Special Series', 'https://feed.theepochtimes.com/health/special-series/feed'),
|
||||||
('US', 'https://feed.theepochtimes.com/us/feed'),
|
('US', 'https://feed.theepochtimes.com/us/feed'),
|
||||||
@ -48,11 +43,4 @@ class EpochTimes(BasicNewsRecipe):
|
|||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for img in soup.findAll('img', attrs={'data-src': True}):
|
for img in soup.findAll('img', attrs={'data-src': True}):
|
||||||
img['src'] = img['data-src']
|
img['src'] = img['data-src']
|
||||||
title = soup.find(attrs={'class': 'post_title'})
|
|
||||||
fi = soup.find(attrs={'class': 'featured_image'})
|
|
||||||
if title is not None and fi is not None:
|
|
||||||
title.extract()
|
|
||||||
fi.insert_before(title)
|
|
||||||
for div in soup.findAll(**classes('post-main'))[1:]:
|
|
||||||
div.extract()
|
|
||||||
return soup
|
return soup
|
||||||
|
@ -1,27 +1,35 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
# vim:fileencoding=utf-8
|
|
||||||
from __future__ import unicode_literals, division, absolute_import, print_function
|
|
||||||
|
|
||||||
'''
|
'''
|
||||||
focus.de
|
focus.de
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
||||||
|
|
||||||
|
|
||||||
class AdvancedUserRecipe1305567197(BasicNewsRecipe):
|
class AdvancedUserRecipe1305567197(BasicNewsRecipe):
|
||||||
title = 'Focus (DE)'
|
title = 'Focus (DE)'
|
||||||
__author__ = 'Anonymous'
|
__author__ = 'unkn0wn'
|
||||||
description = 'RSS-Feeds von Focus.de'
|
description = 'RSS-Feeds von Focus.de, best downloaded at the end of the week.'
|
||||||
language = 'de'
|
language = 'de'
|
||||||
|
|
||||||
oldest_article = 7
|
oldest_article = 7
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 25
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
remove_empty_feeds = True
|
remove_empty_feeds = True
|
||||||
ignore_duplicate_articles = {'title', 'url'}
|
ignore_duplicate_articles = {'title', 'url'}
|
||||||
|
remove_attributes = ['width', 'height', 'style']
|
||||||
|
masthead_url = 'https://www.focus-magazin.de/img/Focus_Logo.jpg'
|
||||||
|
extra_css = '''
|
||||||
|
.posMarker_oh { font-size:small; color:#404040; }
|
||||||
|
.posMarker_he { font-size:large; font-weight:bold; }
|
||||||
|
.leadIn { font-style:italic; color:#202020; }
|
||||||
|
.caption { text-align:center; font-size:small; }
|
||||||
|
.authorMeta, .displayDate { font-size:small; }
|
||||||
|
'''
|
||||||
|
|
||||||
|
def get_cover_url(self):
|
||||||
|
soup = self.index_to_soup('https://www.focus-magazin.de/')
|
||||||
|
return soup.find('img', attrs={'class':'main-cover'})['src']
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
('Politik', 'http://rss.focus.de/politik/'),
|
('Politik', 'http://rss.focus.de/politik/'),
|
||||||
@ -29,33 +37,25 @@ class AdvancedUserRecipe1305567197(BasicNewsRecipe):
|
|||||||
('Gesundheit', 'http://rss.focus.de/gesundheit/'),
|
('Gesundheit', 'http://rss.focus.de/gesundheit/'),
|
||||||
('Panorama', 'http://rss.focus.de/panorama/'),
|
('Panorama', 'http://rss.focus.de/panorama/'),
|
||||||
('Digital', 'http://rss.focus.de/digital/'),
|
('Digital', 'http://rss.focus.de/digital/'),
|
||||||
('Reisen', 'http://rss.focus.de/reisen/')
|
('Reisen', 'http://rss.focus.de/reisen/'),
|
||||||
|
('Andere', 'http://rss.focus.de')
|
||||||
]
|
]
|
||||||
|
|
||||||
keep_only_tags = [
|
keep_only_tags = [
|
||||||
dict(name='div', attrs={'id': 'article'})
|
classes('articleHead articleContent')
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name='div', attrs={'class': ['inimagebuttons',
|
dict(name=['svg', 'script']),
|
||||||
'kolumneHead clearfix']})
|
classes('socFbLikeShare video social_frame'),
|
||||||
|
dict(attrs={'id': 'article-social-holder'})
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_attributes = ['width', 'height']
|
|
||||||
|
|
||||||
extra_css = 'h1 {font-size: 1.6em; text-align: left; margin-top: 0em} \
|
|
||||||
h2 {font-size: 1em; text-align: left} \
|
|
||||||
.overhead {margin-bottom: 0em} \
|
|
||||||
.caption {font-size: 0.6em}'
|
|
||||||
|
|
||||||
def print_version(self, url):
|
|
||||||
return url + '?drucken=1'
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
# remove useless references to videos
|
if h1 := soup.find(attrs={'class':'articleIdentH1'}):
|
||||||
for item in soup.findAll('h2'):
|
h1.name = 'h1'
|
||||||
if item.string:
|
if he := soup.find(**classes('posMarker_he')):
|
||||||
txt = item.string.upper()
|
he.name = 'div'
|
||||||
if txt.startswith('IM VIDEO:') or txt.startswith('VIDEO:'):
|
for img in soup.findAll('img', attrs={'data-src':True}):
|
||||||
item.extract()
|
img['src'] = img['data-src']
|
||||||
return soup
|
return soup
|
||||||
|
@ -4,7 +4,6 @@ from collections import defaultdict
|
|||||||
from datetime import date
|
from datetime import date
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
from calibre.web.feeds.news import BasicNewsRecipe, classes
|
||||||
|
|
||||||
|
|
||||||
def absurl(url):
|
def absurl(url):
|
||||||
if url.startswith('/'):
|
if url.startswith('/'):
|
||||||
url = 'https://www.thehindu.com' + url
|
url = 'https://www.thehindu.com' + url
|
||||||
@ -16,11 +15,16 @@ local_edition = None
|
|||||||
# For past editions, set date to, for example, '2023-01-28'
|
# For past editions, set date to, for example, '2023-01-28'
|
||||||
past_edition = None
|
past_edition = None
|
||||||
|
|
||||||
|
is_monday = date.today().weekday() == 0
|
||||||
|
is_friday = date.today().weekday() == 4
|
||||||
|
is_saturday = date.today().weekday() == 5
|
||||||
is_sunday = date.today().weekday() == 6
|
is_sunday = date.today().weekday() == 6
|
||||||
|
|
||||||
if past_edition:
|
if past_edition:
|
||||||
year, month, day = (int(x) for x in past_edition.split('-'))
|
year, month, day = (int(x) for x in past_edition.split('-'))
|
||||||
dt = date(year, month, day)
|
dt = date(year, month, day)
|
||||||
|
is_monday = dt.weekday() == 0
|
||||||
|
is_saturday = dt.weekday() == 5
|
||||||
is_sunday = dt.weekday() == 6
|
is_sunday = dt.weekday() == 6
|
||||||
|
|
||||||
class TheHindu(BasicNewsRecipe):
|
class TheHindu(BasicNewsRecipe):
|
||||||
@ -75,13 +79,23 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
today = past_edition
|
today = past_edition
|
||||||
self.log('Downloading past edition of', local_edition + ' from ' + today)
|
self.log('Downloading past edition of', local_edition + ' from ' + today)
|
||||||
url = absurl('/todays-paper/' + today + '/' + local_edition + '/')
|
url = absurl('/todays-paper/' + today + '/' + local_edition + '/')
|
||||||
|
if is_monday:
|
||||||
|
mag_url = url + '?supplement=' + local_edition + '-epbs'
|
||||||
|
if is_saturday:
|
||||||
|
mag_url = url + '?supplement=' + local_edition + '-mp'
|
||||||
if is_sunday:
|
if is_sunday:
|
||||||
mag_url = url + '?supplement=' + local_edition + '-sm'
|
mag_url = url + '?supplement=' + local_edition + '-sm'
|
||||||
else:
|
else:
|
||||||
url = 'https://www.thehindu.com/todays-paper/'
|
url = 'https://www.thehindu.com/todays-paper/'
|
||||||
|
if is_monday:
|
||||||
|
mag_url = url + '?supplement=th_chennai-epbs'
|
||||||
|
if is_friday:
|
||||||
|
mag_url = url + '?supplement=th_chennai-fr'
|
||||||
|
if is_saturday:
|
||||||
|
mag_url = url + '?supplement=th_chennai-mp'
|
||||||
if is_sunday:
|
if is_sunday:
|
||||||
mag_url = url + '?supplement=th_chennai-sm'
|
mag_url = url + '?supplement=th_chennai-sm'
|
||||||
|
|
||||||
raw = self.index_to_soup(url, raw=True)
|
raw = self.index_to_soup(url, raw=True)
|
||||||
soup = self.index_to_soup(raw)
|
soup = self.index_to_soup(raw)
|
||||||
ans = self.hindu_parse_index(soup)
|
ans = self.hindu_parse_index(soup)
|
||||||
@ -93,17 +107,18 @@ class TheHindu(BasicNewsRecipe):
|
|||||||
'The Hindu Newspaper is not published Today.'
|
'The Hindu Newspaper is not published Today.'
|
||||||
)
|
)
|
||||||
if mag_url:
|
if mag_url:
|
||||||
self.log('\nFetching Sunday Magazine')
|
self.log('\nFetching Magazine')
|
||||||
soup = self.index_to_soup(mag_url)
|
soup = self.index_to_soup(mag_url)
|
||||||
ans2 = self.hindu_parse_index(soup)
|
ans2 = self.hindu_parse_index(soup)
|
||||||
if ans2:
|
if ans2:
|
||||||
return ans + ans2
|
return ans + ans2
|
||||||
|
self.log('\tMagazine not Found')
|
||||||
return ans
|
return ans
|
||||||
return ans
|
return ans
|
||||||
|
|
||||||
def hindu_parse_index(self, soup):
|
def hindu_parse_index(self, soup):
|
||||||
for script in soup.findAll('script'):
|
for script in soup.findAll('script'):
|
||||||
if not self.tag_to_string(script).strip().startswith('let grouped_articles = {}'):
|
if not self.tag_to_string(script).__contains__('grouped_articles = {"'):
|
||||||
continue
|
continue
|
||||||
if script is not None:
|
if script is not None:
|
||||||
art = re.search(r'grouped_articles = ({\".*)', self.tag_to_string(script))
|
art = re.search(r'grouped_articles = ({\".*)', self.tag_to_string(script))
|
||||||
|
Loading…
x
Reference in New Issue
Block a user