Esempio n. 1
0
    def post(self):
        user = feedreader.utils.get_current_user()
        if not user:
            # Not logged in
            self.response.out.write("Log in, fool")
            return

        url = self.request.get('url')
        username = self.request.get('username')
        password = self.request.get('password')
        query = feedreader.models.feed.Feed.all()
        query.filter('url =', url)
        query.filter('username ='******'password ='******'t exist
            feed = feedreader.models.feed.Feed(url=url)
            if username and password:
                feed.username = username
                feed.password = password
            feed.put()
            key = feed.key()
            google.appengine.api.taskqueue.add(url='/async/fetch',
                params={'key': key})
        if feed.key() not in user.feeds:
            user.feeds.append(feed.key())
            user.put()
            google.appengine.api.taskqueue.add(url='/async/get_entries',
                    params={'user': str(user.key()), 'feed': feed.key()},
                    countdown=3)
        feedreader.utils.json_respond(self.response, feed)
Esempio n. 2
0
 def post(self):
     user_key = google.appengine.ext.db.Key(self.request.get('user'))
     feed_key = google.appengine.ext.db.Key(self.request.get('feed'))
     user = google.appengine.ext.db.get(user_key)
     feed = google.appengine.ext.db.get(feed_key)
     feed_blob_info = feed.contents_blob_info
     feed_contents = StringIO.StringIO(feed.contents)
     if feed_blob_info:
         fi = feed_blob_info.open('r')
         feed_contents = StringIO.StringIO(fi.read())
         fi.close()
     parsed_feed = feedparser.parse(feed_contents)
     if 'title' in parsed_feed['feed']:
         feed.title = parsed_feed['feed']['title']
     else:
         feed.title = 'Unknown feed'
     for entry in parsed_feed['entries'][:10]:
         if 'id' in entry:
             entry_id = entry['id']
         elif len(entry.enclosures) >= 1:
             entry_id = entry.enclosures[0].href
         if (feed.url.startswith("http://www.giantbomb.com/videos")):
             # XXX Hack for Giant Bomb feed brokenness
             entry_id = '-'.join([entry.updated,entry.title])
         if entry_id:
             if len(entry.enclosures) >= 1:
                 enclosure = entry.enclosures[0].href
                 # See if it's already in the database
                 query = feedreader.models.entry.Entry.all()
                 query = query.filter('entry_id =', entry_id)
                 query = query.filter('user ='******'t already exist
                     entry = feedreader.models.entry.Entry(user=user.user,
                         feed=feed.key(),
                         title=entry['title'],
                         enclosure=entry.enclosures[0].href,
                         entry_id=entry_id,
                         play_count=0,
                         updated_time=datetime.datetime(*entry.updated_parsed[0:6]),
                         timestamp=0)
                     entry.put()
Esempio n. 3
0
 def post(self):
     for feed in feedreader.models.feed.Feed.all():
         google.appengine.api.taskqueue.add(url='/async/fetch',
             params={'key': str(feed.key())})