[check] something

This commit is contained in:
levina 2022-02-21 06:30:34 +07:00 committed by GitHub
parent ba5170a35f
commit c5096876e0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -425,49 +425,60 @@ async def vstream(c: Client, m: Message):
) )
if len(m.command) < 2: if len(m.command) < 2:
await m.reply("» give me a live-link/m3u8 url/youtube link to stream.") await m.reply("» Give me a youtube live url/m3u8 url to stream.")
else: else:
if len(m.command) == 2: if len(m.command) == 2:
link = m.text.split(None, 1)[1]
Q = 720 Q = 720
url = m.text.split(None, 1)[1]
search = ytsearch(url)
loser = await c.send_message(chat_id, "🔍 **Loading...**") loser = await c.send_message(chat_id, "🔍 **Loading...**")
elif len(m.command) == 3: elif len(m.command) == 3:
op = m.text.split(None, 1)[1] op = m.text.split(None, 1)[1]
link = op.split(None, 1)[0] url = op.split(None, 1)[0]
quality = op.split(None, 1)[1] quality = op.split(None, 1)[1]
search = ytsearch(op)
if quality == "720" or "480" or "360": if quality == "720" or "480" or "360":
Q = int(quality) Q = int(quality)
else: else:
Q = 720 Q = 720
await m.reply( await m.reply(
"» only 720, 480, 360 allowed\n\n💡 now streaming video in **720p**" "» Streaming the video in 720p quality"
) )
loser = await c.send_message(chat_id, "🔍 **Loading...**") loser = await c.send_message(chat_id, "🔍 **Loading...**")
else: else:
await m.reply("`/vstream` {link} {720/480/360}") await m.reply(f"`/vstream` {url} (720/480/360)")
regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+" regex = r"^(https?\:\/\/)?(www\.youtube\.com|youtu\.?be)\/.+"
match = re.match(regex, link) match = re.match(regex, url)
if match: if match:
veez, livelink = await ytdl(link) veez, livelink = await ytdl(url)
else: else:
livelink = link livelink = url
veez = 1 veez = 1
if veez == 0: if veez == 0:
await loser.edit(f"❌ yt-dl issues detected\n\n» `{livelink}`") await loser.edit(f"❌ yt-dl issues detected\n\n» `{livelink}`")
else: else:
title = search[0]
songname = search[0]
thumbnail = search[1]
userid = m.from_user.id
gcname = m.chat.title
ctitle = await CHAT_TITLE(gcname)
image = await thumb(thumbnail, title, userid, ctitle)
if chat_id in QUEUE: if chat_id in QUEUE:
await loser.edit("🔄 Queueing Track...") await loser.edit("🔄 Queueing Track...")
pos = add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) pos = add_to_queue(chat_id, "Live Stream", livelink, url, "Video", Q)
await loser.delete() await loser.delete()
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})"
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_1}", photo=image,
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"💡 **Track added to queue »** `{pos}`\n\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({url}) | `live video`\n🧸 **Requested by:** {requester}",
) )
remove_if_exists(image)
else: else:
if Q == 720: if Q == 720:
amaze = HighQualityVideo() amaze = HighQualityVideo()
@ -488,17 +499,19 @@ async def vstream(c: Client, m: Message):
), ),
stream_type=StreamType().live_stream, stream_type=StreamType().live_stream,
) )
add_to_queue(chat_id, "Live Stream", livelink, link, "Video", Q) add_to_queue(chat_id, "Live Stream", livelink, url, "Video", Q)
await loser.delete() await loser.delete()
requester = ( requester = (
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})" f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
) )
buttons = stream_markup(user_id) buttons = stream_markup(user_id)
await m.reply_photo( await m.reply_photo(
photo=f"{IMG_2}", photo=image",
reply_markup=InlineKeyboardMarkup(buttons), reply_markup=InlineKeyboardMarkup(buttons),
caption=f"💡 **[Video Live]({link}) stream started.**\n\n💭 **Chat:** `{chat_id}`\n🧸 **Request by:** {requester}", caption=f"🗂 **Name:** [{songname}]({url}) | `live video`\n🧸 **Requested by:** {requester}",
) )
await idle()
remove_if_exists(image)
except Exception as ep: except Exception as ep:
await loser.delete() await loser.delete()
await remove_active_chat(chat_id) await remove_active_chat(chat_id)