Skip to content

Commit

Permalink
OpenCV error fixed
Browse files Browse the repository at this point in the history
  • Loading branch information
SantiiRepair committed Aug 8, 2023
1 parent ba8c02f commit 099dad1
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 13 deletions.
9 changes: 5 additions & 4 deletions bot/plugins/play_song.py
Original file line number Diff line number Diff line change
Expand Up @@ -23,7 +23,7 @@
owner = "1669178360"

dir = os.path.dirname(os.path.abspath(__file__))
download_as = os.path.join(dir, f"../downloads/songs/{str(uuid.uuid4())}")

queues = os.path.join(dir, "../dbs/queues.pkl")


Expand Down Expand Up @@ -63,8 +63,9 @@ async def play_song(event):
replied = await event.get_reply_message()
chat = await event.get_chat()
msg = await event.reply("🔄 **__Processing...__**")
await sleep(2)
from_user = vcmention(event.sender)
await sleep(2)
download_as = os.path.join(dir, f"../downloads/songs/{str(uuid.uuid4())}")
if not replied and not " " in event.message.message:
await msg.edit(
"❗ __Master, try with an: \n\nSending song name.\n\nYouTube video link.\n\nReply to an audio file.__",
Expand All @@ -84,13 +85,13 @@ async def play_song(event):
)
elif VOICE_CHATS.get(chat.id) is None:
try:
await msg.edit("__Joining the voice chat...__")
await msg.edit("**__Joining the voice chat...__**")
await ins.join(chat.id)
VOICE_CHATS[chat.id] = ins
await sleep(2)
except Exception as e:
await msg.edit(
f"__Oops master, something wrong has happened. \n\nError:__ `{e}`",
f"__Oops master, something wrong has happened.__ \n\n`Error: {e}`",
)
await VOICE_CHATS[chat.id].stop()
VOICE_CHATS.pop(chat.id)
Expand Down
19 changes: 10 additions & 9 deletions bot/plugins/play_video.py
Original file line number Diff line number Diff line change
Expand Up @@ -17,7 +17,7 @@
thumb = "https://telegra.ph/file/3e14128ad5c9ec47801bd.jpg"

dir = os.path.dirname(os.path.abspath(__file__))
download_as = os.path.join(dir, f"../downloads/videos/{str(uuid.uuid4())}")

queues = os.path.join(dir, "../dbs/queues.pkl")

ydl = YoutubeDL({
Expand All @@ -34,6 +34,7 @@ async def play_video(event):
replied = await event.get_reply_message()
msg = await event.reply("🔄 **__Processing...__**")
await sleep(2)
download_as = os.path.join(dir, f"../downloads/videos/{str(uuid.uuid4())}")
if not replied and not " " in event.message.message:
await msg.edit(
"❗ __Master, try with an: \n\nLive stream link.\n\nYouTube video link.\n\nReply to an video to start video streaming!__",
Expand All @@ -50,19 +51,19 @@ async def play_video(event):
match = re.match(regex, url)
if VOICE_CHATS.get(chat.id) is None:
try:
await msg.edit("__Joining the voice chat...__")
await msg.edit("**__Joining the voice chat...__**")
await ins.join(chat.id)
VOICE_CHATS[chat.id] = ins
await sleep(2)
except Exception as e:
await msg.edit(
f"__Oops master, something wrong has happened. \n\nError:__ `{e}`",
f"__Oops master, something wrong has happened.__ \n\n`Error: {e}`",
)
await VOICE_CHATS[chat.id].stop()
VOICE_CHATS.pop(chat.id)
return await sleep(2)
if match:
await msg.edit("🔄 __Starting YouTube video stream...__")
await msg.edit("🔄 **__Starting YouTube video stream...__**")
try:
meta = ydl.extract_info(url=url, download=False)
formats = meta.get("formats", [meta])
Expand All @@ -76,22 +77,22 @@ async def play_video(event):
thumb = split[0].strip()
except Exception as e:
await msg.edit(
f"❌ __Master, YouTube download error!</i> \n\n`Error: {e}`",
f"❌ __Master, YouTube download error!__ \n\n`Error: {e}`",
)
print(e)
await VOICE_CHATS[chat.id].stop()
VOICE_CHATS.pop(chat.id)
return await sleep(2)

else:
await msg.edit("🔄 __Starting live video stream...__")
await msg.edit("🔄 **__Starting live video stream...__**")

try:
await sleep(2)
await ins.start_video(url, with_audio=True, repeat=False)
await msg.delete()
await msg.edit(
"\U00002378 __Started video streaming!__",
"\U00002378 **Started video streaming!**",
file=thumb,
buttons=[
[
Expand All @@ -113,15 +114,15 @@ async def play_video(event):
return await sleep(2)

elif replied.video or replied.file:
await msg.edit("🔄 __Downloading...__")
await msg.edit("🔄 **__Downloading...__**")
video = await client.download_media(replied, file=download_as)

try:
await sleep(2)
await ins.start_video(video, with_audio=True, repeat=False)
await msg.delete()
await event.reply(
"▶️ __Started video streaming!__",
"**Started video streaming!**",
file=thumb,
buttons=[
[
Expand Down

0 comments on commit 099dad1

Please sign in to comment.