add duration info for local audio

This commit is contained in:
levina 2022-01-25 21:01:19 +07:00 committed by GitHub
parent 2d5e9ce838
commit 135b90b32d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -109,16 +109,18 @@ async def play(c: Client, m: Message):
suhu = await replied.reply("📥 **downloading audio...**") suhu = await replied.reply("📥 **downloading audio...**")
dl = await replied.download() dl = await replied.download()
link = replied.link link = replied.link
try:
if replied.audio: if replied.audio:
if replied.audio.title:
songname = replied.audio.title[:70] songname = replied.audio.title[:70]
else:
if replied.audio.file_name:
songname = replied.audio.file_name[:70] songname = replied.audio.file_name[:70]
else: duration = replied.audio.duration
songname = "Audio"
elif replied.voice: elif replied.voice:
songname = "Voice Note" songname = "Voice Note"
duration = replied.voice.duration
except BaseException:
songname = "Audio"
if chat_id in QUEUE: if chat_id in QUEUE:
pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0) pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0)
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
@ -127,7 +129,7 @@ async def play(c: Client, m: Message):
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_1}", photo=f"{IMG_1}",
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
) )
else: else:
try: try:
@ -146,7 +148,7 @@ async def play(c: Client, m: Message):
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_2}", photo=f"{IMG_2}",
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
) )
except Exception as e: except Exception as e:
await suhu.delete() await suhu.delete()