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

  1.  
  2. __license__   = 'GPL v3'
  3. __copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
  4. '''
  5. njuz.net
  6. '''
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class NjuzNet(BasicNewsRecipe):
  11.     title                 = 'Njuz.net'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Iscasene vesti iz Srbije, regiona i sveta'
  14.     publisher             = 'njuz.net'
  15.     category              = 'news, politics, humor, Serbia'
  16.     oldest_article        = 2
  17.     max_articles_per_feed = 100
  18.     no_stylesheets        = True
  19.     use_embedded_content  = False
  20.     encoding              = 'utf8'
  21.     language              = 'sr'
  22.     publication_type      = 'newsportal'
  23.     masthead_url          = 'http://www.njuz.net/njuznet.jpg'
  24.     extra_css             = """
  25.                                @font-face {font-family: "serif1";src:url(res:///opt/sony/ebook/FONT/tt0011m_.ttf)}
  26.                                 body{font-family: serif1, serif}
  27.                                .articledescription{font-family: serif1, serif}
  28.                                .wp-caption-text{font-size: x-small}
  29.                             """
  30.  
  31.     conversion_options = {
  32.                           'comment'          : description
  33.                         , 'tags'             : category
  34.                         , 'publisher'        : publisher
  35.                         , 'language'         : language
  36.                         }
  37.  
  38.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  39.  
  40.     keep_only_tags     = [
  41.                            dict(attrs={'id':'entryMeta'})
  42.                           ,dict(attrs={'class':'post'})
  43.                          ]
  44.  
  45.     remove_tags = [
  46.                      dict(name=['embed','link','base','iframe','object','meta','fb:like'])
  47.                     ,dict(name='div', attrs={'id':'tagsandcats'})
  48.                   ]
  49.     remove_tags_after= dict(name='div', attrs={'id':'tagsandcats'})
  50.     remove_attributes= ['lang']
  51.     feeds            = [(u'Clanci', u'http://www.njuz.net/feed/')]
  52.  
  53.     def preprocess_html(self, soup):
  54.         for item in soup.findAll(style=True):
  55.             del item['style']
  56.         for alink in soup.findAll('a'):
  57.             if alink.string is not None:
  58.                tstr = alink.string
  59.                alink.replaceWith(tstr)
  60.         return soup
  61.  
  62.