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

  1. #!/usr/bin/env  python
  2.  
  3. __license__   = 'GPL v3'
  4. __copyright__ = '2009, Darko Miletic <darko.miletic at gmail.com>'
  5. '''
  6. elargentino.com
  7. '''
  8.  
  9. from calibre.web.feeds.news import BasicNewsRecipe
  10. from calibre.ebooks.BeautifulSoup import Tag
  11.  
  12. class Veintitres(BasicNewsRecipe):
  13.     title                 = 'Veintitres'
  14.     __author__            = 'Darko Miletic'
  15.     description           = 'Revista Argentino dedicada a politica'
  16.     publisher             = 'Veintitres'
  17.     category              = 'news, politics, Argentina'
  18.     oldest_article        = 7
  19.     max_articles_per_feed = 100
  20.     no_stylesheets        = True
  21.     use_embedded_content  = False
  22.     encoding              = 'utf-8'
  23.     language = 'es_AR'
  24.  
  25.     lang                  = 'es-AR'
  26.     direction             = 'ltr'
  27.     INDEX                 = 'http://www.elargentino.com/medios/120/veintitres.html'
  28.     extra_css             = ' .titulo{font-size: x-large; font-weight: bold} .volantaImp{font-size: small; font-weight: bold} '
  29.  
  30.     html2lrf_options = [
  31.                           '--comment'  , description
  32.                         , '--category' , category
  33.                         , '--publisher', publisher
  34.                         ]
  35.  
  36.     html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0cm; margin-top: 0em; margin-bottom: 0.5em} "'
  37.  
  38.     keep_only_tags = [dict(name='div', attrs={'class':'ContainerPop'})]
  39.  
  40.     remove_tags = [dict(name='link')]
  41.  
  42.     feeds = [(u'Articulos', u'http://www.elargentino.com/Highlights.aspx?ParentType=Section&ParentId=120&Content-Type=text/xml&ChannelDesc=Veintitres')]
  43.  
  44.     def print_version(self, url):
  45.         main, sep, article_part = url.partition('/nota-')
  46.         article_id, rsep, rrest = article_part.partition('-')
  47.         return u'http://www.elargentino.com/Impresion.aspx?Id=' + article_id
  48.  
  49.     def preprocess_html(self, soup):
  50.         for item in soup.findAll(style=True):
  51.             del item['style']
  52.         soup.html['lang'] = self.lang
  53.         soup.html['dir' ] = self.direction
  54.         mlang = Tag(soup,'meta',[("http-equiv","Content-Language"),("content",self.lang)])
  55.         mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
  56.         soup.head.insert(0,mlang)
  57.         soup.head.insert(1,mcharset)
  58.         return soup
  59.  
  60.     def get_cover_url(self):
  61.         cover_url = None
  62.         soup = self.index_to_soup(self.INDEX)
  63.         cover_item = soup.find('div',attrs={'class':'colder'})
  64.         if cover_item:
  65.            clean_url = self.image_url_processor(None,cover_item.div.img['src'])
  66.            cover_url = 'http://www.elargentino.com' + clean_url + '&height=600'
  67.         return cover_url
  68.  
  69.     def image_url_processor(self, baseurl, url):
  70.         base, sep, rest = url.rpartition('?Id=')
  71.         img, sep2, rrest = rest.partition('&')
  72.         return base + sep + img
  73.