-
Notifications
You must be signed in to change notification settings - Fork 1
/
live.py
68 lines (66 loc) · 2.19 KB
/
live.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
from pyrogram import filters
from config import BANNED_USERS
from AnonX import YouTube, app
from AnonX.utils.channelplay import get_channeplayCB
from AnonX.utils.decorators.language import languageCB
from AnonX.utils.stream.stream import stream
from strings.filters import command
@app.on_callback_query(filters.regex("LiveStream") & ~BANNED_USERS)
@languageCB
async def play_live_stream(client, CallbackQuery, _):
callback_data = CallbackQuery.data.strip()
callback_request = callback_data.split(None, 1)[1]
vidid, user_id, mode, cplay, fplay = callback_request.split("|")
if CallbackQuery.from_user.id != int(user_id):
try:
return await CallbackQuery.answer(
_["playcb_1"], show_alert=True
)
except:
return
try:
chat_id, channel = await get_channeplayCB(
_, cplay, CallbackQuery
)
except:
return
video = True if mode == "v" else None
user_name = CallbackQuery.from_user.first_name
await CallbackQuery.message.delete()
try:
await CallbackQuery.answer()
except:
pass
mystic = await CallbackQuery.message.reply_text(
_["play_2"].format(channel) if channel else _["play_1"]
)
try:
details, track_id = await YouTube.track(vidid, True)
except Exception:
return await mystic.edit_text(_["play_3"])
ffplay = True if fplay == "f" else None
if not details["duration_min"]:
try:
await stream(
_,
mystic,
user_id,
details,
chat_id,
user_name,
CallbackQuery.message.chat.id,
video,
streamtype="live",
forceplay=ffplay,
)
except Exception as e:
ex_type = type(e).__name__
err = (
e
if ex_type == "AssistantErr"
else _["general_3"].format(ex_type)
)
return await mystic.edit_text(err)
else:
return await mystic.edit_text("ɪ ᴅᴏɴ'ᴛ ᴛʜɪɴᴋ ᴛʜᴀᴛ ɪᴛ's ᴀ ʟɪᴠᴇ sᴛʀᴇᴀᴍ.")
await mystic.delete()