File size: 2,778 Bytes
a8e9b84 |
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 |
from pyrogram import filters
from pyrogram.types import Message
from DragMusic import YouTube, app
from DragMusic.core.call import Drag
from DragMusic.misc import db
from DragMusic.utils import AdminRightsCheck, seconds_to_min
from DragMusic.utils.inline import close_markup
from config import BANNED_USERS
@app.on_message(
filters.command(["seek", "cseek", "seekback", "cseekback"])
& 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_20"])
query = message.text.split(None, 1)[1].strip()
if not query.isnumeric():
return await message.reply_text(_["admin_21"])
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_22"])
file_path = playing[0]["file"]
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(
text=_["admin_23"].format(seconds_to_min(duration_played), duration),
reply_markup=close_markup(_),
)
to_seek = duration_played - duration_to_skip + 1
else:
if (duration_seconds - (duration_played + duration_to_skip)) <= 10:
return await message.reply_text(
text=_["admin_23"].format(seconds_to_min(duration_played), duration),
reply_markup=close_markup(_),
)
to_seek = duration_played + duration_to_skip + 1
mystic = await message.reply_text(_["admin_24"])
if "vid_" in file_path:
n, file_path = await YouTube.video(playing[0]["vidid"], True)
if n == 0:
return await message.reply_text(_["admin_22"])
check = (playing[0]).get("speed_path")
if check:
file_path = check
if "index_" in file_path:
file_path = playing[0]["vidid"]
try:
await Drag.seek_stream(
chat_id,
file_path,
seconds_to_min(to_seek),
duration,
playing[0]["streamtype"],
)
except:
return await mystic.edit_text(_["admin_26"], reply_markup=close_markup(_))
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(
text=_["admin_25"].format(seconds_to_min(to_seek), message.from_user.mention),
reply_markup=close_markup(_),
)
|