~ubuntu-branches/ubuntu/karmic/calibre/karmic

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_harpers_full.py

  • Committer: Bazaar Package Importer
  • Author(s): Martin Pitt
  • Date: 2009-07-30 12:49:41 UTC
  • mfrom: (1.3.2 upstream)
  • Revision ID: james.westby@ubuntu.com-20090730124941-qjdsmri25zt8zocn
Tags: 0.6.3+dfsg-0ubuntu1
* New upstream release. Please see http://calibre.kovidgoyal.net/new_in_6/
  for the list of new features and changes.
* remove_postinstall.patch: Update for new version.
* build_debug.patch: Does not apply any more, disable for now. Might not be
  necessary any more.
* debian/copyright: Fix reference to versionless GPL.
* debian/rules: Drop obsolete dh_desktop call.
* debian/rules: Add workaround for weird Python 2.6 setuptools behaviour of
  putting compiled .so files into src/calibre/plugins/calibre/plugins
  instead of src/calibre/plugins.
* debian/rules: Drop hal fdi moving, new upstream version does not use hal
  any more. Drop hal dependency, too.
* debian/rules: Install udev rules into /lib/udev/rules.d.
* Add debian/calibre.preinst: Remove unmodified
  /etc/udev/rules.d/95-calibre.rules on upgrade.
* debian/control: Bump Python dependencies to 2.6, since upstream needs
  it now.

Show diffs side-by-side

added added

removed removed

Lines of Context:
9
9
'''
10
10
 
11
11
from calibre import strftime
12
 
 
13
12
from calibre.web.feeds.news import BasicNewsRecipe
 
13
from calibre.ebooks.BeautifulSoup import Tag
14
14
 
15
15
class Harpers_full(BasicNewsRecipe):
16
16
    title                 = u"Harper's Magazine - articles from printed edition"
17
17
    __author__            = u'Darko Miletic'
18
18
    description           = u"Harper's Magazine: Founded June 1850."
19
19
    publisher             = "Harpers's"
20
 
    category              = 'news, politics, USA'    
 
20
    category              = 'news, politics, USA'
21
21
    oldest_article        = 30
22
22
    max_articles_per_feed = 100
23
23
    no_stylesheets        = True
24
24
    use_embedded_content  = False
25
 
    simultaneous_downloads = 1
26
25
    delay                  = 1
27
26
    language               = _('English')
28
27
    needs_subscription = True
29
28
    INDEX = strftime('http://www.harpers.org/archive/%Y/%m')
30
29
    LOGIN = 'http://www.harpers.org'
31
30
    cover_url = strftime('http://www.harpers.org/media/pages/%Y/%m/gif/0001.gif')
32
 
    remove_javascript     = True
33
 
    
 
31
 
34
32
    html2lrf_options = [
35
33
                          '--comment', description
36
34
                        , '--category', category
37
35
                        , '--publisher', publisher
38
36
                        ]
39
 
    
40
 
    html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em} img {margin-top: 0em; margin-bottom: 0.4em}"' 
 
37
 
 
38
    html2epub_options = 'publisher="' + publisher + '"\ncomments="' + description + '"\ntags="' + category + '"\noverride_css=" p {text-indent: 0em; margin-top: 0em; margin-bottom: 0.5em} img {margin-top: 0em; margin-bottom: 0.4em}"'
41
39
 
42
40
    keep_only_tags = [ dict(name='div', attrs={'id':'cached'}) ]
43
41
    remove_tags = [
44
 
                     dict(name='table', attrs={'class':'rcnt'})
45
 
                    ,dict(name='table', attrs={'class':'rcnt topline'})
 
42
                     dict(name='table', attrs={'class':['rcnt','rcnt topline']})
 
43
                    ,dict(name='link')
46
44
                  ]
47
45
 
48
46
    def get_browser(self):
54
52
            br['password'] = self.password
55
53
            br.submit()
56
54
        return br
57
 
        
 
55
 
58
56
    def parse_index(self):
59
57
        articles = []
60
58
        print 'Processing ' + self.INDEX
61
59
        soup = self.index_to_soup(self.INDEX)
62
60
        for item in soup.findAll('div', attrs={'class':'title'}):
63
 
            text_link = item.parent.find('img',attrs={'alt':'Text'})            
 
61
            text_link = item.parent.find('img',attrs={'alt':'Text'})
64
62
            if text_link:
65
63
                url   = self.LOGIN + item.a['href']
66
64
                title = item.a.contents[0]
72
70
                                 ,'description':''
73
71
                                })
74
72
        return [(soup.head.title.string, articles)]
75
 
        
 
73
 
 
74
    def preprocess_html(self, soup):
 
75
        mcharset = Tag(soup,'meta',[("http-equiv","Content-Type"),("content","text/html; charset=utf-8")])
 
76
        soup.head.insert(1,mcharset)
 
77
        for item in soup.findAll(style=True):
 
78
            del item['style']
 
79
        for item in soup.findAll(xmlns=True):
 
80
            del item['xmlns']
 
81
        return soup