From 39c726a8bcf47c71c7d5479c94af714e6d9b255c Mon Sep 17 00:00:00 2001 From: xtaodada Date: Fri, 18 Aug 2023 18:22:07 +0800 Subject: [PATCH] :bug: Fix audio media name --- defs/bilibili_download.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/defs/bilibili_download.py b/defs/bilibili_download.py index c068d8c..eb633e1 100644 --- a/defs/bilibili_download.py +++ b/defs/bilibili_download.py @@ -224,7 +224,11 @@ async def audio_download(a: Audio, m: Message): async with AsyncClient(headers=HEADERS, timeout=60) as client: r = await client.get(download_url_data["cdns"][0]) media = BytesIO(r.content) - media.name = None + ext = download_url_data["cdns"][0].split("?")[0].split(".")[-1] + if ext: + media.name = f"{info['title']}.{ext}" + else: + media.name = f"{info['title']}.mp3" media.seek(0) if info.get("cover"): r_ = await client.get(info.get("cover"))