home *** CD-ROM | disk | FTP | other *** search
/ Chip 2011 November / CHIP_2011_11.iso / Programy / Narzedzia / Calibre / calibre-0.8.18.msi / file_280 / la_jornada.recipe < prev    next >
Text File  |  2011-09-09  |  5KB  |  92 lines

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>, Rogelio Dom├¡nguez <rogelio.dominguez@gmail.com>'
  3. '''
  4. www.jornada.unam.mx
  5. '''
  6.  
  7. import re
  8. from calibre import strftime
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class LaJornada_mx(BasicNewsRecipe):
  12.     title                 = 'La Jornada (Mexico)'
  13.     __author__            = 'Darko Miletic/Rogelio Dom├¡nguez'
  14.     description           = 'Noticias del diario mexicano La Jornada'
  15.     publisher             = 'DEMOS, Desarrollo de Medios, S.A. de C.V.'
  16.     category              = 'news, Mexico'
  17.     oldest_article        = 2
  18.     max_articles_per_feed = 200
  19.     no_stylesheets        = True
  20.     encoding              = 'utf8'
  21.     use_embedded_content  = False
  22.     language              = 'es_MX'
  23.     remove_empty_feeds    = True
  24.     cover_url             = strftime("http://www.jornada.unam.mx/%Y/%m/%d/portada.pdf")
  25.     masthead_url          = 'http://www.jornada.unam.mx/v7.0/imagenes/la-jornada-trans.png'
  26.     publication_type      = 'newspaper'
  27.     extra_css             = """
  28.                                 body{font-family: "Times New Roman",serif }
  29.                                 .cabeza{font-size: xx-large; font-weight: bold }
  30.                                 .documentFirstHeading{font-size: xx-large; font-weight: bold }
  31.                                 .credito-articulo{font-variant: small-caps; font-weight: bold }
  32.                                 .foto{text-align: center}
  33.                                 .pie-foto{font-size: 0.9em}
  34.                                 .credito{font-weight: bold; margin-left: 1em}
  35.                                 .credito-autor{font-variant: small-caps; font-weight: bold }
  36.                                 .credito-titulo{text-align: right}
  37.                                 .hemero{text-align: right; font-size: 0.9em; margin-bottom: 0.5em }
  38.                                 .loc{font-weight: bold}
  39.                                 .carton{text-align: center}
  40.                                 .credit{font-weight: bold}
  41.                                 .sumario{font-weight: bold; text-align: center}
  42.                                 .text{margin-top: 1.4em}
  43.                                 p.inicial{display: inline; font-size: xx-large; font-weight: bold}
  44.                                 p.s-s{display: inline; text-indent: 0}
  45.                             """
  46.  
  47.     conversion_options = {
  48.                           'comment'   : description
  49.                         , 'tags'      : category
  50.                         , 'publisher' : publisher
  51.                         , 'language'  : language
  52.                         }
  53.  
  54.     preprocess_regexps = [
  55.                           (re.compile(  r'<div class="inicial">(.*)</div><p class="s-s">'
  56.                                        ,re.DOTALL|re.IGNORECASE)
  57.                                        ,lambda match: '<p class="inicial">' + match.group(1) + '</p><p class="s-s">')
  58.                          ]
  59.  
  60.     keep_only_tags = [
  61.                          dict(name='div', attrs={'class':['documentContent','cabeza','sumarios','credito-articulo','text','carton']})
  62.                         ,dict(name='div', attrs={'id':'renderComments'})
  63.                      ]
  64.     remove_tags = [dict(name='div', attrs={'class':['buttonbar','comment-cont']})]
  65.  
  66.     feeds = [
  67.               (u'Opinion'             , u'http://www.jornada.unam.mx/rss/opinion.xml'      )
  68.              ,(u'Cartones'            , u'http://www.jornada.unam.mx/rss/cartones.xml'     )
  69.              ,(u'Politica'            , u'http://www.jornada.unam.mx/rss/politica.xml'     )
  70.              ,(u'Economia'            , u'http://www.jornada.unam.mx/rss/economia.xml'     )
  71.              ,(u'Mundo'               , u'http://www.jornada.unam.mx/rss/mundo.xml'        )
  72.              ,(u'Estados'             , u'http://www.jornada.unam.mx/rss/estados.xml'      )
  73.              ,(u'Capital'             , u'http://www.jornada.unam.mx/rss/capital.xml'      )
  74.              ,(u'Sociedad y justicia' , u'http://www.jornada.unam.mx/rss/sociedad.xml'     )
  75.              ,(u'Ciencias'            , u'http://www.jornada.unam.mx/rss/ciencias.xml'     )
  76.              ,(u'Cultura'             , u'http://www.jornada.unam.mx/rss/cultura.xml'      )
  77.              ,(u'Gastronomia'         , u'http://www.jornada.unam.mx/rss/gastronomia.xml'  )
  78.              ,(u'Espectaculos'        , u'http://www.jornada.unam.mx/rss/espectaculos.xml' )
  79.              ,(u'Deportes'            , u'http://www.jornada.unam.mx/rss/deportes.xml'     )
  80.              ,(u'Ultimas noticias'    , u'http://www.jornada.unam.mx/ultimas/news/RSS'     )
  81.             ]
  82.  
  83.     def preprocess_html(self, soup):
  84.         for item in soup.findAll(style=True):
  85.             del item['style']
  86.         return soup
  87.  
  88.     def get_article_url(self, article):
  89.         rurl = article.get('link',  None)
  90.         return rurl.rpartition('&partner=')[0]
  91.  
  92.