mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-07-09 03:04:10 -04:00
Merge from trunk
This commit is contained in:
commit
01b4701253
BIN
resources/images/news/zerohedge.png
Normal file
BIN
resources/images/news/zerohedge.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 3.0 KiB |
@ -1,59 +1,79 @@
|
|||||||
#!/usr/bin/env python
|
#!/usr/bin/env python
|
||||||
# -*- coding: utf-8 -*-
|
|
||||||
|
|
||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
|
__author__ = 'Gerardo Diez'
|
||||||
'''
|
__copyright__ = 'Gerardo Diez<gerardo.diez.garcia@gmail.com>'
|
||||||
www.expansion.com
|
description = 'Main daily newspaper from Spain - v1.00 (05, Enero 2011)'
|
||||||
'''
|
__docformat__ = 'restructuredtext en'
|
||||||
|
|
||||||
from calibre.web.feeds.news import BasicNewsRecipe
|
'''
|
||||||
from calibre.ebooks.BeautifulSoup import Tag
|
expansion.es
|
||||||
|
'''
|
||||||
class Expansion(BasicNewsRecipe):
|
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||||
title = 'Diario Expansion'
|
class Publico(BasicNewsRecipe):
|
||||||
__author__ = 'Darko Miletic'
|
title =u'Expansion.com'
|
||||||
description = 'Lider de informacion de mercados, economica y politica'
|
__author__ ='Gerardo Diez'
|
||||||
publisher = 'expansion.com'
|
publisher =u'Unidad Editorial Información Económica, S.L.'
|
||||||
category = 'news, politics, Spain'
|
category ='finances, catalunya'
|
||||||
oldest_article = 2
|
oldest_article =1
|
||||||
max_articles_per_feed =100
|
max_articles_per_feed =100
|
||||||
no_stylesheets = True
|
simultaneous_downloads =10
|
||||||
use_embedded_content = False
|
cover_url =u'http://estaticos01.expansion.com/iconos/v2.x/v2.0/cabeceras/logo_expansion.png'
|
||||||
delay = 1
|
timefmt ='[%A, %d %B, %Y]'
|
||||||
encoding = 'iso-8859-15'
|
encoding ='latin'
|
||||||
language ='es'
|
language ='es'
|
||||||
|
remove_javascript =True
|
||||||
direction = 'ltr'
|
no_stylesheets =True
|
||||||
|
keep_only_tags =dict(name='div', attrs={'class':['noticia primer_elemento']})
|
||||||
html2lrf_options = [
|
|
||||||
'--comment' , description
|
|
||||||
, '--category' , category
|
|
||||||
, '--publisher', publisher
|
|
||||||
]
|
|
||||||
|
|
||||||
html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"'
|
|
||||||
|
|
||||||
feeds = [
|
|
||||||
(u'Ultimas noticias', u'http://rss.expansion.com/rss/descarga.htm?data2=178')
|
|
||||||
,(u'Temas del dia' , u'http://rss.expansion.com/rss/descarga.htm?data2=178')
|
|
||||||
]
|
|
||||||
|
|
||||||
|
|
||||||
keep_only_tags = [dict(name='div', attrs={'id':'principal'})]
|
|
||||||
|
|
||||||
remove_tags =[
|
remove_tags =[
|
||||||
dict(name=['object','link','script'])
|
dict(name='div', attrs={'class':['compartir', 'metadata_desarrollo_noticia', 'relacionadas', 'mas_info','publicidad publicidad_textlink', 'ampliarfoto']}),
|
||||||
,dict(name='div', attrs={'class':['utilidades','tit_relacionadas']})
|
dict(name='ul', attrs={'class':['bolos_desarrollo_noticia']}),
|
||||||
|
dict(name='span', attrs={'class':['comentarios']}),
|
||||||
|
dict(name='p', attrs={'class':['cintillo_comentarios', 'cintillo_comentarios formulario']}),
|
||||||
|
dict(name='div', attrs={'id':['comentarios_lectores_listado']})
|
||||||
|
]
|
||||||
|
feeds =[
|
||||||
|
(u'Portada', u'http://estaticos.expansion.com/rss/portada.xml'),
|
||||||
|
(u'Portada: Bolsas', u'http://estaticos.expansion.com/rss/mercados.xml'),
|
||||||
|
(u'Divisas', u'http://estaticos.expansion.com/rss/mercadosdivisas.xml'),
|
||||||
|
(u'Euribor', u'http://estaticos.expansion.com/rss/mercadoseuribor.xml'),
|
||||||
|
(u'Materias Primas', u'http://estaticos.expansion.com/rss/mercadosmateriasprimas.xml'),
|
||||||
|
(u'Renta Fija', u'http://estaticos.expansion.com/rss/mercadosrentafija.xml'),
|
||||||
|
|
||||||
|
(u'Portada: Mi Dinero', u'http://estaticos.expansion.com/rss/midinero.xml'),
|
||||||
|
(u'Hipotecas', u'http://estaticos.expansion.com/rss/midinerohipotecas.xml'),
|
||||||
|
(u'Créditos', u'http://estaticos.expansion.com/rss/midinerocreditos.xml'),
|
||||||
|
(u'Pensiones', u'http://estaticos.expansion.com/rss/midineropensiones.xml'),
|
||||||
|
(u'Fondos de Inversión', u'http://estaticos.expansion.com/rss/midinerofondos.xml'),
|
||||||
|
(u'Motor', u'http://estaticos.expansion.com/rss/midineromotor.xml'),
|
||||||
|
|
||||||
|
(u'Portada: Empresas', u'http://estaticos.expansion.com/rss/empresas.xml'),
|
||||||
|
(u'Banca', u'http://estaticos.expansion.com/rss/empresasbanca.xml'),
|
||||||
|
(u'TMT', u'http://estaticos.expansion.com/rss/empresastmt.xml'),
|
||||||
|
(u'Energía', u'http://estaticos.expansion.com/rss/empresasenergia.xml'),
|
||||||
|
(u'Inmobiliario y Construcción', u'http://estaticos.expansion.com/rss/empresasinmobiliario.xml'),
|
||||||
|
(u'Transporte y Turismo', u'http://estaticos.expansion.com/rss/empresastransporte.xml'),
|
||||||
|
(u'Automoción e Industria', u'http://estaticos.expansion.com/rss/empresasauto-industria.xml'),
|
||||||
|
(u'Distribución', u'http://estaticos.expansion.com/rss/empresasdistribucion.xml'),
|
||||||
|
(u'Deporte y Negocio', u' http://estaticos.expansion.com/rss/empresasdeporte.xml'),
|
||||||
|
(u'Mi Negocio', u'http://estaticos.expansion.com/rss/empresasminegocio.xml'),
|
||||||
|
(u'Interiores', u'http://estaticos.expansion.com/rss/empresasinteriores.xml'),
|
||||||
|
(u'Digitech', u'http://estaticos.expansion.com/rss/empresasdigitech.xml'),
|
||||||
|
|
||||||
|
(u'Portada: Economía y Política', u'http://estaticos.expansion.com/rss/economiapolitica.xml'),
|
||||||
|
(u'Política', u'http://estaticos.expansion.com/rss/economia.xml'),
|
||||||
|
(u'Portada: Sociedad', u'http://estaticos.expansion.com/rss/entorno.xml'),
|
||||||
|
|
||||||
|
(u'Portada: Opinión', u'http://estaticos.expansion.com/rss/opinion.xml'),
|
||||||
|
(u'Llaves y editoriales', u'http://estaticos.expansion.com/rss/opinioneditorialyllaves.xml'),
|
||||||
|
(u'Tribunas', u'http://estaticos.expansion.com/rss/opiniontribunas.xml'),
|
||||||
|
|
||||||
|
(u'Portada: Jurídico', u'http://estaticos.expansion.com/rss/juridico.xml'),
|
||||||
|
(u'Entrevistas', u'http://estaticos.expansion.com/rss/juridicoentrevistas.xml'),
|
||||||
|
(u'Opinión', u'http://estaticos.expansion.com/rss/juridicoopinion.xml'),
|
||||||
|
(u'Sentencias', u'http://estaticos.expansion.com/rss/juridicosentencias.xml'),
|
||||||
|
|
||||||
|
(u'Mujer', u'http://estaticos.expansion.com/rss/mujer-empresa.xml'),
|
||||||
|
(u'Cataluña', u'http://estaticos.expansion.com/rss/catalunya.xml'),
|
||||||
|
(u'Función pública', u'http://estaticos.expansion.com/rss/funcion-publica.xml')
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_tags_after = [dict(name='div', attrs={'class':'tit_relacionadas'})]
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
|
||||||
soup.html['dir' ] = self.direction
|
|
||||||
mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
|
|
||||||
soup.head.insert(0,mcharset)
|
|
||||||
for item in soup.findAll(style=True):
|
|
||||||
del item['style']
|
|
||||||
return soup
|
|
||||||
|
|
||||||
|
@ -1,5 +1,5 @@
|
|||||||
__license__ = 'GPL v3'
|
__license__ = 'GPL v3'
|
||||||
__copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
|
__copyright__ = '2010-2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
'''
|
'''
|
||||||
msnbc.msn.com
|
msnbc.msn.com
|
||||||
'''
|
'''
|
||||||
@ -19,7 +19,16 @@ class MsNBC(BasicNewsRecipe):
|
|||||||
publisher = 'msnbc.com'
|
publisher = 'msnbc.com'
|
||||||
category = 'news, USA, world'
|
category = 'news, USA, world'
|
||||||
language = 'en'
|
language = 'en'
|
||||||
extra_css = ' body{ font-family: sans-serif } .head{font-family: serif; font-size: xx-large; font-weight: bold; color: #CC0000} .abstract{font-weight: bold} .source{font-size: small} .updateTime{font-size: small} '
|
extra_css = """
|
||||||
|
body{ font-family: Georgia,Times,serif }
|
||||||
|
.hide{display: none}
|
||||||
|
.caption{font-family: Arial,sans-serif; font-size: x-small}
|
||||||
|
.entry-summary{font-family: Arial,sans-serif}
|
||||||
|
.copyright{font-size: 0.95em; font-style: italic}
|
||||||
|
.source-org{font-size: small; font-family: Arial,sans-serif}
|
||||||
|
img{display: block; margin-bottom: 0.5em}
|
||||||
|
span.byline{display: none}
|
||||||
|
"""
|
||||||
|
|
||||||
conversion_options = {
|
conversion_options = {
|
||||||
'comments' : description
|
'comments' : description
|
||||||
@ -28,14 +37,20 @@ class MsNBC(BasicNewsRecipe):
|
|||||||
,'publisher': publisher
|
,'publisher': publisher
|
||||||
}
|
}
|
||||||
|
|
||||||
preprocess_regexps = [
|
remove_tags_before = dict(name='h1', attrs={'id':'headline'})
|
||||||
(re.compile(r'</style></head>', re.DOTALL|re.IGNORECASE),lambda match: '</style>')
|
remove_tags_after = dict(name='span', attrs={'class':['copyright','Linear copyright']})
|
||||||
,(re.compile(r'<div class="head">', re.DOTALL|re.IGNORECASE),lambda match: '</head><body><div class="head">'),
|
keep_only_tags=[
|
||||||
|
dict(attrs={'id':['headline','deck','byline','source','intelliTXT']})
|
||||||
|
,dict(attrs={'class':['gl_headline','articleText','drawer-content Linear','v-center3','byline','textBodyBlack']})
|
||||||
|
]
|
||||||
|
remove_attributes=['property','lang','rel','xmlns:fb','xmlns:v','xmlns:dc','xmlns:dcmitype','xmlns:og','xmlns:media','xmlns:vcard','typeof','itemscope','itemtype','itemprop','about','type','size','width','height','onreadystatechange','data','border','hspace','vspace']
|
||||||
|
|
||||||
|
remove_tags = [
|
||||||
|
dict(name=['iframe','object','link','embed','meta','table'])
|
||||||
|
,dict(name='span', attrs={'class':['copyright','Linear copyright']})
|
||||||
|
,dict(name='div', attrs={'class':'social'})
|
||||||
]
|
]
|
||||||
|
|
||||||
remove_tags_before = dict(name='div', attrs={'class':'head'})
|
|
||||||
remove_tags_after = dict(name='div', attrs={'class':'copyright'})
|
|
||||||
remove_tags = [dict(name=['iframe','object','link','script','form'])]
|
|
||||||
|
|
||||||
feeds = [
|
feeds = [
|
||||||
(u'US News' , u'http://rss.msnbc.msn.com/id/3032524/device/rss/rss.xml' )
|
(u'US News' , u'http://rss.msnbc.msn.com/id/3032524/device/rss/rss.xml' )
|
||||||
@ -48,11 +63,26 @@ class MsNBC(BasicNewsRecipe):
|
|||||||
,(u'Tech & Science', u'http://rss.msnbc.msn.com/id/3032117/device/rss/rss.xml' )
|
,(u'Tech & Science', u'http://rss.msnbc.msn.com/id/3032117/device/rss/rss.xml' )
|
||||||
]
|
]
|
||||||
|
|
||||||
def print_version(self, url):
|
|
||||||
return url + 'print/1/displaymode/1098/'
|
|
||||||
|
|
||||||
def preprocess_html(self, soup):
|
def preprocess_html(self, soup):
|
||||||
for item in soup.head.findAll('div'):
|
for item in soup.body.findAll('html'):
|
||||||
|
item.name='div'
|
||||||
|
for item in soup.body.findAll('div'):
|
||||||
|
if item.has_key('id') and item['id'].startswith('vine-'):
|
||||||
item.extract()
|
item.extract()
|
||||||
|
if item.has_key('class') and ( item['class'].startswith('ad') or item['class'].startswith('vine')):
|
||||||
|
item.extract()
|
||||||
|
for item in soup.body.findAll('img'):
|
||||||
|
if not item.has_key('alt'):
|
||||||
|
item['alt'] = 'image'
|
||||||
|
for item in soup.body.findAll('ol'):
|
||||||
|
if item.has_key('class') and item['class'].startswith('grid'):
|
||||||
|
item.extract()
|
||||||
|
for item in soup.body.findAll('span'):
|
||||||
|
if ( item.has_key('id') and item['id'].startswith('byLine') and item.string is None) or ( item.has_key('class') and item['class'].startswith('inline') ):
|
||||||
|
item.extract()
|
||||||
|
for alink in soup.findAll('a'):
|
||||||
|
if alink.string is not None:
|
||||||
|
tstr = alink.string
|
||||||
|
alink.replaceWith(tstr)
|
||||||
return soup
|
return soup
|
||||||
|
|
||||||
|
@ -35,7 +35,6 @@ class TechnologyReview(BasicNewsRecipe):
|
|||||||
def get_article_url(self, article):
|
def get_article_url(self, article):
|
||||||
return article.get('guid', article.get('id', None))
|
return article.get('guid', article.get('id', None))
|
||||||
|
|
||||||
|
|
||||||
def print_version(self, url):
|
def print_version(self, url):
|
||||||
baseurl='http://www.technologyreview.com/printer_friendly_article.aspx?id='
|
baseurl='http://www.technologyreview.com/printer_friendly_article.aspx?id='
|
||||||
split1 = string.split(url,"/")
|
split1 = string.split(url,"/")
|
||||||
@ -43,3 +42,25 @@ class TechnologyReview(BasicNewsRecipe):
|
|||||||
split2= string.split(xxx,"/")
|
split2= string.split(xxx,"/")
|
||||||
s = baseurl + split2[0]
|
s = baseurl + split2[0]
|
||||||
return s
|
return s
|
||||||
|
|
||||||
|
|
||||||
|
def postprocess_html(self,soup, True):
|
||||||
|
#remove picture
|
||||||
|
headerhtml = soup.find(True, {'class':'header'})
|
||||||
|
headerhtml.replaceWith("")
|
||||||
|
|
||||||
|
#remove close button
|
||||||
|
closehtml = soup.find(True, {'class':'close'})
|
||||||
|
closehtml.replaceWith("")
|
||||||
|
|
||||||
|
#remove banner advertisement
|
||||||
|
bannerhtml = soup.find(True, {'class':'bannerad'})
|
||||||
|
bannerhtml.replaceWith("")
|
||||||
|
|
||||||
|
#thanks kiklop74! This code removes all links from the text
|
||||||
|
for alink in soup.findAll('a'):
|
||||||
|
if alink.string is not None:
|
||||||
|
tstr = alink.string
|
||||||
|
alink.replaceWith(tstr)
|
||||||
|
|
||||||
|
return soup
|
||||||
|
33
resources/recipes/zerohedge.recipe
Normal file
33
resources/recipes/zerohedge.recipe
Normal file
@ -0,0 +1,33 @@
|
|||||||
|
__license__ = 'GPL v3'
|
||||||
|
__copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
|
||||||
|
'''
|
||||||
|
www.zerohedge.com
|
||||||
|
'''
|
||||||
|
|
||||||
|
from calibre.web.feeds.recipes import BasicNewsRecipe
|
||||||
|
|
||||||
|
class ZeroHedge(BasicNewsRecipe):
|
||||||
|
title = 'Zero Hedge'
|
||||||
|
__author__ = 'Darko Miletic'
|
||||||
|
description = 'On a long enough timeline the survival rate for everyone drops to zero'
|
||||||
|
oldest_article = 10
|
||||||
|
max_articles_per_feed = 100
|
||||||
|
no_stylesheets = True
|
||||||
|
use_embedded_content = True
|
||||||
|
encoding = 'utf8'
|
||||||
|
publisher = 'zero hedge'
|
||||||
|
category = 'news, USA, world, economy, politics'
|
||||||
|
language = 'en'
|
||||||
|
masthead_url = 'http://www.zerohedge.com/themes/newsflash/logo.png'
|
||||||
|
publication_type = 'blog'
|
||||||
|
extra_css = 'body{ font-family: sans-serif }'
|
||||||
|
|
||||||
|
conversion_options = {
|
||||||
|
'comments' : description
|
||||||
|
,'tags' : category
|
||||||
|
,'language' : language
|
||||||
|
,'publisher': publisher
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
feeds = [(u'Articles', u'http://feeds.feedburner.com/zerohedge/feed')]
|
@ -195,7 +195,9 @@ class SearchBar(QWidget): # {{{
|
|||||||
x.setToolTip(_("Reset Quick Search"))
|
x.setToolTip(_("Reset Quick Search"))
|
||||||
|
|
||||||
x = parent.search_highlight_only = QCheckBox()
|
x = parent.search_highlight_only = QCheckBox()
|
||||||
x.setText(_('Highlight'))
|
x.setText(_('&Highlight'))
|
||||||
|
x.setToolTip(_('Highlight matched books in the book list, instead '
|
||||||
|
'of restricting the book list to the matches.'))
|
||||||
l.addWidget(x)
|
l.addWidget(x)
|
||||||
|
|
||||||
x = parent.saved_search = SavedSearchBox(self)
|
x = parent.saved_search = SavedSearchBox(self)
|
||||||
|
@ -1524,17 +1524,17 @@ class EPUB_MOBI(CatalogPlugin):
|
|||||||
this_title['formats'] = formats
|
this_title['formats'] = formats
|
||||||
|
|
||||||
# Add user notes to be displayed in header
|
# Add user notes to be displayed in header
|
||||||
# Special case handling for datetime fields
|
# Special case handling for datetime fields and lists
|
||||||
if self.opts.header_note_source_field:
|
if self.opts.header_note_source_field:
|
||||||
field_md = self.__db.metadata_for_field(self.opts.header_note_source_field)
|
field_md = self.__db.metadata_for_field(self.opts.header_note_source_field)
|
||||||
notes = self.__db.get_field(record['id'],
|
notes = self.__db.get_field(record['id'],
|
||||||
self.opts.header_note_source_field,
|
self.opts.header_note_source_field,
|
||||||
index_is_id=True)
|
index_is_id=True)
|
||||||
if notes and field_md['datatype'] == 'datetime':
|
|
||||||
# Reformat date fields to match UI presentation: dd MMM YYYY
|
|
||||||
notes = format_date(notes,'dd MMM yyyy')
|
|
||||||
|
|
||||||
if notes:
|
if notes:
|
||||||
|
if field_md['datatype'] == 'text' and isinstance(notes,list):
|
||||||
|
notes = ' · '.join(notes)
|
||||||
|
elif field_md['datatype'] == 'datetime':
|
||||||
|
notes = format_date(notes,'dd MMM yyyy')
|
||||||
this_title['notes'] = {'source':field_md['name'],
|
this_title['notes'] = {'source':field_md['name'],
|
||||||
'content':notes}
|
'content':notes}
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user