def get_items(self, since): items = [] try: feed = feedparser.parse( 'http://www.google.com/reader/public/atom/user/%s/state/com.google/broadcast' % ( self.service.auth.secret, ) ) for entry in feed.entries: updated = parser.parse(entry.updated) updated = (updated - updated.utcoffset()).replace(tzinfo=None) if updated.date() >= since: item = ServiceItem() item.title = entry.title # We dont take the summary as its huge item.body = '' if entry.has_key('links'): item.link_back = entry['links'] if entry.has_key('link'): item.link_back = entry['link'] item.created = updated item.service = self.service # For stats o = urlparse(entry.source.link) item.source = o.netloc # Person making comment item.author = entry.author items.append(item) except Exception, e: raise LoggedServiceError(original_exception=e)
def get_items(user, since, model_instance=None): serv = model_instance or get_model_instance(user, __name__) items = [] at = AccessToken.objects.get(service=serv) try: feed = feedparser.parse('http://www.google.com/reader/public/atom/user/%s/state/com.google/broadcast' % (at.userid,)) for entry in feed.entries: updated = parser.parse(entry.updated) updated = (updated - updated.utcoffset()).replace(tzinfo=None) if updated.date() >= since: item = ServiceItem() item.title = entry.title # we dont take the summary as its huge #if entry.has_key('summary'): item.body = '' if entry.has_key('links'): item.link_back = entry['links'] if entry.has_key('link'): item.link_back = entry['link'] item.created = updated item.service = serv item.user = user # for stats o = urlparse(entry.source.link) item.source = o.netloc item.author = entry.author # person making comment # entry.content[0].value == coment items.append(item) except Exception, e: raise LoggedServiceError(original_exception=e)