Spaces:
Runtime error
Runtime error
File size: 8,802 Bytes
80287e2 |
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 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
from pyrogram import filters
from pyrogram.types import InlineKeyboardMarkup, Message
import config
from Devine import YouTube, app
from Devine.core.call import Anony
from Devine.misc import db
from Devine.utils.database import get_loop
from Devine.utils.decorators import AdminRightsCheck
from Devine.utils.inline import close_markup, stream_markup
from Devine.utils.stream.autoclear import auto_clean
from Devine.utils.thumbnails import get_thumb
from config import BANNED_USERS
@app.on_message(
filters.command(["skip", "cskip", "next", "cnext"]) & filters.group & ~BANNED_USERS
)
@AdminRightsCheck
async def skip(cli, message: Message, _, chat_id):
if not len(message.command) < 2:
loop = await get_loop(chat_id)
if loop != 0:
return await message.reply_text(_["admin_8"])
state = message.text.split(None, 1)[1].strip()
if state.isnumeric():
state = int(state)
check = db.get(chat_id)
if check:
count = len(check)
if count > 2:
count = int(count - 1)
if 1 <= state <= count:
for x in range(state):
popped = None
try:
popped = check.pop(0)
except:
return await message.reply_text(_["admin_12"])
if popped:
await auto_clean(popped)
if not check:
try:
await message.reply_text(
text=_["admin_6"].format(
message.from_user.mention,
message.chat.title,
),
reply_markup=close_markup(_),
)
await Anony.stop_stream(chat_id)
except:
return
break
else:
return await message.reply_text(_["admin_11"].format(count))
else:
return await message.reply_text(_["admin_10"])
else:
return await message.reply_text(_["queue_2"])
else:
return await message.reply_text(_["admin_9"])
else:
check = db.get(chat_id)
popped = None
try:
popped = check.pop(0)
if popped:
await auto_clean(popped)
if not check:
await message.reply_text(
text=_["admin_6"].format(
message.from_user.mention, message.chat.title
),
reply_markup=close_markup(_),
)
try:
return await Anony.stop_stream(chat_id)
except:
return
except:
try:
await message.reply_text(
text=_["admin_6"].format(
message.from_user.mention, message.chat.title
),
reply_markup=close_markup(_),
)
return await Anony.stop_stream(chat_id)
except:
return
queued = check[0]["file"]
title = (check[0]["title"]).title()
user = check[0]["by"]
streamtype = check[0]["streamtype"]
videoid = check[0]["vidid"]
status = True if str(streamtype) == "video" else None
db[chat_id][0]["played"] = 0
exis = (check[0]).get("old_dur")
if exis:
db[chat_id][0]["dur"] = exis
db[chat_id][0]["seconds"] = check[0]["old_second"]
db[chat_id][0]["speed_path"] = None
db[chat_id][0]["speed"] = 1.0
if "live_" in queued:
n, link = await YouTube.video(videoid, True)
if n == 0:
return await message.reply_text(_["admin_7"].format(title))
try:
image = await YouTube.thumbnail(videoid, True)
except:
image = None
try:
await Anony.skip_stream(chat_id, link, video=status, image=image)
except:
return await message.reply_text(_["call_6"])
button = stream_markup(_, chat_id)
img = await get_thumb(videoid)
run = await message.reply_photo(
photo=img,
caption=_["stream_1"].format(
f"https://t.me/{app.username}?start=info_{videoid}",
title[:23],
check[0]["dur"],
user,
),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
db[chat_id][0]["markup"] = "tg"
elif "vid_" in queued:
mystic = await message.reply_text(_["call_7"], disable_web_page_preview=True)
try:
file_path, direct = await YouTube.download(
videoid,
mystic,
videoid=True,
video=status,
)
except:
return await mystic.edit_text(_["call_6"])
try:
image = await YouTube.thumbnail(videoid, True)
except:
image = None
try:
await Anony.skip_stream(chat_id, file_path, video=status, image=image)
except:
return await mystic.edit_text(_["call_6"])
button = stream_markup(_, chat_id)
img = await get_thumb(videoid)
run = await message.reply_photo(
photo=img,
caption=_["stream_1"].format(
f"https://t.me/{app.username}?start=info_{videoid}",
title[:23],
check[0]["dur"],
user,
),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
db[chat_id][0]["markup"] = "stream"
await mystic.delete()
elif "index_" in queued:
try:
await Anony.skip_stream(chat_id, videoid, video=status)
except:
return await message.reply_text(_["call_6"])
button = stream_markup(_, chat_id)
run = await message.reply_photo(
photo=config.STREAM_IMG_URL,
caption=_["stream_2"].format(user),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
db[chat_id][0]["markup"] = "tg"
else:
if videoid == "telegram":
image = None
elif videoid == "soundcloud":
image = None
else:
try:
image = await YouTube.thumbnail(videoid, True)
except:
image = None
try:
await Anony.skip_stream(chat_id, queued, video=status, image=image)
except:
return await message.reply_text(_["call_6"])
if videoid == "telegram":
button = stream_markup(_, chat_id)
run = await message.reply_photo(
photo=config.TELEGRAM_AUDIO_URL
if str(streamtype) == "audio"
else config.TELEGRAM_VIDEO_URL,
caption=_["stream_1"].format(
config.SUPPORT_CHAT, title[:23], check[0]["dur"], user
),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
db[chat_id][0]["markup"] = "tg"
elif videoid == "soundcloud":
button = stream_markup(_, chat_id)
run = await message.reply_photo(
photo=config.SOUNCLOUD_IMG_URL
if str(streamtype) == "audio"
else config.TELEGRAM_VIDEO_URL,
caption=_["stream_1"].format(
config.SUPPORT_CHAT, title[:23], check[0]["dur"], user
),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
db[chat_id][0]["markup"] = "tg"
else:
button = stream_markup(_, chat_id)
img = await get_thumb(videoid)
run = await message.reply_photo(
photo=img,
caption=_["stream_1"].format(
f"https://t.me/{app.username}?start=info_{videoid}",
title[:23],
check[0]["dur"],
user,
),
reply_markup=InlineKeyboardMarkup(button),
)
db[chat_id][0]["mystic"] = run
db[chat_id][0]["markup"] = "stream"
|