diff --git a/recipes/espn.recipe b/recipes/espn.recipe index 34c772f767..03c95d0001 100644 --- a/recipes/espn.recipe +++ b/recipes/espn.recipe @@ -20,7 +20,7 @@ class ESPN(BasicNewsRecipe): use_embedded_content = False remove_javascript = True - needs_subscription = True + needs_subscription = 'optional' encoding= 'ISO-8859-1' remove_tags_before = dict(name='font', attrs={'class':'date'}) @@ -75,32 +75,30 @@ class ESPN(BasicNewsRecipe): return soup - - def get_browser(self): br = BasicNewsRecipe.get_browser() - br.set_handle_refresh(False) - url = ('https://r.espn.go.com/members/v3_1/login') - raw = br.open(url).read() - raw = re.sub(r'(?s)
.*?id="regsigninbtn".*?
', '', raw) - with TemporaryFile(suffix='.htm') as fname: - with open(fname, 'wb') as f: - f.write(raw) - br.open_local_file(fname) + if self.username and self.password: + br.set_handle_refresh(False) + url = ('https://r.espn.go.com/members/v3_1/login') + raw = br.open(url).read() + raw = re.sub(r'(?s)
.*?id="regsigninbtn".*?
', '', raw) + with TemporaryFile(suffix='.htm') as fname: + with open(fname, 'wb') as f: + f.write(raw) + br.open_local_file(fname) - br.form = br.forms().next() - br.form.find_control(name='username', type='text').value = self.username - br.form['password'] = self.password - br.submit().read() - br.open('http://espn.go.com').read() - br.set_handle_refresh(True) + br.form = br.forms().next() + br.form.find_control(name='username', type='text').value = self.username + br.form['password'] = self.password + br.submit().read() + br.open('http://espn.go.com').read() + br.set_handle_refresh(True) return br def get_article_url(self, article): return article.get('guid', None) def print_version(self, url): - if 'eticket' in url: return url.partition('&')[0].replace('story?', 'print?') match = re.search(r'story\?(id=\d+)', url)