-
-
Notifications
You must be signed in to change notification settings - Fork 13
/
Copy pathvideoplay.py
82 lines (77 loc) · 2.87 KB
/
videoplay.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
# Ultroid - UserBot
# Copyright (C) 2021-2022 TeamUltroid
#
# This file is a part of < https://github.com/TeamUltroid/Ultroid/ >
# PLease read the GNU Affero General Public License in
# <https://www.github.com/TeamUltroid/Ultroid/blob/main/LICENSE/>.
"""
✘ Commands Available
`{i}videoplay <song name/url/m3u8 links/reply to video>`
Stream Videos in chat.
you can use remotely too
like `{i}videoplay @chat <input/reply>`
"""
import re, asyncio
from telethon.errors.rpcerrorlist import ChatSendMediaForbiddenError
from . import vc_asst, Player, get_string, inline_mention, is_url_ok, mediainfo, vid_download, file_download,LOGS
@vc_asst("videoplay")
async def video_c(event):
xx = await event.eor(get_string("com_1"))
chat = event.chat_id
from_user = inline_mention(event.sender)
reply, song = None, None
if event.reply_to:
reply = await event.get_reply_message()
if len(event.text.split()) > 1:
input = event.text.split(maxsplit=1)[1]
tiny_input = input.split()[0]
if tiny_input[0] in ["@", "-"]:
try:
chat = await event.client.parse_id(tiny_input)
except Exception as er:
LOGS.exception(er)
return await xx.edit(str(er))
try:
song = input.split(maxsplit=1)[1]
except BaseException:
pass
else:
song = input
if not (reply or song):
return await xx.eor(get_string("vcbot_15"), time=5)
await xx.eor(get_string("vcbot_20"))
if reply and reply.media and mediainfo(reply.media).startswith("video"):
song, thumb, title, link, duration = await file_download(xx, reply)
else:
is_link = is_url_ok(song)
if is_link is False:
return await xx.eor(f"`{song}`\n\nNot a playable link.🥱")
if is_link is None:
song, thumb, title, link, duration = await vid_download(song)
elif re.search("youtube", song) or re.search("youtu", song):
song, thumb, title, link, duration = await vid_download(song)
else:
song, thumb, title, link, duration = (
song,
"https://telegra.ph/file/22bb2349da20c7524e4db.mp4",
song,
song,
"♾",
)
ultSongs = Player(chat, xx, True)
if not (await ultSongs.vc_joiner()):
return
text = "🎸 **Now playing:** [{}]({})\n⏰ **Duration:** `{}`\n👥 **Chat:** `{}`\n🙋♂ **Requested by:** {}".format(
title, link, duration, chat, from_user
)
try:
await xx.reply(
text,
file=thumb,
link_preview=False,
)
except ChatSendMediaForbiddenError:
await xx.reply(text, link_preview=False)
await asyncio.sleep(1)
await ultSongs.group_call.start_video(song, with_audio=True)
await xx.delete()