improve
added video name, duration when starting streaming youtube video
This commit is contained in:
parent
22b076260f
commit
3723ae6eb5
@ -52,8 +52,8 @@ def youtube(url: str):
|
|||||||
params = {"format": "best[height=?480]/best", "noplaylist": True}
|
params = {"format": "best[height=?480]/best", "noplaylist": True}
|
||||||
yt = YoutubeDL(params)
|
yt = YoutubeDL(params)
|
||||||
info = yt.extract_info(url, download=False)
|
info = yt.extract_info(url, download=False)
|
||||||
return info['url']
|
return info['url'], return info['title'], return info['duration']
|
||||||
except ExtractorError: # do whatever
|
except ExtractorError:
|
||||||
return
|
return
|
||||||
except Exception:
|
except Exception:
|
||||||
return
|
return
|
||||||
@ -70,7 +70,7 @@ async def startvideo(client, m: Message):
|
|||||||
livelink = m.text.split(None, 1)[1]
|
livelink = m.text.split(None, 1)[1]
|
||||||
chat_id = m.chat.id
|
chat_id = m.chat.id
|
||||||
try:
|
try:
|
||||||
livelink = await asyncio.wait_for(
|
livelink, title, duration = await asyncio.wait_for(
|
||||||
app.loop.run_in_executor(
|
app.loop.run_in_executor(
|
||||||
None,
|
None,
|
||||||
lambda : youtube(livelink)
|
lambda : youtube(livelink)
|
||||||
@ -111,7 +111,11 @@ async def startvideo(client, m: Message):
|
|||||||
),
|
),
|
||||||
stream_type=StreamType().local_stream,
|
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()
|
await idle()
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
await msg.edit(f"🚫 **error** | `{e}`")
|
await msg.edit(f"🚫 **error** | `{e}`")
|
||||||
|
Loading…
Reference in New Issue
Block a user