mirror of
https://github.com/kovidgoyal/calibre.git
synced 2025-06-23 15:30:45 -04:00
Add Google Reader recipe (thanks to davec)
This commit is contained in:
parent
fea37f24ae
commit
21b31d05ed
@ -4,8 +4,10 @@ __copyright__ = '2008, Kovid Goyal <kovid at kovidgoyal.net>'
|
||||
'''
|
||||
Builtin recipes.
|
||||
'''
|
||||
recipes = ['newsweek', 'atlantic', 'economist', 'dilbert', 'portfolio',
|
||||
'nytimes', 'usatoday', 'outlook_india', 'bbc']
|
||||
recipes = [
|
||||
'newsweek', 'atlantic', 'economist', 'dilbert', 'portfolio',
|
||||
'nytimes', 'usatoday', 'outlook_india', 'bbc', 'greader',
|
||||
]
|
||||
|
||||
import re, imp, inspect, time
|
||||
from libprs500.web.feeds.news import BasicNewsRecipe, CustomIndexRecipe, AutomaticNewsRecipe
|
||||
|
36
src/libprs500/web/feeds/recipes/greader.py
Normal file
36
src/libprs500/web/feeds/recipes/greader.py
Normal file
@ -0,0 +1,36 @@
|
||||
import urllib, re, mechanize
|
||||
from libprs500.web.feeds.recipes import BasicNewsRecipe
|
||||
from libprs500 import __appname__
|
||||
|
||||
class GoogleReader(BasicNewsRecipe):
|
||||
title = 'Google Reader'
|
||||
description = 'This recipe downloads feeds you have tagged from your Google Reader account.'
|
||||
needs_subscription = True
|
||||
__author__ = 'davec'
|
||||
base_url = 'http://www.google.com/reader/atom/'
|
||||
max_articles_per_feed = 50
|
||||
get_options = '?n=%d&xt=user/-/state/com.google/read' % max_articles_per_feed
|
||||
use_embedded_content = True
|
||||
|
||||
def get_browser(self):
|
||||
br = BasicNewsRecipe.get_browser()
|
||||
|
||||
if self.username is not None and self.password is not None:
|
||||
request = urllib.urlencode([('Email', self.username), ('Passwd', self.password),
|
||||
('service', 'reader'), ('source', __appname__)])
|
||||
response = br.open('https://www.google.com/accounts/ClientLogin', request)
|
||||
sid = re.search('SID=(\S*)', response.read()).group(1)
|
||||
|
||||
cookies = mechanize.CookieJar()
|
||||
br = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookies))
|
||||
cookies.set_cookie(mechanize.Cookie(None, 'SID', sid, None, False, '.google.com', True, True, '/', True, False, None, True, '', '', None))
|
||||
return br
|
||||
|
||||
|
||||
def get_feeds(self):
|
||||
feeds = []
|
||||
soup = self.index_to_soup('http://www.google.com/reader/api/0/tag/list')
|
||||
for id in soup.findAll(True, attrs={'name':['id']}):
|
||||
url = id.contents[0]
|
||||
feeds.append((re.search('/([^/]*)$', url).group(1), self.base_url + urllib.quote(url) + self.get_options))
|
||||
return feeds
|
Loading…
x
Reference in New Issue
Block a user