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

  1. __license__   = 'GPL v3'
  2. __copyright__ = '2010, Darko Miletic <darko.miletic at gmail.com>'
  3. '''
  4. www.philosophypress.co.uk
  5. '''
  6.  
  7. from calibre.web.feeds.news import BasicNewsRecipe
  8.  
  9. class TPM_uk(BasicNewsRecipe):
  10.     title                 = "The Philosophers' Magazine"
  11.     __author__            = 'Darko Miletic'
  12.     description           = 'Title says it all'
  13.     publisher             = "The Philosophers' Magazine"
  14.     category              = 'philosophy, news'
  15.     oldest_article        = 25
  16.     max_articles_per_feed = 200
  17.     no_stylesheets        = True
  18.     encoding              = 'utf8'
  19.     use_embedded_content  = False
  20.     language              = 'en_GB'
  21.     remove_empty_feeds    = True
  22.     publication_type      = 'magazine'
  23.     masthead_url          = 'http://www.philosophypress.co.uk/wp-content/themes/masterplan/tma/images/bg/sitelogo.png'
  24.     extra_css             = """
  25.                                body{font-family: Helvetica,Arial,"Lucida Grande",Verdana,sans-serif }
  26.                                img{margin-bottom: 0.4em; display:block}
  27.                             """
  28.  
  29.     conversion_options = {
  30.                           'comment'   : description
  31.                         , 'tags'      : category
  32.                         , 'publisher' : publisher
  33.                         , 'language'  : language
  34.                         }
  35.  
  36.     remove_tags = [
  37.                      dict(name=['meta','link','base','iframe','embed','object','img'])
  38.                     ,dict(attrs={'id':['respond','sharethis_0']})
  39.                     ,dict(attrs={'class':'wp-caption-text'})
  40.                   ]
  41.     keep_only_tags=[
  42.                      dict(attrs={'class':['post_cat','post_name','post_meta','post_text']})
  43.                     ,dict(attrs={'id':'comments'})
  44.                    ]
  45.     remove_attributes=['lang','width','height']
  46.  
  47.  
  48.     feeds = [
  49.               (u'Columns'       , u'http://www.philosophypress.co.uk/?feed=rss2&cat=15' )
  50.              ,(u'Essays'        , u'http://www.philosophypress.co.uk/?feed=rss2&cat=19' )
  51.              ,(u"21'st Century" , u'http://www.philosophypress.co.uk/?feed=rss2&cat=101')
  52.              ,(u'Interviews'    , u'http://www.philosophypress.co.uk/?feed=rss2&cat=9'  )
  53.              ,(u'News'          , u'http://www.philosophypress.co.uk/?feed=rss2&cat=28' )
  54.              ,(u'Profiles'      , u'http://www.philosophypress.co.uk/?feed=rss2&cat=59' )
  55.              ,(u'Reviews'       , u'http://www.philosophypress.co.uk/?feed=rss2&cat=12' )
  56.             ]
  57.  
  58.     def get_cover_url(self):
  59.         soup = self.index_to_soup('http://www.philosophypress.co.uk/')
  60.         for image in soup.findAll('img',title=True):
  61.            if image['title'].startswith('Click to Subscribe'):
  62.               return image['src']
  63.         return None
  64.  
  65.     def preprocess_html(self, soup):
  66.         for item in soup.findAll(style=True):
  67.             del item['style']
  68.         for alink in soup.findAll('a', rel=True):
  69.             if alink.string is not None:
  70.                tstr = alink.string
  71.                alink.replaceWith(tstr)
  72.         return soup
  73.