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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2008-2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. www.themoscowtimes.com
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class Moscowtimes(BasicNewsRecipe):
  10.     title                 = 'The Moscow Times'
  11.     __author__            = 'Darko Miletic and Sujata Raman'
  12.     description           = 'The Moscow Times is a daily English-language newspaper featuring objective, reliable news on business, politics, sports and culture in Moscow, in Russia and the former Soviet Union (CIS).'
  13.     category              = 'Russia, Moscow, Russian news, Moscow news, Russian newspaper, daily news, independent news, reliable news, USSR, Soviet Union, CIS, Russian politics, Russian business, Russian culture, Russian opinion, St Petersburg, Saint Petersburg'
  14.     publisher             = 'The Moscow Times'
  15.     language              = 'en'
  16.     oldest_article        = 2
  17.     max_articles_per_feed = 100
  18.     no_stylesheets        = True
  19.     use_embedded_content  = False
  20.     remove_empty_feeds    = True
  21.     encoding              = 'cp1251'
  22.     masthead_url          = 'http://www.themoscowtimes.com/bitrix/templates/tmt/img/logo.gif'
  23.     publication_type      = 'newspaper'
  24.  
  25.     conversion_options = {
  26.                           'comment'   : description
  27.                         , 'tags'      : category
  28.                         , 'publisher' : publisher
  29.                         , 'language'  : language
  30.                         }
  31.  
  32.     extra_css      = '''
  33.                         h1{ color:#0066B3; font-family: Georgia,serif ; font-size: large}
  34.                         .article_date{ font-family:Arial,Tahoma,Verdana,Helvetica,sans-serif ; color:#000000; font-size: x-small;}
  35.                         .autors{color:#999999 ; font-weight: bold ; font-family:Arial,Tahoma,Verdana,Helvetica,sans-serif ; font-size: x-small; }
  36.                         .photoautors{ color:#999999 ; font-family:Arial,Tahoma,Verdana,Helvetica,sans-serif ; font-size: x-small; }
  37.                         .text{font-family:Arial,Tahoma,Verdana,Helvetica,sans-serif ; font-size:75%; }
  38.                         '''
  39.     feeds          = [
  40.                          (u'Top Stories'   , u'http://www.themoscowtimes.com/rss/top'     )
  41.                         ,(u'Current Issue' , u'http://www.themoscowtimes.com/rss/issue'   )
  42.                         ,(u'News'          , u'http://www.themoscowtimes.com/rss/news'    )
  43.                         ,(u'Business'      , u'http://www.themoscowtimes.com/rss/business')
  44.                         ,(u'Art and Ideas' , u'http://www.themoscowtimes.com/rss/art'     )
  45.                         ,(u'Opinion'       , u'http://www.themoscowtimes.com/rss/opinion' )
  46.                      ]
  47.  
  48.     keep_only_tags = [dict(name='div', attrs={'id':'content'})]
  49.     remove_tags    = [
  50.                        dict(name='div', attrs={'class':['photo_nav','phototext']})
  51.                       ,dict(name=['iframe','meta','base','link','embed','object'])
  52.                      ]
  53.                      
  54.     def preprocess_html(self, soup):
  55.         for lnk in soup.findAll('a'):
  56.             if lnk.string is not None:
  57.                ind = self.tag_to_string(lnk)
  58.                lnk.replaceWith(ind)
  59.         return soup
  60.  
  61.     def print_version(self, url):        
  62.         return url.replace('.themoscowtimes.com/','.themoscowtimes.com/print/')
  63.  
  64.     def get_cover_url(self):
  65.         cover_url = None
  66.         href =  'http://www.themoscowtimes.com/pdf/'
  67.         soup = self.index_to_soup(href)        
  68.         div = soup.find('div',attrs={'class':'left'})
  69.         if div:
  70.             a = div.find('a')
  71.             if a :
  72.                cover_url = 'http://www.themoscowtimes.com' + a.img['src']
  73.         return cover_url
  74.