Thread: gmail recipe
View Single Post
Old 10-01-2010, 03:43 AM   #9
marbs
Zealot
marbs began at the beginning.
 
Posts: 122
Karma: 10
Join Date: Jul 2010
Device: nook
still working on this

this is what i have. if anything comes to mind, please tell me.

import urllib, re, mechanize
from calibre.web.feeds.recipes import BasicNewsRecipe
from calibre import __appname__

Spoiler:
Code:
class GoogleReaderUber(BasicNewsRecipe):
    title   = 'Google Reader uber'
    description = 'Fetches all feeds from your Google Reader account including the uncategorized items.'
    needs_subscription = True
    __author__ = 'davec, rollercoaster, Starson17'
    base_url = 'http://www.google.com/reader/atom/'
    oldest_article = 365
    max_articles_per_feed = 250
    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(self)
        if self.username is not None and self.password is not None:
            request = urllib.urlencode([('Email', self.username), ('Passwd', self.password),
                                        ('service', 'reader'), ('accountType', 'HOSTED_OR_GOOGLE'), ('source', __appname__)])
            response = br.open('https://www.google.com/accounts/ClientLogin', request)
            auth = re.search('Auth=(\S*)', response.read()).group(1)
            cookies = mechanize.CookieJar()
            br = mechanize.build_opener(mechanize.HTTPCookieProcessor(cookies))
            br.addheaders = [('Authorization', 'GoogleLogin auth='+auth)]
        return br
    def get_feeds(self):
        feeds = []
        soup = self.index_to_soup('https://mail.google.com/mail/feed/atom')
        for id in soup.findAll('entry', attrs={'href'}):
            url = id['href']
            title       = self.tag_to_string(title)
            description1=self.tag_to_string(summary)
            date1=self.tag_to_string(modified)

            feeds.append({'title': title, 'url': url, 'description':summary, 'date':''}) # append all this
            
           
        return feeds
marbs is offline   Reply With Quote