Exemple #1
0
def add_feed_github(request, user=None):
#    if user is None:
#        return 'fail'


    if request.user.is_authenticated():

        user = request.REQUEST['user']
        url = 'https://github.com/%s/' % user
        feed_url = 'https://github.com/%s.atom' % user

    #    feed, create = Feed.objects.get_or_create(title=user)

        category, created = Category.objects.get_or_create(name='github', slug='github')

        feed = Feed()
        feed.title = user
        feed.url = url
        feed.category = category
        feed.feed_url = feed_url
        feed.dt_checked = datetime.datetime(1, 1, 1, 0, 0, 0)
        feed.dt_updated = datetime.datetime(1, 1, 1, 0, 0, 0)
        feed.save()

        return HttpResponse('yay')

#        return HttpResponseRedirect('/admin/reader/feed/%d/' % (feed.id,))
    else:
        return 'h4axx0r..'
Exemple #2
0
def add_rss(request, url=None):
    if url is None:
        url = request.REQUEST['url']
    d = feedparser.parse(url)
    feed = Feed()
    feed.title = d.feed.get('title', 'Untitled')
    feed.url = d.feed.get('link', url[:url.find('/', 8)])
    feed.feed_url = url
    feed.dt_checked = datetime.datetime(1, 1, 1, 0, 0, 0)
    feed.dt_updated = datetime.datetime(1, 1, 1, 0, 0, 0)
    feed.save()
    update(request, feed.id)
    return HttpResponseRedirect('/admin/reader/feed/%d/' % (feed.id,))