home *** CD-ROM | disk | FTP | other *** search
/ Maximum CD 2010 November / maximum-cd-2010-11.iso / DiscContents / calibre-0.7.13.msi / file_3899 < prev    next >
Encoding:
Text File  |  2010-01-16  |  4.4 KB  |  92 lines

  1. #!/usr/bin/env  python
  2. __license__     = 'GPL v3'
  3. __author__      = 'Lorenzo Vigentini'
  4. __copyright__   = '2009, Lorenzo Vigentini <l.vigentini at gmail.com>'
  5. __version__     = 'v1.01'
  6. __date__        = '14, January 2010'
  7. __description__ = 'Macworld is a publication of IDG Communication in the UK specifically on the Apple Mac.'
  8.  
  9. '''
  10. http://www.macworld.co.uk/
  11. '''
  12.  
  13. from calibre.web.feeds.news import BasicNewsRecipe
  14. from calibre.ptempfile import PersistentTemporaryFile
  15.  
  16. class pcMag(BasicNewsRecipe):
  17.     __author__    = 'Lorenzo Vigentini'
  18.     description   = 'Macworld is a publication of IDG Communication in the UK specifically on the Apple Mac.'
  19.     cover_url     = 'http://media.macworld.co.uk/images/masthead.jpg'
  20.  
  21.     title          = 'Mac World UK '
  22.     publisher      = 'IDG Communication'
  23.     category       = 'Apple, Mac, computing, product reviews, UK'
  24.  
  25.     language       = 'en_GB'
  26.     timefmt        = '[%a, %d %b, %Y]'
  27.  
  28.     oldest_article        = 15
  29.     max_articles_per_feed = 25
  30.     use_embedded_content  = False
  31.     recursion             = 10
  32.  
  33.     remove_javascript     = True
  34.     no_stylesheets        = True
  35.  
  36.     temp_files = []
  37.     articles_are_obfuscated = True
  38.  
  39.     def get_obfuscated_article(self, url):
  40.         br = self.get_browser()
  41.         br.open(url)
  42.         response = br.follow_link(url_regex='&print$', nr = 0)
  43.         html = response.read()
  44.  
  45.         self.temp_files.append(PersistentTemporaryFile('_fa.html'))
  46.         self.temp_files[-1].write(html)
  47.         self.temp_files[-1].close()
  48.         return self.temp_files[-1].name
  49.  
  50.     keep_only_tags     = [
  51.                             dict(name='div', attrs={'id':'wrapper'})
  52.                         ]
  53.  
  54.     remove_tags        = [
  55.                             dict(name='div', attrs={'class':'bannerContainer'}),
  56.                             dict(name='p', attrs={'class':'breadcrumbs'}),
  57.                             dict(name='ul', attrs={'id':'articleIconsList'})
  58.  
  59.                         ]
  60.  
  61.     remove_tags_after  = [
  62.                             dict(name='p', attrs={'id':'articlePageList'}),
  63.                         ]
  64.  
  65.     feeds          = [
  66.                        (u'MacWorld Headlines', u'http://www.macworld.co.uk/rss/macworld.xml'),
  67.                        (u'Reviews', u'http://www.macworld.co.uk/rss/reviews.xml'),
  68.                        (u'Masterclass', u'http://www.macworld.co.uk/rss/masterclasses.xml'),
  69.                        (u'MacWorld Team', u'http://www.macworld.co.uk/rss/blog8.xml'),
  70.                        (u'Andy Ihnatko', u'http://www.macworld.co.uk/rss/blog7.xml'),
  71.                        (u'Andy Penfold', u'http://www.macworld.co.uk/rss/blog11.xml'),
  72.                        (u'Jonny Evans', u'http://www.macworld.co.uk/rss/blog1.xml'),
  73.                        (u'Karen Haslam', u'http://www.macworld.co.uk/rss/blog4.xml'),
  74.                        (u'Mark Hattersley', u'http://www.macworld.co.uk/rss/blog2.xml'),
  75.                        (u'Nick Spence', u'http://www.macworld.co.uk/rss/blog12.xml'),
  76.                        (u'Simon Iary', u'http://www.macworld.co.uk/rss/blog3.xml')
  77.                      ]
  78.  
  79.     extra_css = '''
  80.                 h1 {color:#0066CC;font-family:Arial,Helvetica,sans-serif; font-size:20px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:20px;}
  81.                 h2 {color:#4D4D4D;font-family:Arial,Helvetica,sans-serif; font-size:16px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:16px; }
  82.                 h3 {color:#4D4D4D;font-family:Arial,Helvetica,sans-serif; font-size:15px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:15px;}
  83.                 h4 {color:#333333; font-family:Arial,Helvetica,sans-serif;font-size:13px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:13px; }
  84.                 h5 {color:#333333; font-family:Arial,Helvetica,sans-serif; font-size:11px; font-size-adjust:none; font-stretch:normal; font-style:normal; font-variant:normal; font-weight:bold; line-height:11px; text-transform:uppercase;}
  85.                 p.authorCredit {-x-system-font:none;font-family:Arial,sans-serif;font-size:10pt;font-size-adjust:none;font-stretch:normal;font-style:normal;font-variant:normal;font-weight:normal;line-height:1.1em;}
  86.                 p.date {font-size:10pt;margin-bottom:0;}
  87.                 img {align:left;}
  88.                 '''
  89.  
  90.  
  91.  
  92.