mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Common Dreams
This commit is contained in:
parent
bc8753c7b5
commit
8659089df7
@ -1,8 +1,9 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
##
|
##
|
||||||
## Title: Common Dreams
|
# Title: Common Dreams
|
||||||
##
|
##
|
||||||
## License: GNU General Public License v3 - http://www.gnu.org/copyleft/gpl.html
|
# License: GNU General Public License v3 -
|
||||||
|
# http://www.gnu.org/copyleft/gpl.html
|
||||||
|
|
||||||
# Feb 2012: Cleaned up the output to have only the main article
|
# Feb 2012: Cleaned up the output to have only the main article
|
||||||
|
|
||||||
@ -14,6 +15,7 @@ commondreams.org
|
|||||||
import re
|
import re
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
|
|
||||||
class CommonDreams(BasicNewsRecipe):
|
class CommonDreams(BasicNewsRecipe):
|
||||||
# Identify the recipe
|
# Identify the recipe
|
||||||
|
|
||||||
@ -29,12 +31,6 @@ class CommonDreams(BasicNewsRecipe):
|
|||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
|
|
||||||
# Flattens all the tables to make it compatible with Nook
|
|
||||||
conversion_options = {'linearize_tables' : True}
|
|
||||||
|
|
||||||
remove_attributes = [ 'border', 'cellspacing', 'align', 'cellpadding', 'colspan',
|
|
||||||
'valign', 'vspace', 'hspace', 'alt', 'width', 'height' ]
|
|
||||||
|
|
||||||
# Specify extra CSS - overrides ALL other CSS (IE. Added last).
|
# Specify extra CSS - overrides ALL other CSS (IE. Added last).
|
||||||
extra_css = 'body { font-family: verdana, helvetica, sans-serif; } \
|
extra_css = 'body { font-family: verdana, helvetica, sans-serif; } \
|
||||||
.introduction, .first { font-weight: bold; } \
|
.introduction, .first { font-weight: bold; } \
|
||||||
@ -57,7 +53,8 @@ class CommonDreams(BasicNewsRecipe):
|
|||||||
|
|
||||||
# Remove the line breaks and float left/right and picture width/height.
|
# Remove the line breaks and float left/right and picture width/height.
|
||||||
preprocess_regexps = [(re.compile(r'<br[ ]*/>', re.IGNORECASE), lambda m: ''),
|
preprocess_regexps = [(re.compile(r'<br[ ]*/>', re.IGNORECASE), lambda m: ''),
|
||||||
(re.compile(r'<br[ ]*clear.*/>', re.IGNORECASE), lambda m: ''),
|
(re.compile(
|
||||||
|
r'<br[ ]*clear.*/>', re.IGNORECASE), lambda m: ''),
|
||||||
(re.compile(r'float:.*?'), lambda m: ''),
|
(re.compile(r'float:.*?'), lambda m: ''),
|
||||||
(re.compile(r'width:.*?px'), lambda m: ''),
|
(re.compile(r'width:.*?px'), lambda m: ''),
|
||||||
(re.compile(r'height:.*?px'), lambda m: ''),
|
(re.compile(r'height:.*?px'), lambda m: ''),
|
||||||
@ -65,25 +62,17 @@ class CommonDreams(BasicNewsRecipe):
|
|||||||
(re.compile(r'</a>'), lambda m: ''),
|
(re.compile(r'</a>'), lambda m: ''),
|
||||||
]
|
]
|
||||||
|
|
||||||
|
|
||||||
# Main article is inside this tag
|
# Main article is inside this tag
|
||||||
keep_only_tags = [
|
keep_only_tags = [dict(name='h1', attrs={'class': 'node__title managed-node-title'}),
|
||||||
dict(name='div', attrs={'id':lambda x: x and 'node-' in x}),
|
dict(name='div', attrs={'class': ['field field--name-field-article-img field--type-image field--label-hidden',
|
||||||
|
'field field--name-body field--type-text-with-summary field--label-hidden']}),
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_tags = [
|
|
||||||
dict(name='div', attrs={'class':'node-links clear-block'}), # remove Share options
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
# Identify the news feeds
|
# Identify the news feeds
|
||||||
|
|
||||||
feeds = [(u'Headlines', u'https://www.commondreams.org/feed/headlines_rss'),
|
feeds = [(u'Headlines', u'https://www.commondreams.org/feed/headlines_rss'),
|
||||||
(u'Further News Articles', u'https://www.commondreams.org/feed/further_rss'),
|
(u'Further News Articles',
|
||||||
|
u'https://www.commondreams.org/feed/further_rss'),
|
||||||
(u'Views', u'https://www.commondreams.org/feed/views_rss'),
|
(u'Views', u'https://www.commondreams.org/feed/views_rss'),
|
||||||
(u'Progressive Newswire', u'https://www.commondreams.org/feed/newswire_rss')]
|
(u'Progressive Newswire', u'https://www.commondreams.org/feed/newswire_rss')]
|
||||||
|
|
||||||
|
|
||||||
def print_version(self, url):
|
|
||||||
url = url + '?print'
|
|
||||||
return url
|
|
Loading…
x
Reference in New Issue
Block a user