some fixes
This commit is contained in:
parent
685ede5a86
commit
df451012fe
@ -23,17 +23,15 @@ from pytgcalls.types.input_stream.quality import (
|
||||
from youtubesearchpython import VideosSearch
|
||||
|
||||
|
||||
def ytsearch(query):
|
||||
def ytsearch(query: str):
|
||||
try:
|
||||
search = VideosSearch(query, limit=1)
|
||||
for r in search.result()["result"]:
|
||||
ytid = r["id"]
|
||||
if len(r["title"]) > 34:
|
||||
songname = r["title"][:70]
|
||||
else:
|
||||
songname = r["title"]
|
||||
url = f"https://www.youtube.com/watch?v={ytid}"
|
||||
return [songname, url]
|
||||
search = VideosSearch(query, limit=1).result()
|
||||
data = search["result"][0]
|
||||
songname = data["title"]
|
||||
url = data["link"]
|
||||
duration = data["duration"]
|
||||
thumbnail = f"https://i.ytimg.com/vi/{data['id']}/hqdefault.jpg"
|
||||
return [songname, url, duration, thumbnail]
|
||||
except Exception as e:
|
||||
print(e)
|
||||
return 0
|
||||
@ -58,6 +56,7 @@ async def ytdl(link):
|
||||
|
||||
@Client.on_message(command(["vplay", f"vplay@{BOT_USERNAME}"]) & other_filters)
|
||||
async def vplay(c: Client, m: Message):
|
||||
await m.delete()
|
||||
replied = m.reply_to_message
|
||||
chat_id = m.chat.id
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
@ -69,7 +68,7 @@ async def vplay(c: Client, m: Message):
|
||||
]
|
||||
)
|
||||
if m.sender_chat:
|
||||
return await m.reply_text("you're an __Anonymous Admin__ !\n\n» revert back to user account from admin rights.")
|
||||
return await m.reply_text("you're an __Anonymous__ Admin !\n\n» revert back to user account from admin rights.")
|
||||
try:
|
||||
aing = await c.get_me()
|
||||
except Exception as e:
|
||||
@ -199,6 +198,8 @@ async def vplay(c: Client, m: Message):
|
||||
else:
|
||||
songname = search[0]
|
||||
url = search[1]
|
||||
duration = search[2]
|
||||
thumbnail = search[3]
|
||||
veez, ytlink = await ytdl(url)
|
||||
if veez == 0:
|
||||
await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`")
|
||||
@ -210,8 +211,8 @@ async def vplay(c: Client, m: Message):
|
||||
await loser.delete()
|
||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||
await m.reply_photo(
|
||||
photo=f"{IMG_1}",
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {requester}",
|
||||
photo=thumbnail",
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url})\n⏱ **Duration:** `{duration}`\n🎧 **Request by:** {requester}",
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
else:
|
||||
@ -230,8 +231,8 @@ async def vplay(c: Client, m: Message):
|
||||
await loser.delete()
|
||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||
await m.reply_photo(
|
||||
photo=f"{IMG_2}",
|
||||
caption=f"💡 **Video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}",
|
||||
photo=thumbnail,
|
||||
caption=f"💡 **Video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n⏱ **Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}",
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
except Exception as ep:
|
||||
@ -254,6 +255,8 @@ async def vplay(c: Client, m: Message):
|
||||
else:
|
||||
songname = search[0]
|
||||
url = search[1]
|
||||
duration = search[2]
|
||||
thumbnail = search[3]
|
||||
veez, ytlink = await ytdl(url)
|
||||
if veez == 0:
|
||||
await loser.edit(f"❌ yt-dl issues detected\n\n» `{ytlink}`")
|
||||
@ -265,8 +268,8 @@ async def vplay(c: Client, m: Message):
|
||||
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||
)
|
||||
await m.reply_photo(
|
||||
photo=f"{IMG_1}",
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n🎧 **Request by:** {requester}",
|
||||
photo=thumbnail,
|
||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🏷 **Name:** [{songname}]({url})\n⏱ **Duration:** `{duration}`\n🎧 **Request by:** {requester}",
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
else:
|
||||
@ -285,8 +288,8 @@ async def vplay(c: Client, m: Message):
|
||||
await loser.delete()
|
||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||
await m.reply_photo(
|
||||
photo=f"{IMG_2}",
|
||||
caption=f"💡 **Video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n💭 **Chat:** `{chat_id}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}",
|
||||
photo=thumbnail,
|
||||
caption=f"💡 **Video streaming started.**\n\n🏷 **Name:** [{songname}]({url})\n⏱ **Duration:** `{duration}`\n💡 **Status:** `Playing`\n🎧 **Request by:** {requester}",
|
||||
reply_markup=keyboard,
|
||||
)
|
||||
except Exception as ep:
|
||||
@ -296,7 +299,7 @@ async def vplay(c: Client, m: Message):
|
||||
|
||||
@Client.on_message(command(["vstream", f"vstream@{BOT_USERNAME}"]) & other_filters)
|
||||
async def vstream(c: Client, m: Message):
|
||||
m.reply_to_message
|
||||
await m.delete()
|
||||
chat_id = m.chat.id
|
||||
keyboard = InlineKeyboardMarkup(
|
||||
[
|
||||
@ -307,7 +310,7 @@ async def vstream(c: Client, m: Message):
|
||||
]
|
||||
)
|
||||
if m.sender_chat:
|
||||
return await m.reply_text("you're an __Anonymous Admin__ !\n\n» revert back to user account from admin rights.")
|
||||
return await m.reply_text("you're an __Anonymous__ Admin !\n\n» revert back to user account from admin rights.")
|
||||
try:
|
||||
aing = await c.get_me()
|
||||
except Exception as e:
|
||||
@ -348,12 +351,14 @@ async def vstream(c: Client, m: Message):
|
||||
return
|
||||
else:
|
||||
try:
|
||||
user_id = (await user.get_me()).id
|
||||
link = await c.export_chat_invite_link(chat_id)
|
||||
if "+" in link:
|
||||
link_hash = (link.replace("+", "")).split("t.me/")[1]
|
||||
await ubot.join_chat(link_hash)
|
||||
await c.promote_member(chat_id, user_id)
|
||||
invitelink = await c.export_chat_invite_link(
|
||||
m.chat.id
|
||||
)
|
||||
if invitelink.startswith("https://t.me/+"):
|
||||
invitelink = invitelink.replace(
|
||||
"https://t.me/+", "https://t.me/joinchat/"
|
||||
)
|
||||
await user.join_chat(invitelink)
|
||||
except UserAlreadyParticipant:
|
||||
pass
|
||||
except Exception as e:
|
||||
|
Loading…
Reference in New Issue
Block a user