mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Updated recipe for The New Yorker
This commit is contained in:
parent
8c6801d9c8
commit
fe7876189c
@ -1,53 +1,57 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
newyorker.com
|
newyorker.com
|
||||||
'''
|
'''
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from calibre.ebooks.BeautifulSoup import BeautifulSoup, Tag
|
||||||
|
|
||||||
class NewYorker(BasicNewsRecipe):
|
class NewYorker(BasicNewsRecipe):
|
||||||
|
title = 'The New Yorker'
|
||||||
title = u'The New Yorker'
|
|
||||||
__author__ = 'Darko Miletic'
|
__author__ = 'Darko Miletic'
|
||||||
description = 'The best of US journalism'
|
description = 'The best of US journalism'
|
||||||
oldest_article = 7
|
oldest_article = 7
|
||||||
language = _('English')
|
language = _('English')
|
||||||
max_articles_per_feed = 100
|
max_articles_per_feed = 100
|
||||||
no_stylesheets = False
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
extra_css = '''
|
publisher = 'Conde Nast Publications'
|
||||||
.calibre_feed_list {font-size:xx-small}
|
category = 'news, politics, USA'
|
||||||
.calibre_article_list {font-size:xx-small}
|
encoding = 'cp1252'
|
||||||
.calibre_feed_title {font-size:normal}
|
|
||||||
.calibre_recipe_title {font-size:normal}
|
|
||||||
.calibre_feed_description {font-size:xx-small}
|
|
||||||
'''
|
|
||||||
|
|
||||||
|
html2lrf_options = [
|
||||||
|
'--comment', description
|
||||||
|
, '--category', category
|
||||||
|
, '--publisher', publisher
|
||||||
|
]
|
||||||
|
|
||||||
keep_only_tags = [
|
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
||||||
dict(name='div' , attrs={'id':'printbody' })
|
|
||||||
]
|
keep_only_tags = [dict(name='div', attrs={'id':'printbody'})]
|
||||||
|
remove_tags_after = dict(name='div',attrs={'id':'articlebody'})
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name='div' , attrs={'class':'utils' })
|
dict(name='div', attrs={'class':['utils','articleRailLinks','icons'] })
|
||||||
,dict(name='div' , attrs={'id':'bottomFeatures' })
|
,dict(name='link')
|
||||||
,dict(name='div' , attrs={'id':'articleBottom' })
|
|
||||||
]
|
]
|
||||||
|
|
||||||
feeds = [
|
feeds = [(u'The New Yorker', u'http://feeds.newyorker.com/services/rss/feeds/everything.xml')]
|
||||||
(u'The New Yorker', u'http://feeds.newyorker.com/services/rss/feeds/everything.xml')
|
|
||||||
]
|
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
return url + '?printable=true'
|
return url + '?printable=true'
|
||||||
|
|
||||||
|
def get_article_url(self, article):
|
||||||
|
return article.get('guid', None)
|
||||||
|
|
||||||
def postprocess_html(self, soup, x):
|
def postprocess_html(self, soup, x):
|
||||||
body = soup.find('body')
|
body = soup.find('body')
|
||||||
if body:
|
if body:
|
||||||
html = soup.find('html')
|
html = soup.find('html')
|
||||||
if html:
|
if html:
|
||||||
body.extract()
|
body.extract()
|
||||||
html.insert(-1, body)
|
html.insert(2, body)
|
||||||
|
mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
|
||||||
|
soup.head.insert(1,mcharset)
|
||||||
return soup
|
return soup
|
||||||
|
Loading…
x
Reference in New Issue
Block a user