home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2011 January / maximum-cd-2011-01.iso / DiscContents / calibre-0.7.26.msi / file_4232 < prev    next >
Encoding:
Text File  |  2010-09-30  |  3.5 KB  |  78 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 NavigableString
  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        = 7
  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.     delay                 = 2
  25.     remove_empty_feeds    = True
  26.     publication_type      = 'magazine'
  27.     masthead_url          = 'http://www.nspm.rs/templates/jsn_epic_pro/images/logol.jpg'
  28.     extra_css             = """ @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
  29.                                 @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
  30.                                 body{font-family: "Times New Roman", serif1, serif}
  31.                                 .article_description{font-family: Arial, sans1, sans-serif}
  32.                                 img{margin-top:0.5em; margin-bottom: 0.7em}
  33.                                 .author{color: #990000; font-weight: bold}
  34.                                 .author,.createdate{font-size: 0.9em} """
  35.  
  36.     conversion_options = {
  37.                           'comment'          : description
  38.                         , 'tags'             : category
  39.                         , 'publisher'        : publisher
  40.                         , 'language'         : language
  41.                         , 'linearize_tables' : True
  42.                         }
  43.  
  44.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  45.     keep_only_tags = [dict(attrs={'id':'jsn-mainbody'})]
  46.     remove_tags        = [
  47.                            dict(name=['link','object','embed','script','meta','base','iframe'])
  48.                           ,dict(attrs={'class':'buttonheading'})
  49.                          ]
  50.     remove_tags_before = dict(attrs={'class':'contentheading'})
  51.     remove_tags_after  = dict(attrs={'class':'article_separator'})
  52.     remove_attributes  = ['width','height']
  53.  
  54.     def get_browser(self):
  55.         br = BasicNewsRecipe.get_browser()
  56.         br.open(self.INDEX)
  57.         return br
  58.  
  59.     feeds = [
  60.                  (u'Rubrike'      , u'http://www.nspm.rs/rubrike/feed/rss.html')
  61.                 ,(u'Debate'       , u'http://www.nspm.rs/debate/feed/rss.html')
  62.                 ,(u'Reci i misli' , u'http://www.nspm.rs/reci-i-misli/feed/rss.html')
  63.                 ,(u'Samo smeh srbina spasava', u'http://www.nspm.rs/samo-smeh-srbina-spasava/feed/rss.html')
  64.                 ,(u'Polemike'     , u'http://www.nspm.rs/polemike/feed/rss.html')
  65.                 ,(u'Prikazi'   , u'http://www.nspm.rs/prikazi/feed/rss.html')
  66.                 ,(u'Prenosimo'   , u'http://www.nspm.rs/prenosimo/feed/rss.html')
  67.                 ,(u'Hronika'   , u'http://www.nspm.rs/tabela/hronika/feed/rss.html')
  68.             ]
  69.  
  70.     def preprocess_html(self, soup):
  71.         for item in soup.body.findAll(style=True):
  72.             del item['style']
  73.         for item in soup.body.findAll('h1'):
  74.             nh = NavigableString(item.a.string)
  75.             item.a.extract()
  76.             item.insert(0,nh)
  77.         return self.adeify_images(soup)
  78.