Update Deutsche Welle (English and Spanish editions)

This commit is contained in:
Kovid Goyal 2016-05-15 21:37:13 +05:30
parent 81182e7ae8
commit 1bac058322
2 changed files with 113 additions and 98 deletions

View File

@ -1,66 +1,73 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>' __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
''' '''
dw-world.de Deutsche Welle (english) - dw.com/en
''' '''
import re
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class DeutscheWelle_en(BasicNewsRecipe): class DeutscheWelle_en(BasicNewsRecipe):
title = 'Deutsche Welle' title = 'Deutsche Welle'
__author__ = 'Darko Miletic' __author__ = 'Darko Miletic'
description = 'News from Germany and World' description = 'News from Germany and the world'
publisher = 'Deutsche Welle' publisher = 'Deutsche Welle'
category = 'news, politics, Germany' language = 'en'
oldest_article = 1
max_articles_per_feed = 100
use_embedded_content = False
no_stylesheets = True
language = 'en'
publication_type = 'newsportal'
remove_empty_feeds = True
masthead_url = 'http://www.dw-world.de/skins/std/channel1/pics/dw_logo1024.gif'
extra_css = """
body{font-family: Arial,sans-serif}
img{margin-top: 0.5em; margin-bottom: 0.2em; display: block}
.caption{font-size: x-small; display: block; margin-bottom: 0.4em}
"""
oldest_article = 1
max_articles_per_feed = 50
no_stylesheets = True
remove_javascript = True
remove_empty_feeds = True
ignore_duplicate_articles = {'title', 'url'}
conversion_options = { feeds = [
'comment' : description ('Top Stories', 'http://rss.dw-world.de/rdf/rss-en-top'),
, 'tags' : category ('World', 'http://rss.dw.de/rdf/rss-en-world'),
, 'publisher': publisher ('Germany', 'http://rss.dw.de/rdf/rss-en-ger'),
, 'language' : language ('Europe', 'http://rss.dw.de/rdf/rss-en-eu'),
} ('Business', 'http://rss.dw.de/rdf/rss-en-bus'),
('Culture & Lifestyle', 'http://rss.dw.de/rdf/rss-en-cul'),
('Sports', 'http://rss.dw.de/rdf/rss-en-sports'),
('Visit Germany', 'http://rss.dw.de/rdf/rss-en-visitgermany'),
('Asia', 'http://rss.dw.de/rdf/rss-en-asia')
]
keep_only_tags=[
dict(name='div', attrs={'class':'col3'})
]
remove_tags_after = [
dict(name='div', attrs={'class':'group'})
]
remove_tags = [ remove_tags = [
dict(name=['iframe','embed','object','form','base','meta','link']) dict(name='div', attrs={'class':'col1'}),
,dict(attrs={'class':'actionFooter'}) dict(name='div', attrs={'class':re.compile('gallery')}),
] dict(name='div', attrs={'class':re.compile('audio')}),
keep_only_tags=[dict(attrs={'class':'ArticleDetail detail'})] dict(name='div', attrs={'class':re.compile('video')})
remove_attributes = ['height','width','onclick','border','lang'] ]
feeds = [(u'All news', u'http://rss.dw-world.de/rdf/rss-en-all')] remove_attributes = ['height', 'width', 'onclick', 'border', 'lang', 'link']
def print_version(self, url): extra_css = '''
artl = url.rpartition('/')[2] h1 {font-size: 1.6em; margin-top: 0em}
return 'http://www.dw-world.de/popups/popup_printcontent/' + artl .artikel {font-size: 1em; text-transform: uppercase; margin: 0em}
'''
def preprocess_html(self, soup): def preprocess_html(self, soup):
for item in soup.findAll('a'): # convert local hyperlinks
limg = item.find('img') for a in soup.findAll('a', href=True):
if item.string is not None: if a['href'].startswith('/'):
str = item.string a['href'] = 'http://www.dw.com' + a['href']
item.replaceWith(str) elif a['href'].startswith('#'):
else: del a['href']
if limg: # remove all style attributes with an effect on font size
item.name = 'div' for item in soup.findAll(attrs={'style':re.compile('font-size')}):
del item['href'] del item['style']
if item.has_key('target'):
del item['target']
else:
str = self.tag_to_string(item)
item.replaceWith(str)
return soup return soup

View File

