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
f42d0aaf6c
@ -14,10 +14,10 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
ignore_duplicate_articles = {'url'}
|
ignore_duplicate_articles = {'url'}
|
||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
masthead_url = 'https://assets.bwbx.io/s3/javelin/public/hub/images/BW-Logo-Black-cc9035fbb3.svg'
|
masthead_url = 'https://assets.bwbx.io/s3/javelin/public/hub/images/BW-Logo-Black-cc9035fbb3.svg'
|
||||||
delay = 2
|
delay = 3 # seconds
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
#auth {font-size:small; font-weight:bold;}
|
#auth {font-size:small; font-weight:bold;}
|
||||||
#time {font-size:small;}
|
#time, .chart {font-size:small;}
|
||||||
#subhead {font-style:italic; color:#404040;}
|
#subhead {font-style:italic; color:#404040;}
|
||||||
.news-figure-caption-text, #cap {font-size:small; text-align:center;}
|
.news-figure-caption-text, #cap {font-size:small; text-align:center;}
|
||||||
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
|
.news-figure-credit {font-size:small; text-align:center; color:#202020;}
|
||||||
@ -94,7 +94,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
subhead = '<div id="subhead"><p>' + data['abstract'][0] + '</p><p>' + data['abstract'][1] + '</p></div>'
|
subhead = '<div id="subhead"><p>' + data['abstract'][0] + '</p><p>' + data['abstract'][1] + '</p></div>'
|
||||||
else:
|
else:
|
||||||
if 'summary' in data:
|
if 'summary' in data:
|
||||||
subhead = '<div id="subhead">' + data['summary'] + '</div>'
|
subhead = '<div id="subhead"><p>' + data['summary'] + '</p></div>'
|
||||||
|
|
||||||
if 'byline' in data:
|
if 'byline' in data:
|
||||||
if data['byline'] is not None:
|
if data['byline'] is not None:
|
||||||
@ -103,12 +103,12 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
|
|
||||||
if 'ledeImageUrl' in data:
|
if 'ledeImageUrl' in data:
|
||||||
if data['ledeImageUrl'] is not None:
|
if data['ledeImageUrl'] is not None:
|
||||||
lede = '<p><img src="{}">'.format(data['ledeImageUrl'].replace('\\', ''))
|
lede = '<p><img src="{}">'.format(data['ledeImageUrl'])
|
||||||
|
|
||||||
if data['ledeDescription'] is not None:
|
if data['ledeDescription'] is not None:
|
||||||
caption = '<span id="cap">' + data['ledeDescription'] + '</span>'
|
caption = '<span id="cap">' + data['ledeDescription'] + '</span>'
|
||||||
|
|
||||||
body = data['body'].replace('\\', '')
|
body = data['body']
|
||||||
html = '<html><body>' + cat + title + subhead + auth + lede + caption + '<div>' + body
|
html = '<html><body>' + cat + title + subhead + auth + lede + caption + '<div>' + body
|
||||||
return html
|
return html
|
||||||
|
|
||||||
|
@ -13,12 +13,12 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
remove_attributes = ['style', 'height', 'width']
|
remove_attributes = ['style', 'height', 'width']
|
||||||
ignore_duplicate_articles = {'url', 'title'}
|
ignore_duplicate_articles = {'url', 'title'}
|
||||||
resolve_internal_links = True
|
resolve_internal_links = True
|
||||||
oldest_article = 2 # days
|
|
||||||
delay = 1.5
|
delay = 5 # seconds
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
#auth {font-size:small; font-weight:bold;}
|
#auth {font-size:small; font-weight:bold;}
|
||||||
#time {font-size:small;}
|
#time, .chart {font-size:small;}
|
||||||
#subhead {font-style:italic; color:#404040;}
|
#subhead {font-style:italic; color:#404040;}
|
||||||
#cat {font-size:small; color:gray;}
|
#cat {font-size:small; color:gray;}
|
||||||
.news-figure-caption-text, #cap {font-size:small; text-align:center;}
|
.news-figure-caption-text, #cap {font-size:small; text-align:center;}
|
||||||
@ -53,11 +53,11 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
feeds = [
|
feeds = [
|
||||||
('Features',
|
('Features',
|
||||||
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Ffeatures%2F&hl=en-US&gl=US&ceid=US:en'),
|
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Ffeatures%2F&hl=en-US&gl=US&ceid=US:en'),
|
||||||
('News',
|
|
||||||
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Farticles%2F&hl=en-US&gl=US&ceid=US:en'),
|
|
||||||
('Opinion', 'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fopinion%2F&hl=en-US&gl=US&ceid=US:en'),
|
('Opinion', 'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fopinion%2F&hl=en-US&gl=US&ceid=US:en'),
|
||||||
('Newsletters',
|
('Newsletters',
|
||||||
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Fnewsletters%2F&hl=en-US&gl=US&ceid=US:en'),
|
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Fnewsletters%2F&hl=en-US&gl=US&ceid=US:en'),
|
||||||
|
('News',
|
||||||
|
'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com%2Fnews%2Farticles%2F&hl=en-US&gl=US&ceid=US:en'),
|
||||||
('Others', 'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com&hl=en-US&gl=US&ceid=US:en')
|
('Others', 'https://news.google.com/rss/search?q=when:27h+allinurl:bloomberg.com&hl=en-US&gl=US&ceid=US:en')
|
||||||
]
|
]
|
||||||
|
|
||||||
@ -84,7 +84,7 @@ class Bloomberg(BasicNewsRecipe):
|
|||||||
subhead = '<div id="subhead"><p>' + data['abstract'][0] + '</p><p>' + data['abstract'][1] + '</p></div>'
|
subhead = '<div id="subhead"><p>' + data['abstract'][0] + '</p><p>' + data['abstract'][1] + '</p></div>'
|
||||||
else:
|
else:
|
||||||
if 'summary' in data:
|
if 'summary' in data:
|
||||||
subhead = '<div id="subhead">' + data['summary'] + '</div>'
|
subhead = '<div id="subhead"><p>' + data['summary'] + '</p></div>'
|
||||||
|
|
||||||
if 'byline' in data:
|
if 'byline' in data:
|
||||||
if data['byline'] is not None:
|
if data['byline'] is not None:
|
||||||
|
@ -2,6 +2,7 @@
|
|||||||
# vim:fileencoding=utf-8
|
# vim:fileencoding=utf-8
|
||||||
from __future__ import unicode_literals, division, absolute_import, print_function
|
from __future__ import unicode_literals, division, absolute_import, print_function
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from calibre.ptempfile import PersistentTemporaryFile
|
||||||
import json
|
import json
|
||||||
|
|
||||||
# a serarch topic, filled into the string below. You can change that to anything google news should be searched for...
|
# a serarch topic, filled into the string below. You can change that to anything google news should be searched for...
|
||||||
@ -16,9 +17,9 @@ class google_news_de(BasicNewsRecipe):
|
|||||||
title = 'Google News'
|
title = 'Google News'
|
||||||
cover_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Google_News_icon.svg/500px-Google_News_icon.svg.png'
|
cover_url = 'https://upload.wikimedia.org/wikipedia/commons/thumb/d/da/Google_News_icon.svg/500px-Google_News_icon.svg.png'
|
||||||
# Author
|
# Author
|
||||||
__author__ = 'Volker Heggemann, VoHe'
|
__author__ = 'Volker Heggemann, VoHe, unkn0wn'
|
||||||
# oldest article to download (in days) ---- can be edit by user
|
# oldest article to download (in days) ---- can be edit by user
|
||||||
oldest_article = 2
|
oldest_article = 1.25
|
||||||
# describes itself, ---- can be edit by user
|
# describes itself, ---- can be edit by user
|
||||||
max_articles_per_feed = 200
|
max_articles_per_feed = 200
|
||||||
# speed up the download on fast computers be careful (I test max.20)
|
# speed up the download on fast computers be careful (I test max.20)
|
||||||
@ -36,6 +37,30 @@ class google_news_de(BasicNewsRecipe):
|
|||||||
|
|
||||||
# remove the rubbish (in ebook)
|
# remove the rubbish (in ebook)
|
||||||
auto_cleanup = True
|
auto_cleanup = 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/', 'podcast-'
|
||||||
|
]
|
||||||
|
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('Found link: ', link['href'])
|
||||||
|
html = br.open(link['href']).read()
|
||||||
|
pt = PersistentTemporaryFile('.html')
|
||||||
|
pt.write(html)
|
||||||
|
pt.close()
|
||||||
|
return pt.name
|
||||||
|
|
||||||
# now the content description and URL follows
|
# now the content description and URL follows
|
||||||
# feel free to add, wipe out what you need ---- can be edit by user
|
# feel free to add, wipe out what you need ---- can be edit by user
|
||||||
|
Loading…
x
Reference in New Issue
Block a user