home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3945 < prev    next >
Encoding:
Text File  |  2010-04-18  |  3.0 KB  |  73 lines

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. nspm.rs
  5. '''
  6.  
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9. from calibre.ebooks.BeautifulSoup import Tag
  10.  
  11. class Nspm(BasicNewsRecipe):
  12.     title                 = 'Nova srpska politicka misao'
  13.     __author__            = 'Darko Miletic'
  14.     description           = 'Casopis za politicku teoriju i drustvena istrazivanja'
  15.     publisher             = 'NSPM'
  16.     category              = 'news, politics, Serbia'
  17.     oldest_article        = 2
  18.     max_articles_per_feed = 100
  19.     no_stylesheets        = True
  20.     use_embedded_content  = False
  21.     INDEX                 = 'http://www.nspm.rs/?alphabet=l'
  22.     encoding              = 'utf-8'
  23.     language              = 'sr'
  24.     publication_type      = 'magazine'    
  25.     masthead_url          = 'http://www.nspm.rs/templates/jsn_epic_pro/images/logol.jpg'
  26.     extra_css             = ' @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)} @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)} body{font-family: "Times New Roman", serif1, serif} .article_description{font-family: Arial, sans1, sans-serif} img{margin-top:0.5em; margin-bottom: 0.7em} .author{color: #990000; font-weight: bold} .author,.createdate{font-size: 0.9em} img{margin-top:0.5em; margin-bottom: 0.7em} '
  27.  
  28.     conversion_options = {
  29.                           'comment'   : description
  30.                         , 'tags'      : category
  31.                         , 'publisher' : publisher
  32.                         , 'language'  : language
  33.                         }
  34.  
  35.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  36.     remove_tags        = [
  37.                             dict(name=['link','object','embed','script','meta'])
  38.                            ,dict(name='td', attrs={'class':'buttonheading'})
  39.                          ]
  40.     keep_only_tags = [
  41.                          dict(attrs={'class':['contentpagetitle','author','createdate']})
  42.                         ,dict(name='p')                        
  43.                      ]
  44.     remove_attributes = ['width','height']
  45.  
  46.     def get_browser(self):
  47.         br = BasicNewsRecipe.get_browser()
  48.         br.open(self.INDEX)
  49.         return br
  50.  
  51.     feeds = [(u'Nova srpska politicka misao', u'http://www.nspm.rs/feed/rss.html')]
  52.  
  53.     def print_version(self, url):
  54.         return url.replace('.html','/stampa.html')
  55.  
  56.     def preprocess_html(self, soup):
  57.         for item in soup.body.findAll(style=True):
  58.             del item['style']
  59.         att = soup.find('a',attrs={'class':'contentpagetitle'})
  60.         if att:
  61.            att.name = 'h1';
  62.            del att['href']
  63.         att2 = soup.find('td')
  64.         if att2:
  65.            att2.name = 'p';
  66.            del att['valign']
  67.         for pt in soup.findAll('img'):
  68.             brtag = Tag(soup,'br')
  69.             brtag2 = Tag(soup,'br')
  70.             pt.append(brtag)
  71.             pt.append(brtag2)           
  72.         return soup
  73.