Exemplo n.º 1
0
async def modify_video_favorite_list(media_id: int,
                                     title: str,
                                     introduction: str = '',
                                     private: bool = False,
                                     credential: Credential = None):
    """
    修改视频收藏夹信息。

    Args:
        media_id     (int)                 : 收藏夹 ID.
        title        (str)                 : 收藏夹名。
        introduction (str, optional)       : 收藏夹简介. Defaults to ''.
        private      (bool, optional)      : 是否为私有. Defaults to False.
        credential   (Credential, optional): Credential. Defaults to None.

    Returns:
        dict: API 调用结果。
    """

    if credential is None:
        credential = Credential()

    credential.raise_for_no_sessdata()
    credential.raise_for_no_bili_jct()

    api = API["operate"]["modify"]
    data = {
        "title": title,
        "intro": introduction,
        "privacy": 1 if private else 0,
        "cover": "",
        "media_id": media_id
    }

    return await request("POST", api["url"], data=data, credential=credential)
Exemplo n.º 2
0
async def move_video_favorite_list_content(media_id_from: int,
                                           media_id_to: int, aids: List[int],
                                           credential: Credential):
    """
    移动视频收藏夹内容

    Args:
        media_id_from (int)       : 要移动的源收藏夹 ID。
        media_id_to   (int)       : 目标收藏夹 ID。
        aids          (List[int]) : 被移动的视频 ID 列表。
        credential    (Credential): 凭据

    Returns:
        dict: API 调用结果。
    """
    credential.raise_for_no_sessdata()
    credential.raise_for_no_bili_jct()
    api = API["operate"]["content_move"]

    data = {
        "src_media_id": media_id_from,
        "tar_media_id": media_id_to,
        "resources": ",".join(map(lambda x: f"{str(x)}:2", aids))
    }

    return await request("POST", api["url"], data=data, credential=credential)
Exemplo n.º 3
0
async def clean_video_favorite_list_content(media_id: int,
                                            credential: Credential):
    """
    清除视频收藏夹失效内容

    Args:
        media_id   (int)       : 收藏夹 ID
        credential (Credential): 凭据

    Returns:
        dict: API 调用结果。
    """
    credential.raise_for_no_sessdata()
    credential.raise_for_no_bili_jct()
    api = API["operate"]["content_clean"]

    data = {"media_id": media_id}

    return await request("POST", api["url"], data=data, credential=credential)
Exemplo n.º 4
0
async def delete_video_favorite_list(media_ids: List[int],
                                     credential: Credential):
    """
    删除视频收藏夹,可批量删除。

    Args:
        media_ids  (List[int]) : 收藏夹 ID 列表。
        credential (Credential): Credential.

    Returns:
        dict: API 调用结果。
    """

    credential.raise_for_no_sessdata()
    credential.raise_for_no_bili_jct()

    data = {"media_ids": join(",", media_ids)}
    api = API["operate"]["delete"]

    return await request("POST", api["url"], data=data, credential=credential)
Exemplo n.º 5
0
async def get_note_favorite_list(page: int = 1, credential: Credential = None):
    """
    获取自己的笔记收藏夹内容。

    Args:
        page       (int, optional)       : 页码. Defaults to 1.
        credential (Credential, optional): Credential. Defaults to None.
    """
    if credential is None:
        credential = Credential()

    credential.raise_for_no_sessdata()

    api = API["info"]["list_notes"]
    params = {"pn": page, "ps": 16}

    return await request("GET",
                         api["url"],
                         params=params,
                         credential=credential)
Exemplo n.º 6
0
 def __init__(self, cvid: int, credential: Credential = None):
     """
     Args:
         cvid       (int)                 : cv 号
         credential (Credential, optional): 凭据. Defaults to None.
     """
     self.__children: List[Node] = []
     self.credential: Credential = credential if credential is not None else Credential(
     )
     self.__meta = None
     self.cvid = cvid
     self.__has_parsed: bool = False
Exemplo n.º 7
0
async def get_course_favorite_list(page: int = 1,
                                   credential: Credential = None):
    """
    获取自己的课程收藏夹内容。

    Args:
        page       (int, optional)       : 页码. Defaults to 1.
        credential (Credential, optional): Credential. Defaults to None.
    """
    if credential is None:
        credential = Credential()

    credential.raise_for_no_sessdata()

    api = API["info"]["list_courses"]
    self_info = await user.get_self_info(credential)
    params = {"pn": page, "ps": 10, "mid": self_info["mid"]}

    return await request("GET",
                         api["url"],
                         params=params,
                         credential=credential)
Exemplo n.º 8
0
async def get_article_list(rlid: int, credential: Credential = None):
    """
    获取专栏文集文章列表

    Args:
        rlid       (int)                 : 文集 ID,如 https: //www.bilibili.com/read/readlist/rl000010 省略前导 0
        credential (Credential, optional): 凭据. Defaults to None.
    """
    credential = credential if credential is not None else Credential()

    api = API['info']['list']
    params = {"id": rlid}
    return await request('GET', api['url'], params, credential=credential)
Exemplo n.º 9
0
async def delete_video_favorite_list_content(media_id: int, aids: List[int],
                                             credential: Credential):
    """
    删除视频收藏夹内容

    Args:
        media_id   (int)       : 收藏夹 ID。
        aids       (List[int]) : 被删除的视频 ID 列表。
        credential (Credential): 凭据

    Returns:
        dict: API 调用结果。
    """
    credential.raise_for_no_sessdata()
    credential.raise_for_no_bili_jct()
    api = API["operate"]["content_rm"]

    data = {
        "media_id": media_id,
        "resources": ",".join(map(lambda x: f"{str(x)}:2", aids))
    }

    return await request("POST", api["url"], data=data, credential=credential)