File size: 1,982 Bytes
0aee47a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
"""

bilibili_api.hot



热门相关 API

"""

from .utils.utils import get_api
from .utils.network import Api

API_rank = get_api("rank")
API = get_api("hot")


async def get_hot_videos(pn: int = 1, ps: int = 20) -> dict:
    """

    获取热门视频



    Args:

        pn (int): 第几页. Default to 1.



        ps (int): 每页视频数. Default to 20.



    Returns:

        dict: 调用 API 返回的结果

    """
    api = API_rank["info"]["hot"]
    params = {"ps": ps, "pn": pn}
    return await Api(**api).update_params(**params).result


async def get_weekly_hot_videos_list() -> dict:
    """

    获取每周必看列表(仅概述)



    Returns:

        调用 API 返回的结果

    """
    api = API_rank["info"]["weekly_series"]
    return await Api(**api).result


async def get_weekly_hot_videos(week: int = 1) -> dict:
    """

    获取一周的每周必看视频列表



    Args:

        week(int): 第几周. Default to 1.



    Returns:

        dict: 调用 API 返回的结果

    """
    api = API_rank["info"]["weekly_details"]
    params = {"number": week}
    return await Api(**api).update_params(**params).result


async def get_history_popular_videos() -> dict:
    """

    获取入站必刷 85 个视频



    Returns:

        dict: 调用 API 返回的结果

    """
    api = API_rank["info"]["history_popular"]
    params = {"page_size": 85, "page": 1}
    return await Api(**api).update_params(**params).result


async def get_hot_buzzwords(page_num: int = 1, page_size: int = 20) -> dict:
    """

    获取热词图鉴信息



    Args:

        page_num  (int): 页码. Defaults to 1.



        page_size (int): 每一页的数据大小. Defaults to 20.



    Returns:

        dict: 调用 API 返回的结果

    """
    api = API["buzzwords"]
    params = {"pn": page_num, "ps": page_size, "type_id": 4}
    return await Api(**api).update_params(**params).result