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

« back to all changes in this revision

Viewing changes to src/calibre/web/feeds/recipes/recipe_espn.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:
10
10
from calibre.web.feeds.news import BasicNewsRecipe
11
11
 
12
12
class ESPN(BasicNewsRecipe):
13
 
    
 
13
 
14
14
    title       = 'ESPN'
15
15
    description = 'Sports news'
16
16
    __author__  = 'Kovid Goyal'
17
17
    language = _('English')
18
 
    
 
18
 
19
19
    needs_subscription = True
20
20
    remove_tags = [dict(name='font', attrs={'class':'footer'}), dict(name='hr', noshade='noshade')]
21
21
    remove_tags_before = dict(name='font', attrs={'class':'date'})
22
22
    center_navbar = False
23
 
    html2lrf_options = ['--base-font-size', '0']
24
 
    
 
23
 
25
24
    feeds = [('Top Headlines', 'http://sports.espn.go.com/espn/rss/news'),
26
25
             'http://sports.espn.go.com/espn/rss/nfl/news',
27
26
             'http://sports.espn.go.com/espn/rss/nba/news',
39
38
             'http://sports.espn.go.com/espn/rss/bassmaster/news',
40
39
             'http://sports.espn.go.com/espn/rss/oly/news',
41
40
             'http://sports.espn.go.com/espn/rss/horse/news']
42
 
    
 
41
 
43
42
    def get_browser(self):
44
43
        br = BasicNewsRecipe.get_browser()
45
44
        br.set_handle_refresh(False)
46
45
        if self.username is not None and self.password is not None:
47
46
            br.open('http://espn.com')
48
 
            br.select_form(nr=0)
 
47
            br.select_form(nr=1)
49
48
            br.form.find_control(name='username', type='text').value = self.username
50
49
            br.form['password'] = self.password
51
50
            br.submit()
52
51
        br.set_handle_refresh(True)
53
52
        return br
54
 
    
 
53
 
55
54
    def print_version(self, url):
56
55
        if 'eticket' in url:
57
56
            return url.partition('&')[0].replace('story?', 'print?')
58
57
        match = re.search(r'story\?(id=\d+)', url)
59
58
        if match:
60
59
            return 'http://sports.espn.go.com/espn/print?'+match.group(1)+'&type=story'
61
 
        
 
60
 
62
61
        return None
63
 
    
 
62
 
64
63
    def preprocess_html(self, soup):
65
64
        for div in soup.findAll('div'):
66
65
            if div.has_key('style') and 'px' in div['style']:
67
66
                div['style'] = ''
68
 
        
 
67
 
69
68
        return soup
70
 
    
 
69
 
71
70
    def postprocess_html(self, soup, first_fetch):
72
71
        for div in soup.findAll('div', style=True):
73
72
            div['style'] = div['style'].replace('center', 'left')
74
73
        return soup
75
 
            
 
 
b'\\ No newline at end of file'
 
74