added video name, duration when starting streaming youtube video
This commit is contained in:
levina 2021-09-13 05:47:27 +07:00 committed by GitHub
parent 22b076260f
commit 3723ae6eb5
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -52,8 +52,8 @@ def youtube(url: str):
params = {"format": "best[height=?480]/best", "noplaylist": True}
yt = YoutubeDL(params)
info = yt.extract_info(url, download=False)
return info['url']
except ExtractorError: # do whatever
return info['url'], return info['title'], return info['duration']
except ExtractorError:
return
except Exception:
return
@ -70,7 +70,7 @@ async def startvideo(client, m: Message):
livelink = m.text.split(None, 1)[1]
chat_id = m.chat.id
try:
livelink = await asyncio.wait_for(
livelink, title, duration = await asyncio.wait_for(
app.loop.run_in_executor(
None,
lambda : youtube(livelink)
@ -111,7 +111,11 @@ async def startvideo(client, m: Message):
),
stream_type=StreamType().local_stream,
)
await msg.edit("💡 **video streaming started!**\n\n» **join to video chat on the top to watch the video.**")
await msg.edit(
"💡 **video streaming started!**\n"
f"\n🏷 **Name:** {title}"
f"⏱ **Duration:** {duration}\n"
f"\n» **join to video chat on the top to watch the video.**")
await idle()
except Exception as e:
await msg.edit(f"🚫 **error** | `{e}`")