def pull_feeds(request): sources = Source.objects.filter(usersource__user=request.user) for source in sources: if source.xml_url: d = feedparser.parse(source.xml_url) #update source with attributes from feed if 'icon' in d.feed: source.icon_url = d.feed.icon if 'updated_parsed' in d.feed and d.feed.updated_parsed is not None: source.updated_parsed = datetime.fromtimestamp(mktime(d.feed.updated_parsed)) source.save() #print [field for field in d] for e in d['entries']: if 'published_parsed' in e: entry_published_date = datetime.fromtimestamp(mktime(e.published_parsed)) #feed timestamp if source.updated_parsed is None or entry_published_date>source.updated_parsed: entry = Entry(source=source, title=e.title, raw=e) if 'author_detail' in e: if 'name' in e.author_detail: entry.author_name = e.author_detail.name if 'href' in e.author_detail: entry.author_href = e.author_detail.href if 'email' in e.author_detail: entry.author_email = e.author_detail.email if 'comments' in e: entry.comments_href = e.comments if 'content' in e: entry.content = e.content if 'contributors' in e: entry.contributors = e.contributors if 'link' in e: entry.link = e.link if 'links' in e: entry.links = e.links if 'created_parsed' in e: entry.created_parsed = datetime.fromtimestamp(mktime(e.created_parsed)) #feed timestamp if 'expired_parsed' in e: entry.expired_parsed = datetime.fromtimestamp(mktime(e.expired_parsed)) #feed timestamp if 'published_parsed' in e: entry.published_parsed = datetime.fromtimestamp(mktime(e.published_parsed)) #feed timestamp if 'updated_parsed' in e: entry.updated_parsed = datetime.fromtimestamp(mktime(e.updated_parsed)) #feed timestamp if 'summary' in e: entry.summary = e.summary entry.save() else: print 'Entry with no Publication date: %s' % e return HttpResponseRedirect( reverse('entries') )