fix: bilibili BV filter

This commit is contained in:
xtaodada 2024-08-19 21:25:26 +08:00
parent 7f411871d1
commit 0d14b0fdfe
Signed by: xtaodada
GPG Key ID: 4CBB3F4FA8C85659
2 changed files with 9 additions and 4 deletions

View File

@ -20,7 +20,7 @@ from scheduler import scheduler
@bot.on_message( @bot.on_message(
filters.incoming filters.incoming
& filters.text & filters.text
& filters.regex(r"av(\d{1,12})|BV(1[A-Za-z0-9]{2}4.1.7[A-Za-z0-9]{2})|b23.tv") & filters.regex(r"av(\d{1,12})|BV(\w{10})|b23.tv")
& ~( & ~(
filters.command(["download", "bilibili_fav"]) filters.command(["download", "bilibili_fav"])
& (filters.user(bili_auth_user) | filters.chat(bili_auth_chat)) & (filters.user(bili_auth_user) | filters.chat(bili_auth_chat))
@ -32,7 +32,7 @@ async def bili_resolve(_: Client, message: Message):
""" """
if "b23.tv" in message.text: if "b23.tv" in message.text:
message.text = await b23_extract(message.text) message.text = await b23_extract(message.text)
p = re.compile(r"av(\d{1,12})|BV(1[A-Za-z0-9]{2}4.1.7[A-Za-z0-9]{2})") p = re.compile(r"av(\d{1,12})|BV(\w{10})|b23.tv")
video_number = p.search(message.text) video_number = p.search(message.text)
if video_number: if video_number:
video_number = video_number[0] video_number = video_number[0]

View File

@ -19,7 +19,7 @@ from models.services.bilifav import BiliFavAction
async def bili_download_resolve(_: Client, message: Message): async def bili_download_resolve(_: Client, message: Message):
if "b23.tv" in message.text: if "b23.tv" in message.text:
message.text = await b23_extract(message.text) message.text = await b23_extract(message.text)
p = re.compile(r"av(\d{1,12})|BV(1[A-Za-z0-9]{2}4.1.7[A-Za-z0-9]{2})") p = re.compile(r"av(\d{1,12})|BV(\w{10})|b23.tv")
video_number = p.search(message.text) video_number = p.search(message.text)
if video_number: if video_number:
video_number = video_number[0] video_number = video_number[0]
@ -80,9 +80,14 @@ async def bili_download_resolve_cb(_: Client, callback_query: CallbackQuery):
video = create_video(video_number) video = create_video(video_number)
if video_db := await BiliFavAction.get_by_bv_id(video.get_bvid()): if video_db := await BiliFavAction.get_by_bv_id(video.get_bvid()):
await callback_query.answer("找到缓存") await callback_query.answer("找到缓存")
caption = (
f"详细信息https://t.me/{bilifav_channel_username}/{video_db.message_id}"
if video_db.message_id
else None
)
await callback_query.message.reply_video( await callback_query.message.reply_video(
video_db.file_id, video_db.file_id,
caption=f"详细信息https://t.me/{bilifav_channel_username}/{video_db.message_id}", caption=caption,
quote=True, quote=True,
) )
raise ContinuePropagation raise ContinuePropagation