Beispiel #1
0
def ttv_live_follows(user_id, client_id):
    data = {}
    batch, cursor = 0, ''

    header = create_client_header(client_id)
    total = ttv_total_follows(user_id, client_id)

    default_url = "%s%s&first=100" % (FOLLOWS_URL, user_id)

    while batch <= total:
        user_list = ""

        url = "%s&after=%s" % (default_url, cursor) if cursor else default_url
        follow_json_response = url_get_json(url, header)

        for streamer in follow_json_response['data']:
            user_list += "user_id=%s&" % streamer['to_id']

        live_json_response = url_get_json(STREAMS_URL + user_list[:-1], header)
        live_streams = live_json_response['data']
        data.update({"page%s" % int((batch / 100) + 1): live_streams})

        cursor = live_json_response['pagination']['cursor']
        batch += 100

    return data
Beispiel #2
0
def ttv_get_game_viewer_info(client_id, game_id):
    url = f"{STREAMS_URL}game_id={game_id}&first=100"
    logging.debug(f"Game viewer count lookup: {url}")
    return url_get_json(url, create_client_header(client_id))
Beispiel #3
0
def ttv_total_follows(user_id, client_id):
    url = "%s%s&first=1" % (FOLLOWS_URL, user_id)
    return url_get_json(url, create_client_header(client_id))['total']
Beispiel #4
0
def ttv_get_game_info(client_id, game_id):
    url = f"{GAME_URL}{game_id}"
    logging.debug(f"Game lookup: {url}")
    return url_get_json(url, create_client_header(client_id))
Beispiel #5
0
def ttv_get_user_info(client_id, user_id):
    url = f"{USER_URL}{user_id}"
    logging.debug(f"User lookup: {url}")
    return url_get_json(url, create_client_header(client_id))
Beispiel #6
0
def ttv_get_my_info(token, client_id):
    url = f"{MY_URL}"
    header = create_client_header(client_id)
    header.update(create_bearer_header(token))
    logging.debug(f"Self lookup: {url} Header: {header}")
    return url_get_json(url, header)
Beispiel #7
0
def ttv_top_games(client_id):
    return url_get_json(GAMES_URL, create_client_header(client_id))
Beispiel #8
0
def ttv_top_streams(client_id):
    return url_get_json(STREAMS_URL, create_client_header(client_id))