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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2011, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. www.washingtonpost.com
  5. '''
  6.  
  7. from calibre import strftime
  8. from calibre.web.feeds.news import BasicNewsRecipe
  9.  
  10. class TheWashingtonPost(BasicNewsRecipe):
  11.     title                 = 'The Washington Post'
  12.     __author__            = 'Darko Miletic'
  13.     description           = 'Leading source for news, video and opinion on politics, business, world and national news, science, travel, entertainment and more. Our local coverage includes reporting on education, crime, weather, traffic, real estate, jobs and cars for DC, Maryland and Virginia. Offering award-winning opinion writing, entertainment information and restaurant reviews.'
  14.     publisher             = 'The Washington Post Company'
  15.     category              = 'news, politics, USA'
  16.     oldest_article        = 2
  17.     max_articles_per_feed = 200
  18.     no_stylesheets        = True
  19.     encoding              = 'utf8'
  20.     delay                 = 1
  21.     use_embedded_content  = False
  22.     language              = 'en'
  23.     remove_empty_feeds    = True
  24.     publication_type      = 'newspaper'
  25.     masthead_url          = 'http://www.washingtonpost.com/rw/sites/twpweb/img/logos/twp_logo_300.gif'
  26.     cover_url             = strftime('http://www.washingtonpost.com/rw/WashingtonPost/Content/Epaper/%Y-%m-%d/Ax1.pdf')
  27.     extra_css             = """
  28.                                body{font-family: Georgia,serif }
  29.                             """
  30.  
  31.     conversion_options = {
  32.                           'comment'   : description
  33.                         , 'tags'      : category
  34.                         , 'publisher' : publisher
  35.                         , 'language'  : language
  36.                         }
  37.  
  38.     keep_only_tags   = [dict(attrs={'id':['content','entryhead','entrytext']})]
  39.     remove_tags      = [
  40.                           dict(name=['meta','link','iframe','base'])
  41.                          ,dict(attrs={'id':'multimedia-leaf-page'})
  42.                        ]
  43.     remove_attributes= ['lang','property','epochtime','datetitle','pagetype','contenttype','comparetime']
  44.  
  45.  
  46.     feeds = [
  47.               (u'World'          , u'http://feeds.washingtonpost.com/rss/world'                   )
  48.              ,(u'National'       , u'http://feeds.washingtonpost.com/rss/national'                )
  49.              ,(u'White House'    , u'http://feeds.washingtonpost.com/rss/politics/whitehouse'     )
  50.              ,(u'Business'       , u'http://feeds.washingtonpost.com/rss/business'                )
  51.              ,(u'Opinions'       , u'http://feeds.washingtonpost.com/rss/opinions'                )
  52.              ,(u'Investigations' , u'http://feeds.washingtonpost.com/rss/investigations'          )
  53.              ,(u'Local'          , u'http://feeds.washingtonpost.com/rss/local'                   )
  54.              ,(u'Entertainment'  , u'http://feeds.washingtonpost.com/rss/entertainment'           )
  55.              ,(u'Sports'         , u'http://feeds.washingtonpost.com/rss/sports'                  )
  56.              ,(u'Redskins'       , u'http://feeds.washingtonpost.com/rss/sports/redskins'         )
  57.              ,(u'Special Reports', u'http://feeds.washingtonpost.com/rss/national/special-reports')
  58.             ]
  59.  
  60.     def print_version(self, url):
  61.         if '_story.html' in url:
  62.            return url.replace('_story.html','_print.html')
  63.         return url
  64.  
  65.     def get_article_url(self, article):
  66.         link = BasicNewsRecipe.get_article_url(self,article)
  67.         if not 'washingtonpost.com' in link:
  68.            self.log('Skipping adds:', link)
  69.            return None
  70.         for it in ['_video.html','_gallery.html','_links.html']:
  71.             if it in link:
  72.                self.log('Skipping non-article:', link)
  73.                return None
  74.         return link
  75.  
  76.