mirror of
https://github.com/suyiiyii/nonebot-bison.git
synced 2025-06-08 04:43:00 +08:00
update bilibili-bangumi parser
This commit is contained in:
parent
9cd7e95a58
commit
f6a816a716
@ -46,10 +46,8 @@ class Bilibili(NewMessage):
|
|||||||
async def parse_target(self, target_text: str) -> Target:
|
async def parse_target(self, target_text: str) -> Target:
|
||||||
if re.match(r"\d+", target_text):
|
if re.match(r"\d+", target_text):
|
||||||
return Target(target_text)
|
return Target(target_text)
|
||||||
elif match := re.match(
|
elif m := re.match(r"(?:https?://)?space\.bilibili\.com/(\d+)", target_text):
|
||||||
r"(?:https?://)?space\.bilibili\.com/(\d+)", target_text
|
return Target(m.group(1))
|
||||||
):
|
|
||||||
return Target(match.group(1))
|
|
||||||
else:
|
else:
|
||||||
raise self.ParseTargetException()
|
raise self.ParseTargetException()
|
||||||
|
|
||||||
@ -241,6 +239,7 @@ class BilibiliBangumi(StatusChange):
|
|||||||
scheduler_class = "bilibili.com"
|
scheduler_class = "bilibili.com"
|
||||||
name = "Bilibili剧集"
|
name = "Bilibili剧集"
|
||||||
has_target = True
|
has_target = True
|
||||||
|
parse_target_promot = "请输入剧集主页"
|
||||||
|
|
||||||
_url = "https://api.bilibili.com/pgc/review/user"
|
_url = "https://api.bilibili.com/pgc/review/user"
|
||||||
|
|
||||||
@ -252,6 +251,17 @@ class BilibiliBangumi(StatusChange):
|
|||||||
return None
|
return None
|
||||||
return res_data["result"]["media"]["title"]
|
return res_data["result"]["media"]["title"]
|
||||||
|
|
||||||
|
async def parse_target(self, target_string: str) -> Target:
|
||||||
|
if re.match(r"\d+", target_string):
|
||||||
|
return Target(target_string)
|
||||||
|
elif m := re.match(r"md(\d+)", target_string):
|
||||||
|
return Target(m.group(1))
|
||||||
|
elif m := re.match(
|
||||||
|
r"(?:https?://)?www\.bilibili\.com/bangumi/media/md(\d+)/", target_string
|
||||||
|
):
|
||||||
|
return Target(m.group(1))
|
||||||
|
raise self.ParseTargetException()
|
||||||
|
|
||||||
async def get_status(self, target: Target):
|
async def get_status(self, target: Target):
|
||||||
async with http_client() as client:
|
async with http_client() as client:
|
||||||
res = await client.get(
|
res = await client.get(
|
||||||
|
Loading…
x
Reference in New Issue
Block a user