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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. akter.co.rs
  5. '''
  6.  
  7. import re
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class Akter(BasicNewsRecipe):
  11.     title                 = 'AKTER'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'AKTER - nedeljni politicki magazin savremene Srbije'
  14.     publisher             = 'Akter Media Group d.o.o.'
  15.     category              = 'vesti, online vesti, najnovije vesti, politika, sport, ekonomija, biznis, finansije, berza, kultura, zivot, putovanja, auto, automobili, tehnologija, politicki magazin, dogadjaji, desavanja, lifestyle, zdravlje, zdravstvo, vest, novine, nedeljnik, srbija, novi sad, vojvodina, svet, drustvo, zabava, republika srpska, beograd, intervju, komentar, reportaza, arhiva vesti, news, serbia, politics'
  16.     oldest_article        = 8
  17.     max_articles_per_feed = 100
  18.     no_stylesheets        = True
  19.     use_embedded_content  = False
  20.     encoding              = 'utf-8'
  21.     masthead_url          = 'http://www.akter.co.rs/templates/gk_thenews2/images/style2/logo.png'
  22.     language              = 'sr'
  23.     publication_type      = 'magazine'
  24.     remove_empty_feeds    = True
  25.     PREFIX                 = 'http://www.akter.co.rs'
  26.     extra_css             = """
  27.                                 @font-face {font-family: "sans1";src:url(res:///opt/sony/ebook/FONT/tt0003m_.ttf)}
  28.                                 .article_description,body{font-family: Arial,Helvetica,sans1,sans-serif}
  29.                                 .color-2{display:block; margin-bottom: 10px; padding: 5px, 10px;
  30.                                 border-left: 1px solid #D00000; color: #D00000}
  31.                                 img{margin-bottom: 0.8em} """
  32.  
  33.     conversion_options = {
  34.                           'comment'          : description
  35.                         , 'tags'             : category
  36.                         , 'publisher'        : publisher
  37.                         , 'language'         : language
  38.                         , 'linearize_tables' : True
  39.                         }
  40.  
  41.     preprocess_regexps = [(re.compile(u'\u0110'), lambda match: u'\u00D0')]
  42.  
  43.     feeds          = [
  44.                         (u'Politika'   , u'http://www.akter.co.rs/index.php/politikaprint.html' )
  45.                        ,(u'Ekonomija'  , u'http://www.akter.co.rs/index.php/ekonomijaprint.html')
  46.                        ,(u'Life&Style' , u'http://www.akter.co.rs/index.php/lsprint.html'       )
  47.                        ,(u'Sport'      , u'http://www.akter.co.rs/index.php/sportprint.html'    )
  48.                      ]
  49.  
  50.     def preprocess_html(self, soup):
  51.         for item in soup.findAll(style=True):
  52.             del item['style']
  53.         return self.adeify_images(soup)
  54.  
  55.     def print_version(self, url):
  56.         return url + '?tmpl=component&print=1&page='
  57.  
  58.     def parse_index(self):
  59.         totalfeeds = []
  60.         lfeeds = self.get_feeds()
  61.         for feedobj in lfeeds:
  62.             feedtitle, feedurl = feedobj
  63.             self.report_progress(0, _('Fetching feed')+' %s...'%(feedtitle if feedtitle else feedurl))
  64.             articles = []
  65.             soup = self.index_to_soup(feedurl)
  66.             for item in soup.findAll(attrs={'class':['sectiontableentry1','sectiontableentry2']}):
  67.                 link = item.find('a')
  68.                 url         = self.PREFIX + link['href']
  69.                 title       = self.tag_to_string(link)
  70.                 articles.append({
  71.                                       'title'      :title
  72.                                      ,'date'       :''
  73.                                      ,'url'        :url
  74.                                      ,'description':''
  75.                                     })
  76.             totalfeeds.append((feedtitle, articles))
  77.         return totalfeeds
  78.  
  79.