Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[提问] biliplus“获取 cid 对应的视频”返回404,导致笔记获取失败 #858

Open
YanCore opened this issue Nov 27, 2024 · 1 comment
Labels
question 这啥呀这是,我不到啊

Comments

@YanCore
Copy link

YanCore commented Nov 27, 2024

Python 版本: 3.11.0b4

模块版本: 16.3.0

运行环境: Windows


日志

[Request][2024-11-27 17:18:12,759] Api(url='https://hd.biliplus.com/api/cidinfo', method='GET', comment='获取 cid 对应的视频', wbi=False, verify=False, no_csrf=False, json_body=False, ignore_code=False, data={}, params={'cid': 733266843}, files={}, headers={}, credential=<bilibili_api.utils.credential.Credential object at 0x0000029C5C307A50>)

bilibili_api.exceptions.ResponseCodeException.ResponseCodeException: 接口返回错误代码:-404,信息:cid无记录。
{'code': -404, 'message': 'cid无记录'}

https://hd.biliplus.com/api/cidinfo?cid=733266843

上面CID对应的视频链接:https://www.bilibili.com/video/BV1kY411u7iK

复现代码

获取私人笔记,调用note.fetch_content()报错。

import bilibili_api as bili
from bilibili_api import sync
note_id,aid = "",""
def main():
    credential = bili.Credential(
          sessdata=SESSDATA, bili_jct=BILI_JCT, buvid3=BUVID3)

    note = bili.note.Note(
          note_type=bili.note.NoteType.PRIVATE,
          note_id=note_id, aid=aid,
          credential=credential)
    # FIXME
    await note.fetch_content()
    note_markdown = note.markdown()
if __name__ == "__main__":
    sync(main())

image

image

疑问/解决

  1. cid是什么?
  2. 拿着BVID去「biliplus」搜索后,上面的404就不会出现,note.fetch_content()功能恢复正常。是否能够在API库中内置这个功能?
    image
@YanCore YanCore added the question 这啥呀这是,我不到啊 label Nov 27, 2024
@YanCore
Copy link
Author

YanCore commented Nov 27, 2024

class VideoCardNode(Node):
    def __init__(self):
        self.aid = 0

    def markdown(self):
        return f"[视频 av{self.aid}](https://www.bilibili.com/av{self.aid})\n\n"

    def json(self):
        return {"type": "VideoCardNode", "aid": self.aid}

这里cid是错的,得用aid。

class Note:
    async def fetch_content(self) -> None:
        """
        获取并解析笔记内容

        该返回不会返回任何值,调用该方法后请再调用 `self.markdown()` 或 `self.json()` 来获取你需要的值。
        """

        def parse_note(data: List[dict]):
            for field in data:
                if not isinstance(field["insert"], str):
                    if "tag" in field["insert"].keys():
                        node = VideoCardNode()
                        # FIXME
                        # node.aid = get_cid_info_sync(field["insert"]["tag"]["cid"])[
                        #     "cid"
                        # ]
                        # 
                        node.aid = get_cid_info_sync(field["insert"]["tag"]["cid"])[
                            "aid"
                        ]
                        self.__children.append(node)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question 这啥呀这是,我不到啊
Projects
None yet
Development

No branches or pull requests

1 participant