mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Update Japan Times. Fixes #1112656 (Updated recipe for Japan Times)
This commit is contained in:
parent
fdf2947314
commit
276b1699f4
@ -1,5 +1,5 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008-2011, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2008-2013, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
japantimes.co.jp
|
japantimes.co.jp
|
||||||
'''
|
'''
|
||||||
@ -13,59 +13,41 @@ class JapanTimes(BasicNewsRecipe):
|
|||||||
language = 'en_JP'
|
language = 'en_JP'
|
||||||
category = 'news, politics, japan'
|
category = 'news, politics, japan'
|
||||||
publisher = 'The Japan Times'
|
publisher = 'The Japan Times'
|
||||||
oldest_article = 5
|
oldest_article = 2
|
||||||
max_articles_per_feed = 150
|
max_articles_per_feed = 150
|
||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
encoding = 'utf8'
|
encoding = 'utf8'
|
||||||
publication_type = 'newspaper'
|
publication_type = 'newspaper'
|
||||||
masthead_url = 'http://search.japantimes.co.jp/images/header_title.gif'
|
masthead_url = 'http://www.japantimes.co.jp/wp-content/themes/jt_theme/library/img/logo-japan-times.png'
|
||||||
extra_css = 'body{font-family: Geneva,Arial,Helvetica,sans-serif}'
|
extra_css = 'body{font-family: Geneva,Arial,Helvetica,sans-serif}'
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'comment' : description
|
'comment' : description
|
||||||
, 'tags' : category
|
, 'tags' : category
|
||||||
, 'publisher' : publisher
|
, 'publisher' : publisher
|
||||||
, 'language' : language
|
, 'language' : language
|
||||||
, 'linearize_tables' : True
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
remove_tags_after = dict(name='div', attrs={'class':'entry'})
|
||||||
keep_only_tags = [dict(name='div', attrs={'id':'printresult'})]
|
keep_only_tags = [dict(name='div', attrs={'class':'padding_block'})]
|
||||||
remove_tags = [
|
remove_tags = [
|
||||||
dict(name=['iframe','meta','link','embed','object','base'])
|
dict(name=['iframe','embed','object','base'])
|
||||||
,dict(attrs={'id':'searchfooter'})
|
,dict(attrs={'class':['meta_extras','related_articles']})
|
||||||
]
|
,dict(attrs={'id':'content_footer_menu'})
|
||||||
feeds = [(u'The Japan Times', u'http://feeds.feedburner.com/japantimes')]
|
]
|
||||||
remove_attributes = ['border']
|
feeds = [
|
||||||
|
(u'News' , u'http://www.japantimes.co.jp/news/feed/' )
|
||||||
|
,(u'Opinion' , u'http://www.japantimes.co.jp/opinion/feed/' )
|
||||||
|
,(u'Life' , u'http://www.japantimes.co.jp/opinion/feed/' )
|
||||||
|
,(u'Community', u'http://www.japantimes.co.jp/community/feed/')
|
||||||
|
,(u'Culture' , u'http://www.japantimes.co.jp/culture/feed/' )
|
||||||
|
,(u'Sports' , u'http://www.japantimes.co.jp/sports/feed/' )
|
||||||
|
]
|
||||||
|
|
||||||
def get_article_url(self, article):
|
def get_article_url(self, article):
|
||||||
rurl = BasicNewsRecipe.get_article_url(self, article)
|
rurl = BasicNewsRecipe.get_article_url(self, article)
|
||||||
return rurl.partition('?')[0]
|
return rurl.partition('?')[0]
|
||||||
|
|
||||||
def print_version(self, url):
|
def preprocess_raw_html(self, raw, url):
|
||||||
if '/rss/' in url:
|
return '<html><head>'+raw[raw.find('</head>'):]
|
||||||
return url.replace('.jp/rss/','.jp/print/')
|
|
||||||
if '/text/' in url:
|
|
||||||
return url.replace('.jp/text/','.jp/print/')
|
|
||||||
return url
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
|
||||||
for item in soup.findAll(style=True):
|
|
||||||
del item['style']
|
|
||||||
for item in soup.findAll('img'):
|
|
||||||
if not item.has_key('alt'):
|
|
||||||
item['alt'] = 'image'
|
|
||||||
for item in soup.findAll('photo'):
|
|
||||||
item.name = 'div'
|
|
||||||
for item in soup.head.findAll('paragraph'):
|
|
||||||
item.extract()
|
|
||||||
for item in soup.findAll('wwfilename'):
|
|
||||||
item.extract()
|
|
||||||
for item in soup.findAll('jtcategory'):
|
|
||||||
item.extract()
|
|
||||||
for item in soup.findAll('nomooter'):
|
|
||||||
item.extract()
|
|
||||||
for item in soup.body.findAll('paragraph'):
|
|
||||||
item.name = 'p'
|
|
||||||
return soup
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user