示例#1
0
文件: bi.py 项目: tclh123/wido
    def get(cls, owner_access_token, uid, count=50, page=1, sort=0):
        client = client_with_access_token(owner_access_token)

        r = client.friendships.friends.bilateral.ids.get(uid=uid,
                                                         count=count,
                                                         page=page,
                                                         sort=sort)

        uids = r.ids

        return cls(uid, uids)
示例#2
0
文件: bi.py 项目: tclh123/wido
    def get(cls, owner_access_token,
            uid, count=50, page=1, sort=0):
        client = client_with_access_token(owner_access_token)

        r = client.friendships.friends.bilateral.ids.get(uid=uid,
                                                         count=count,
                                                         page=page,
                                                         sort=sort)

        uids = r.ids

        return cls(uid, uids)
示例#3
0
文件: timeline.py 项目: tclh123/wido
def user_timeline(owner_access_token, uid, count=3, hrs_limit=48):
    c = client_with_access_token(owner_access_token)
    try:
        r = c.statuses.user_timeline.get(uid=uid,
                                         feature=WEIBO_TYPE_VIDEO,
                                         count=count)
    except:
        return []

    # TODO
    statuses = [s for s in r.statuses if s.created_at]
    return statuses
示例#4
0
文件: video_url.py 项目: tclh123/wido
    def get_long_urls(cls, owner_access_token, urls):
        """ return dict (short_url -> long_url) """
        c = client_with_access_token(owner_access_token)

        r = None
        while not r:
            try:
                # URLencoded
                r = c.short_url.expand.get(url_short=urls)
            except Exception as e:
                print repr(e)

        return r.urls
示例#5
0
文件: home.py 项目: tclh123/wido
    def user_ids(cls, owner_access_token, uid):
        c = client_with_access_token(owner_access_token)

        # TODO: cache 考虑持久化
        # 目前只能处理200个关注用户里的大V
        # FIXME: 性能 批量获得 用户关注的用户里面的情况
        # r = c.friendships.friends.ids.get(uid=uid,
        #                                   count=5000)
        r = c.friendships.friends.get(uid=uid, count=200)
        follows = r.users
        bi_uids = Bi.get(owner_access_token, uid, count=2000).uids

        big_v = rule(follows)

        return list(set(bi_uids) | big_v)
示例#6
0
文件: home.py 项目: tclh123/wido
    def big_v_user_ids(cls, owner_access_token, uid):
        c = client_with_access_token(owner_access_token)

        # TODO: 待改,用 ids 的,然后跟死列表比较
        r = None
        while not r:
            try:
                r = c.friendships.friends.get(uid=uid, count=200)
            except Exception as e:
                print repr(e)

        follows = r.users
        big_v = rule(follows)

        return list(big_v)
示例#7
0
文件: timeline.py 项目: tclh123/wido
def user_timeline_batch(owner_access_token, uids, count=3, hrs_limit=48):
    c = client_with_access_token(owner_access_token)
    try:
        r = c.statuses.timeline_batch.get(uids=uids,
                                          feature=WEIBO_TYPE_VIDEO,
                                          count=count)
    except Exception as e:
        print repr(e)
        return []

    # TODO
    print r
    return r
    statuses = [s for s in r.statuses if s.created_at]
    return statuses
示例#8
0
文件: rec.py 项目: tclh123/wido
    def get(cls, owner_access_token, start=0, limit=3):
        c = client_with_access_token(owner_access_token)

        r = None
        while not r:
            try:
                r = c.suggestions.users.may_interested.get(
                        count=100)
            except Exception as e:
                print repr(e)

        uids = [u.uid for u in r[start:limit]]

        statuses = [t for uid in uids for t in user_timeline(owner_access_token, uid)]
        make_statuses(owner_access_token, statuses)
        return statuses
示例#9
0
文件: home.py 项目: tclh123/wido
    def user_ids(cls, owner_access_token, uid):
        c = client_with_access_token(owner_access_token)

        # TODO: cache 考虑持久化
        # 目前只能处理200个关注用户里的大V
        # FIXME: 性能 批量获得 用户关注的用户里面的情况
        # r = c.friendships.friends.ids.get(uid=uid,
        #                                   count=5000)
        r = c.friendships.friends.get(uid=uid,
                                      count=200)
        follows = r.users
        bi_uids = Bi.get(owner_access_token, uid, count=2000).uids

        big_v = rule(follows)

        return list(set(bi_uids) | big_v)
示例#10
0
文件: home.py 项目: tclh123/wido
    def big_v_user_ids(cls, owner_access_token, uid):
        c = client_with_access_token(owner_access_token)

        # TODO: 待改,用 ids 的,然后跟死列表比较
        r = None
        while not r:
            try:
                r = c.friendships.friends.get(uid=uid,
                                              count=200)
            except Exception as e:
                print repr(e)

        follows = r.users
        big_v = rule(follows)

        return list(big_v)
示例#11
0
文件: rec.py 项目: tclh123/wido
    def get(cls, owner_access_token, start=0, limit=3):
        c = client_with_access_token(owner_access_token)

        r = None
        while not r:
            try:
                r = c.suggestions.users.may_interested.get(count=100)
            except Exception as e:
                print repr(e)

        uids = [u.uid for u in r[start:limit]]

        statuses = [
            t for uid in uids for t in user_timeline(owner_access_token, uid)
        ]
        make_statuses(owner_access_token, statuses)
        return statuses
示例#12
0
文件: timeline.py 项目: tclh123/wido
    def get(cls, owner_uid, owner_access_token,
            since_id=0, max_id=0, count=20, page=1):
        client = client_with_access_token(owner_access_token)

        r = None
        while not r:
            try:
                r = client.statuses.home_timeline.get(feature=WEIBO_TYPE_VIDEO,
                                                      since_id=since_id,
                                                      max_id=max_id,
                                                      count=count,
                                                      page=page)
            except Exception as e:
                print repr(e)

        make_statuses(owner_access_token, r.statuses)

        return cls(owner_uid, owner_access_token, r)