Пример #1
0
def _handle_rss_bookmark(mark, username):
    log.info("working with bookmark => %s" % mark.get('extended'))

    bookmark, created = Bookmark.objects.get_or_create(
        description = mark.get('extended'),
        url = mark.get("href"),
        title = mark.get("description"),
        timestamp = utils.parsedate(mark.get('time'))
    )
    bookmark.tags = mark.get("tag")
Пример #2
0
        log.warning('no tweets returned, twitter possibly overloaded.')
        return

    for t in tweets:
        if t['id'] > last_id:
            log.info("Working with %s.", t['id'])

            tweet_text = smart_unicode(t['text'])
            owner_user = smart_unicode(t['user']['screen_name'])
            url = "http://twitter.com/%s/statuses/%s" % (owner_user, t['id'])

            tweet, created = Tweet.objects.get_or_create(
                    tweet_id    = t['id'], 
                    title       = tweet_text,
                    owner_user  = owner_user,
                    timestamp   = utils.parsedate(t['created_at']),
                    source      = smart_unicode(t['source']),
                    url = url,
                    source_type = "tweet"
            )
            try:
                tweet.tags = _tweet_to_tags(tweet_text)
            except Exception, e:
                print e
                pass
        else:
            log.warning("No more tweets, stopping...")
            break

def _tweet_to_tags(text):
    tags = []
Пример #3
0
        try:
            last_update = Bookmark.objects.filter(owner_user=username).order_by('-timestamp')[0].timestamp
        except Exception, e:
            log.debug('%s', e)

    if force and password:
        marks = utils.get_remote_data(url, rformat=rformat, username=username, password=password)
    else:
        marks = utils.get_remote_data(url, rformat=rformat)

    if marks:
        for mark in marks:
            if password and force:
                _handle_rss_bookmark(mark, username)
                continue
            dt = utils.parsedate(mark['dt']) 
            if dt > last_update:
                _handle_bookmark(mark, dt, username)
            else:
                log.warning("No more bookmarks, stopping...")
                break

def _handle_bookmark(mark, dt, username):
    log.info("working with bookmark => %s" % mark['d'])

    tags = ' '.join(mark['t'])

    bookmark, created = Bookmark.objects.get_or_create(
        timestamp   = dt,
        url         = mark['u'],
        title       = mark['d'],