@ -1,66 +1,74 @@
#!/usr/bin/env python2
# vim:fileencoding=utf-8
from __future__ import unicode_literals, division, absolute_import, print_function
__license__ = 'GPL v3' __license__ = 'GPL v3'
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>' __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
''' '''
dw-world.de Deutsche Welle (español) - dw.com/es
''' '''
import re
from calibre.web.feeds.news import BasicNewsRecipe from calibre.web.feeds.news import BasicNewsRecipe
class DeutscheWelle_es(BasicNewsRecipe): class DeutscheWelle_es(BasicNewsRecipe):
title = 'Deutsche Welle' title = 'Deutsche Welle'
__author__ = 'Darko Miletic' __author__ = 'Darko Miletic'
description = 'Noticias desde Alemania y mundo' description = 'Noticias desde Alemania y mundo'
publisher = 'Deutsche Welle' publisher = 'Deutsche Welle'
category = 'news, politics, Germany' language = 'es'
oldest_article = 1
max_articles_per_feed = 100
use_embedded_content = False
no_stylesheets = True
language = 'de'
publication_type = 'newsportal'
remove_empty_feeds = True
masthead_url = 'http://www.dw-world.de/skins/std/channel1/pics/dw_logo1024.gif'
extra_css = """
body{font-family: Arial,sans-serif}
img{margin-top: 0.5em; margin-bottom: 0.2em; display: block}
.caption{font-size: x-small; display: block; margin-bottom: 0.4em}
"""
oldest_article = 2
max_articles_per_feed = 50
no_stylesheets = True
remove_javascript = True
remove_empty_feeds = True
ignore_duplicate_articles = {'title', 'url'}
conversion_options = { feeds = [
'comment' : description ('Titulares', 'http://rss.dw-world.de/rdf/rss-sp-top'),
, 'tags' : category ('Noticias de Alemania', 'http://rss.dw-world.de/rdf/rss-sp-ale'),
, 'publisher': publisher ('Internacionales', 'http://rss.dw-world.de/rdf/rss-sp-inter'),
, 'language' : language ('Cultura', 'http://rss.dw-world.de/rdf/rss-sp-cul'),
} ('Ciencia y Tecnología', 'http://rss.dw-world.de/rdf/rss-sp-cyt'),
('Economía', 'http://rss.dw-world.de/rdf/rss-sp-eco'),
('La prensa opina', 'http://rss.dw-world.de/rdf/rss-sp-press'),
('Ecología', 'http://rss.dw-world.de/rdf/rss-sp-ecol'),
('Futbol alemán', 'http://rss.dw-world.de/rdf/rss-sp-fut'),
('Conozca Alemania', 'http://rss.dw-world.de/rdf/rss-sp-con')
]
keep_only_tags=[
dict(name='div', attrs={'class':'col3'})
]
remove_tags_after = [
dict(name='div', attrs={'class':'group'})
]
remove_tags = [ remove_tags = [
dict(name=['iframe','embed','object','form','base','meta','link']) dict(name='div', attrs={'class':'col1'}),
,dict(attrs={'class':'actionFooter'}) dict(name='div', attrs={'class':re.compile('gallery')}),
] dict(name='div', attrs={'class':re.compile('audio')}),
keep_only_tags=[dict(attrs={'class':'ArticleDetail detail'})] dict(name='div', attrs={'class':re.compile('video')})
remove_attributes = ['height','width','onclick','border','lang'] ]
feeds = [(u'Noticias', u'http://rss.dw-world.de/rdf/rss-sp-all')] remove_attributes = ['height', 'width', 'onclick', 'border', 'lang', 'link']
def print_version(self, url): extra_css = '''
artl = url.rpartition('/')[2] h1 {font-size: 1.6em; margin-top: 0em}
return 'http://www.dw-world.de/popups/popup_printcontent/' + artl .artikel {font-size: 1em; text-transform: uppercase; margin: 0em}
'''
def preprocess_html(self, soup): def preprocess_html(self, soup):
for item in soup.findAll('a'): # convert local hyperlinks
limg = item.find('img') for a in soup.findAll('a', href=True):
if item.string is not None: if a['href'].startswith('/'):
str = item.string a['href'] = 'http://www.dw.com' + a['href']
item.replaceWith(str) elif a['href'].startswith('#'):
else: del a['href']
if limg: # remove all style attributes with an effect on font size
item.name = 'div' for item in soup.findAll(attrs={'style':re.compile('font-size')}):
del item['href'] del item['style']
if item.has_key('target'):
del item['target']
else:
str = self.tag_to_string(item)
item.replaceWith(str)
return soup return soup