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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. lamujerdemivida.com.ar
  7. '''
  8. from calibre import strftime
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10.  
  11. class LaMujerDeMiVida(BasicNewsRecipe):
  12.     title                 = 'La Mujer de mi Vida'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'Cultura de otra manera'
  15.     oldest_article        = 90
  16.     max_articles_per_feed = 100
  17.     no_stylesheets        = True
  18.     use_embedded_content  = False
  19.     encoding              = 'cp1252'
  20.     publisher             = 'La Mujer de mi Vida'
  21.     category              = 'literatura, critica, arte, ensayos'
  22.     language = 'es_AR'
  23.  
  24.     INDEX                 = 'http://www.lamujerdemivida.com.ar/'
  25.     html2lrf_options = [
  26.                           '--comment', description
  27.                         , '--category', category
  28.                         , '--publisher', publisher
  29.                         , '--ignore-tables'
  30.                         ]
  31.  
  32.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\nlinearize_tables=True'
  33.  
  34.     keep_only_tags = [dict(name='table', attrs={'width':'570'})]
  35.  
  36.     feeds = [(u'Articulos', u'http://www.lamujerdemivida.com.ar/index.php')]
  37.  
  38.     def preprocess_html(self, soup):
  39.         soup.html['xml:lang'] = 'es-AR'
  40.         soup.html['lang']     = 'es-AR'
  41.         mtag = '<meta http-equiv="Content-Language" content="es-AR"/>'
  42.         soup.head.insert(0,mtag)
  43.         for item in soup.findAll(style=True):
  44.             del item['style']
  45.         return soup
  46.  
  47.     def get_cover_url(self):
  48.         cover_url = None
  49.         soup = self.index_to_soup(self.INDEX)
  50.         cover_item = soup.find('img',attrs={'alt':'Lamujerdemivida.'})
  51.         if cover_item:
  52.            cover_url = self.INDEX + cover_item['src']
  53.         return cover_url
  54.  
  55.     def parse_index(self):
  56.         totalfeeds = []
  57.         lfeeds = self.get_feeds()
  58.         for feedobj in lfeeds:
  59.             feedtitle, feedurl = feedobj
  60.             self.report_progress(0, _('Fetching feed')+' %s...'%(feedtitle if feedtitle else feedurl))
  61.             articles = []
  62.             soup = self.index_to_soup(feedurl)
  63.             for item in soup.findAll('td', attrs={'width':'390'}):
  64.                 atag = item.find('a',href=True)
  65.                 if atag:
  66.                     url         = atag['href']
  67.                     title       = self.tag_to_string(atag)
  68.                     date        = strftime(self.timefmt)
  69.                     articles.append({
  70.                                       'title'      :title
  71.                                      ,'date'       :date
  72.                                      ,'url'        :url
  73.                                      ,'description':''
  74.                                     })
  75.             totalfeeds.append((feedtitle, articles))
  76.         return totalfeeds
  77.  
  78.