forked from sultansq/kiu
-
Notifications
You must be signed in to change notification settings - Fork 0
/
seek.py
78 lines (75 loc) · 2.58 KB
/
seek.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
from pyrogram import filters
from pyrogram.types import Message
from strings.filters import command
from config import BANNED_USERS
from strings import get_command
from AnonX import YouTube, app
from AnonX.core.call import Anon
from AnonX.misc import db
from AnonX.utils import AdminRightsCheck, seconds_to_min
# Commands
SEEK_COMMAND = get_command("SEEK_COMMAND")
@app.on_message(
command(SEEK_COMMAND)
& filters.group
& ~BANNED_USERS
)
@AdminRightsCheck
async def seek_comm(cli, message: Message, _, chat_id):
if len(message.command) == 1:
return await message.reply_text(_["admin_28"])
query = message.text.split(None, 1)[1].strip()
if not query.isnumeric():
return await message.reply_text(_["admin_29"])
playing = db.get(chat_id)
if not playing:
return await message.reply_text(_["queue_2"])
duration_seconds = int(playing[0]["seconds"])
if duration_seconds == 0:
return await message.reply_text(_["admin_30"])
file_path = playing[0]["file"]
if "index_" in file_path or "live_" in file_path:
return await message.reply_text(_["admin_30"])
duration_played = int(playing[0]["played"])
duration_to_skip = int(query)
duration = playing[0]["dur"]
if message.command[0][-2] == "c":
if (duration_played - duration_to_skip) <= 10:
return await message.reply_text(
_["admin_31"].format(
seconds_to_min(duration_played), duration
)
)
to_seek = duration_played - duration_to_skip + 1
else:
if (
duration_seconds - (duration_played + duration_to_skip)
) <= 10:
return await message.reply_text(
_["admin_31"].format(
seconds_to_min(duration_played), duration
)
)
to_seek = duration_played + duration_to_skip + 1
mystic = await message.reply_text(_["admin_32"])
if "vid_" in file_path:
n, file_path = await YouTube.video(playing[0]["vidid"], True)
if n == 0:
return await message.reply_text(_["admin_30"])
try:
await Anon.seek_stream(
chat_id,
file_path,
seconds_to_min(to_seek),
duration,
playing[0]["streamtype"],
)
except:
return await mystic.edit_text(_["admin_34"])
if message.command[0][-2] == "c":
db[chat_id][0]["played"] -= duration_to_skip
else:
db[chat_id][0]["played"] += duration_to_skip
await mystic.edit_text(
_["admin_33"].format(seconds_to_min(to_seek))
)