mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Fix #6794 (Updated recipes for Infobae and NSPM)
This commit is contained in:
parent
5ce924d10a
commit
80c976e0f2
@ -1,12 +1,8 @@
|
|||||||
#!/usr/bin/env python
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2008-2009, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
infobae.com
|
infobae.com
|
||||||
'''
|
'''
|
||||||
import re
|
|
||||||
import urllib, urlparse
|
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
|
||||||
@ -21,33 +17,22 @@ class Infobae(BasicNewsRecipe):
|
|||||||
no_stylesheets = True
|
no_stylesheets = True
|
||||||
use_embedded_content = False
|
use_embedded_content = False
|
||||||
language = 'es'
|
language = 'es'
|
||||||
lang = 'es-AR'
|
|
||||||
|
|
||||||
encoding = 'cp1252'
|
encoding = 'cp1252'
|
||||||
cover_url = 'http://www.infobae.com/imgs/header/header.gif'
|
masthead_url = 'http://www.infobae.com/imgs/header/header.gif'
|
||||||
remove_javascript = True
|
remove_javascript = True
|
||||||
preprocess_regexps = [(re.compile(
|
remove_empty_feeds = True
|
||||||
r'<meta name="Description" content="[^"]+">'), lambda m:'')]
|
|
||||||
|
|
||||||
|
|
||||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True'
|
|
||||||
|
|
||||||
extra_css = '''
|
extra_css = '''
|
||||||
.col-center{font-family:Arial,Helvetica,sans-serif;}
|
body{font-family:Arial,Helvetica,sans-serif;}
|
||||||
h1{font-family:Arial,Helvetica,sans-serif; color:#0D4261;}
|
.popUpTitulo{color:#0D4261; font-size: xx-large}
|
||||||
.fuenteIntNota{font-family:Arial,Helvetica,sans-serif; color:#1D1D1D; font-size:x-small;}
|
|
||||||
'''
|
'''
|
||||||
|
|
||||||
keep_only_tags = [dict(name='div', attrs={'class':['content']})]
|
conversion_options = {
|
||||||
|
'comment' : description
|
||||||
|
, 'tags' : category
|
||||||
remove_tags = [
|
, 'publisher' : publisher
|
||||||
dict(name='div', attrs={'class':['options','col-right','controles', 'bannerLibre','tiulo-masleidas','masleidas-h']}),
|
, 'language' : language
|
||||||
dict(name='a', attrs={'name' : 'comentario',}),
|
, 'linearize_tables' : True
|
||||||
dict(name='iframe'),
|
}
|
||||||
dict(name='img', alt = "Ver galerias de imagenes"),
|
|
||||||
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
@ -57,39 +42,14 @@ class Infobae(BasicNewsRecipe):
|
|||||||
,(u'Deportes' , u'http://www.infobae.com/adjuntos/html/RSS/deportes.xml' )
|
,(u'Deportes' , u'http://www.infobae.com/adjuntos/html/RSS/deportes.xml' )
|
||||||
]
|
]
|
||||||
|
|
||||||
# def print_version(self, url):
|
def print_version(self, url):
|
||||||
# main, sep, article_part = url.partition('contenidos/')
|
article_part = url.rpartition('/')[2]
|
||||||
# article_id, rsep, rrest = article_part.partition('-')
|
article_id= article_part.partition('-')[0]
|
||||||
# return u'http://www.infobae.com/notas/nota_imprimir.php?Idx=' + article_id
|
return 'http://www.infobae.com/notas/nota_imprimir.php?Idx=' + article_id
|
||||||
|
|
||||||
def get_article_url(self, article):
|
|
||||||
ans = article.get('link').encode('utf-8')
|
|
||||||
parts = list(urlparse.urlparse(ans))
|
|
||||||
parts[2] = urllib.quote(parts[2])
|
|
||||||
ans = urlparse.urlunparse(parts)
|
|
||||||
return ans.decode('utf-8')
|
|
||||||
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
|
||||||
|
|
||||||
for tag in soup.head.findAll('strong'):
|
|
||||||
tag.extract()
|
|
||||||
for tag in soup.findAll('meta'):
|
|
||||||
del tag['content']
|
|
||||||
tag.extract()
|
|
||||||
|
|
||||||
mtag = '<meta http-equiv="Content-Type" content="text/html; charset=iso-8859-1">\n<meta http-equiv="Content-Language" content="es-AR"/>\n'
|
|
||||||
soup.head.insert(0,mtag)
|
|
||||||
for item in soup.findAll(style=True):
|
|
||||||
del item['style']
|
|
||||||
|
|
||||||
return soup
|
|
||||||
|
|
||||||
def postprocess_html(self, soup, first):
|
def postprocess_html(self, soup, first):
|
||||||
|
|
||||||
for tag in soup.findAll(name='strong'):
|
for tag in soup.findAll(name='strong'):
|
||||||
tag.name = 'b'
|
tag.name = 'b'
|
||||||
|
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
|
||||||
|
@ -6,6 +6,7 @@ nspm.rs
|
|||||||
|
|
||||||
import re
|
import re
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
from calibre.web.feeds.news import BasicNewsRecipe
|
||||||
|
from calibre.ebooks.BeautifulSoup import Tag, NavigableString
|
||||||
|
|
||||||
class Nspm(BasicNewsRecipe):
|
class Nspm(BasicNewsRecipe):
|
||||||
title = 'Nova srpska politicka misao'
|
title = 'Nova srpska politicka misao'
|
||||||
@ -21,6 +22,7 @@ class Nspm(BasicNewsRecipe):
|
|||||||
encoding = 'utf-8'
|
encoding = 'utf-8'
|
||||||
language = 'sr'
|
language = 'sr'
|
||||||
delay = 2
|
delay = 2
|
||||||
|
remove_empty_feeds = True
|
||||||
publication_type = 'magazine'
|
publication_type = 'magazine'
|
||||||
masthead_url = 'http://www.nspm.rs/templates/jsn_epic_pro/images/logol.jpg'
|
masthead_url = 'http://www.nspm.rs/templates/jsn_epic_pro/images/logol.jpg'
|
||||||
extra_css = """ @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
|
extra_css = """ @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
|
||||||
@ -45,6 +47,7 @@ class Nspm(BasicNewsRecipe):
|
|||||||
dict(name=['link','object','embed','script','meta','base','iframe'])
|
dict(name=['link','object','embed','script','meta','base','iframe'])
|
||||||
,dict(attrs={'class':'buttonheading'})
|
,dict(attrs={'class':'buttonheading'})
|
||||||
]
|
]
|
||||||
|
remove_tags_before = dict(attrs={'class':'contentheading'})
|
||||||
remove_tags_after = dict(attrs={'class':'article_separator'})
|
remove_tags_after = dict(attrs={'class':'article_separator'})
|
||||||
remove_attributes = ['width','height']
|
remove_attributes = ['width','height']
|
||||||
|
|
||||||
@ -67,4 +70,8 @@ class Nspm(BasicNewsRecipe):
|
|||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for item in soup.body.findAll(style=True):
|
for item in soup.body.findAll(style=True):
|
||||||
del item['style']
|
del item['style']
|
||||||
|
for item in soup.body.findAll('h1'):
|
||||||
|
nh = NavigableString(item.a.string)
|
||||||
|
item.a.extract()
|
||||||
|
item.insert(0,nh)
|
||||||
return self.adeify_images(soup)
|
return self.adeify_images(soup)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user