From 961680a81baa92bd32b83cb864722e314c22db69 Mon Sep 17 00:00:00 2001 From: Soxoj <31013580+soxoj@users.noreply.github.com> Date: Mon, 20 Jul 2026 20:28:02 +0200 Subject: [PATCH] Add support of Bilibili (#2891) --- docs/source/command-line-options.rst | 2 +- .../zh_CN/LC_MESSAGES/command-line-options.po | 10 +++---- .../LC_MESSAGES/supported-identifier-types.po | 26 ++++++++++++++++++- docs/source/supported-identifier-types.rst | 9 +++++++ maigret/checking.py | 1 + maigret/resources/data.json | 20 ++++++++++++++ maigret/resources/db_meta.json | 6 ++--- sites.md | 17 ++++++------ 8 files changed, 73 insertions(+), 18 deletions(-) diff --git a/docs/source/command-line-options.rst b/docs/source/command-line-options.rst index 45779da..2b68e88 100644 --- a/docs/source/command-line-options.rst +++ b/docs/source/command-line-options.rst @@ -98,7 +98,7 @@ false positives). ``--id-type`` - Specify identifier(s) type (default: username). Supported types: gaia_id, steam_id, vk_id, yandex_public_id, ok_id, -wikimapia_uid, uidme_uguid, yelp_userid, orcid, qq_id. +wikimapia_uid, uidme_uguid, yelp_userid, orcid, qq_id, bilibili_id. Sites whose type does not match are filtered out automatically. See :ref:`supported-identifier-types` for details and an example. diff --git a/docs/source/locale/zh_CN/LC_MESSAGES/command-line-options.po b/docs/source/locale/zh_CN/LC_MESSAGES/command-line-options.po index 0997057..e114d8f 100644 --- a/docs/source/locale/zh_CN/LC_MESSAGES/command-line-options.po +++ b/docs/source/locale/zh_CN/LC_MESSAGES/command-line-options.po @@ -214,14 +214,14 @@ msgstr "``--use-disabled-sites`` —— 把已禁用的站点也纳入搜索范 msgid "" "``--id-type`` - Specify identifier(s) type (default: username). Supported " "types: gaia_id, steam_id, vk_id, yandex_public_id, ok_id, wikimapia_uid, " -"uidme_uguid, yelp_userid, orcid, qq_id. Sites whose type does not match are " -"filtered out automatically. See :ref:`supported-identifier-types` for " -"details and an example." +"uidme_uguid, yelp_userid, orcid, qq_id, bilibili_id. Sites whose type does " +"not match are filtered out automatically. See " +":ref:`supported-identifier-types` for details and an example." msgstr "" "``--id-type`` —— 指定标识符类型(默认:username)。支持的类型有:gaia_id、" "steam_id、vk_id、yandex_public_id、ok_id、wikimapia_uid、uidme_uguid、" -"yelp_userid、orcid、qq_id。类型不匹配的站点会被自动筛除。详情及示例见 " -":ref:`supported-identifier-types`。" +"yelp_userid、orcid、qq_id、bilibili_id。类型不匹配的站点会被自动筛除。详情及" +"示例见 :ref:`supported-identifier-types`。" #: ../../source/command-line-options.rst:104 ef2bfbd405b1471abfed99b2b82974d7 msgid "" diff --git a/docs/source/locale/zh_CN/LC_MESSAGES/supported-identifier-types.po b/docs/source/locale/zh_CN/LC_MESSAGES/supported-identifier-types.po index 94c06ee..bd3cfcf 100644 --- a/docs/source/locale/zh_CN/LC_MESSAGES/supported-identifier-types.po +++ b/docs/source/locale/zh_CN/LC_MESSAGES/supported-identifier-types.po @@ -85,7 +85,15 @@ msgid "" "profile id." msgstr "**qq_id** —— QQ(腾讯)的数字账号,同时用作 Qzone 空间的用户 id。" -#: ../../source/supported-identifier-types.rst:18 +#: ../../source/supported-identifier-types.rst:17 +msgid "" +"**bilibili_id** - Bilibili numeric user id (the ``mid`` in a " +"``space.bilibili.com/{mid}`` profile URL)." +msgstr "" +"**bilibili_id** —— Bilibili 的数字用户 id(即 ``space.bilibili.com/{mid}`` " +"个人主页 URL 中的 ``mid``)。" + +#: ../../source/supported-identifier-types.rst:19 msgid "Example" msgstr "示例" @@ -107,3 +115,19 @@ msgstr "" "Maigret 通过 Qzone 头像 API 解析该账号;找到后会提取昵称和头像。凡是 ``type`` " "与所给 ``--id-type`` 不匹配的站点都会被跳过,因此直接运行 ``maigret 10001``" "(默认为 ``username``)不会查询 QQ。" + +#: ../../source/supported-identifier-types.rst:35 +msgid "" +"Or, to look up the Bilibili user id ``2`` (the ``mid`` from " +"``space.bilibili.com/2``):" +msgstr "" +"或者,查询 Bilibili 用户 id ``2``(即 ``space.bilibili.com/2`` 中的 " +"``mid``):" + +#: ../../source/supported-identifier-types.rst:41 +msgid "" +"Maigret resolves the account via the Bilibili user-card API and, when found, " +"extracts the nickname, avatar, signature and follower count." +msgstr "" +"Maigret 通过 Bilibili 用户名片 API 解析该账号;找到后会提取昵称、头像、" +"签名和粉丝数。" diff --git a/docs/source/supported-identifier-types.rst b/docs/source/supported-identifier-types.rst index fc32a4d..5809cf7 100644 --- a/docs/source/supported-identifier-types.rst +++ b/docs/source/supported-identifier-types.rst @@ -14,6 +14,7 @@ Maigret can search against not only ordinary usernames, but also through certain - **ok_id** - OK.ru inner numeric user identifier. - **yelp_userid** - Yelp inner user identifier. - **qq_id** - QQ (Tencent) numeric account number, also used as the Qzone profile id. +- **bilibili_id** - Bilibili numeric user id (the ``mid`` in a ``space.bilibili.com/{mid}`` profile URL). Example ------- @@ -25,3 +26,11 @@ Pass the identifier as the target and select its type with ``--id-type``. For ex $ maigret 10001 --id-type qq_id Maigret resolves the account via the Qzone portrait API and, when found, extracts the nickname and avatar. Any site whose ``type`` does not match the given ``--id-type`` is skipped, so a plain ``maigret 10001`` (default ``username``) will not query QQ. + +Or, to look up the Bilibili user id ``2`` (the ``mid`` from ``space.bilibili.com/2``): + +.. code-block:: console + + $ maigret 2 --id-type bilibili_id + +Maigret resolves the account via the Bilibili user-card API and, when found, extracts the nickname, avatar, signature and follower count. diff --git a/maigret/checking.py b/maigret/checking.py index 8bda036..0c9fd80 100644 --- a/maigret/checking.py +++ b/maigret/checking.py @@ -70,6 +70,7 @@ SUPPORTED_IDS = ( "yelp_userid", "orcid", "qq_id", + "bilibili_id", ) BAD_CHARS = "#" diff --git a/maigret/resources/data.json b/maigret/resources/data.json index 178b0fc..648b785 100644 --- a/maigret/resources/data.json +++ b/maigret/resources/data.json @@ -22,6 +22,26 @@ "social" ] }, + "Bilibili": { + "type": "bilibili_id", + "regexCheck": "^[1-9][0-9]{0,14}$", + "checkType": "message", + "presenseStrs": [ + "\"card\":{" + ], + "absenceStrs": [ + "啥都木有" + ], + "urlProbe": "https://api.bilibili.com/x/web-interface/card?mid={username}", + "url": "https://space.bilibili.com/{username}", + "urlMain": "https://www.bilibili.com/", + "usernameClaimed": "2", + "usernameUnclaimed": "999999999999", + "tags": [ + "cn", + "video" + ] + }, "Facebook": { "regexCheck": "^[a-zA-Z0-9_\\.]{3,49}(?