merge pull request #149 from Xtao-Labs/tg
[feat] support play with telegram url.
This commit is contained in:
commit
56172f2bff
@ -1,6 +1,4 @@
|
|||||||
import asyncio
|
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
from pyrogram.types import User
|
|
||||||
from pytgcalls import PyTgCalls
|
from pytgcalls import PyTgCalls
|
||||||
from config import API_HASH, API_ID, BOT_TOKEN, SESSION_NAME
|
from config import API_HASH, API_ID, BOT_TOKEN, SESSION_NAME
|
||||||
|
|
||||||
@ -9,7 +7,8 @@ bot = Client(
|
|||||||
":veez:",
|
":veez:",
|
||||||
API_ID,
|
API_ID,
|
||||||
API_HASH,
|
API_HASH,
|
||||||
bot_token=BOT_TOKEN
|
bot_token=BOT_TOKEN,
|
||||||
|
plugins={"root": "program"},
|
||||||
)
|
)
|
||||||
|
|
||||||
user = Client(
|
user = Client(
|
||||||
@ -20,15 +19,7 @@ user = Client(
|
|||||||
|
|
||||||
calls = PyTgCalls(user, overload_quiet_mode=True)
|
calls = PyTgCalls(user, overload_quiet_mode=True)
|
||||||
|
|
||||||
with bot as app:
|
with Client(":veez:", API_ID, API_HASH, bot_token=BOT_TOKEN) as app:
|
||||||
me_bot = app.get_me()
|
me_bot = app.get_me()
|
||||||
with user as app:
|
with user as app:
|
||||||
me_user = app.get_me()
|
me_user = app.get_me()
|
||||||
|
|
||||||
bot = Client( # type: ignore
|
|
||||||
":veez:",
|
|
||||||
API_ID,
|
|
||||||
API_HASH,
|
|
||||||
bot_token=BOT_TOKEN,
|
|
||||||
plugins={"root": "program"},
|
|
||||||
)
|
|
||||||
|
@ -1,6 +1,8 @@
|
|||||||
import asyncio
|
import asyncio
|
||||||
import os
|
import os
|
||||||
from driver.core import bot, calls
|
|
||||||
|
from config import IMG_5
|
||||||
|
from driver.core import bot, calls, user
|
||||||
from driver.database.dbqueue import remove_active_chat
|
from driver.database.dbqueue import remove_active_chat
|
||||||
from driver.queues import (
|
from driver.queues import (
|
||||||
QUEUE,
|
QUEUE,
|
||||||
@ -158,3 +160,14 @@ async def bash(cmd):
|
|||||||
def remove_if_exists(path):
|
def remove_if_exists(path):
|
||||||
if os.path.exists(path):
|
if os.path.exists(path):
|
||||||
os.remove(path)
|
os.remove(path)
|
||||||
|
|
||||||
|
|
||||||
|
async def from_tg_get_msg(url: str):
|
||||||
|
data = url.split('/')[-2:]
|
||||||
|
if len(data) == 2:
|
||||||
|
cid = data[0]
|
||||||
|
if cid.isdigit():
|
||||||
|
cid = int('-100' + cid)
|
||||||
|
mid = int(data[1])
|
||||||
|
return await user.get_messages(cid, message_ids=mid)
|
||||||
|
return None
|
||||||
|
@ -9,7 +9,6 @@ from driver.queues import QUEUE, clear_queue
|
|||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.decorators import authorized_users_only, check_blacklist
|
from driver.decorators import authorized_users_only, check_blacklist
|
||||||
from driver.utils import skip_current_song, skip_item, remove_if_exists
|
from driver.utils import skip_current_song, skip_item, remove_if_exists
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
|
||||||
|
|
||||||
from driver.database.dbqueue import (
|
from driver.database.dbqueue import (
|
||||||
is_music_playing,
|
is_music_playing,
|
||||||
|
@ -3,7 +3,6 @@
|
|||||||
from driver.core import me_bot
|
from driver.core import me_bot
|
||||||
from driver.decorators import check_blacklist
|
from driver.decorators import check_blacklist
|
||||||
from driver.queues import QUEUE
|
from driver.queues import QUEUE
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client, filters
|
||||||
from program.utils.inline import menu_markup, stream_markup
|
from program.utils.inline import menu_markup, stream_markup
|
||||||
from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
|
from pyrogram.types import CallbackQuery, InlineKeyboardButton, InlineKeyboardMarkup
|
||||||
|
190
program/music.py
190
program/music.py
@ -20,10 +20,8 @@ from driver.design.thumbnail import thumb
|
|||||||
from driver.design.chatname import CHAT_TITLE
|
from driver.design.chatname import CHAT_TITLE
|
||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.queues import QUEUE, add_to_queue
|
from driver.queues import QUEUE, add_to_queue
|
||||||
from driver.core import calls, user, bot, me_user
|
from driver.core import calls, user, me_user
|
||||||
from driver.utils import bash, remove_if_exists
|
from driver.utils import bash, remove_if_exists, from_tg_get_msg
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
|
||||||
from driver.database.dblockchat import blacklisted_chats
|
|
||||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||||
from config import BOT_USERNAME, IMG_5
|
from config import BOT_USERNAME, IMG_5
|
||||||
# youtube-dl stuff
|
# youtube-dl stuff
|
||||||
@ -61,6 +59,111 @@ def convert_seconds(seconds):
|
|||||||
return "%02d:%02d" % (minutes, seconds)
|
return "%02d:%02d" % (minutes, seconds)
|
||||||
|
|
||||||
|
|
||||||
|
async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str = None):
|
||||||
|
chat_id = m.chat.id
|
||||||
|
user_id = m.from_user.id
|
||||||
|
if link:
|
||||||
|
try:
|
||||||
|
replied = await from_tg_get_msg(link)
|
||||||
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
|
return await m.reply_text(f"🚫 error:\n\n» {e}")
|
||||||
|
if not replied:
|
||||||
|
return await m.reply(
|
||||||
|
"» reply to an **audio file** or **give something to search.**"
|
||||||
|
)
|
||||||
|
if replied.audio or replied.voice:
|
||||||
|
if not link:
|
||||||
|
suhu = await replied.reply("📥 downloading audio...")
|
||||||
|
else:
|
||||||
|
suhu = await m.reply("📥 downloading audio...")
|
||||||
|
dl = await replied.download()
|
||||||
|
link = replied.link
|
||||||
|
songname = "Audio"
|
||||||
|
thumbnail = f"{IMG_5}"
|
||||||
|
duration = "00:00"
|
||||||
|
try:
|
||||||
|
if replied.audio:
|
||||||
|
if replied.audio.title:
|
||||||
|
songname = replied.audio.title[:80]
|
||||||
|
else:
|
||||||
|
songname = replied.audio.file_name[:80]
|
||||||
|
if replied.audio.thumbs:
|
||||||
|
if not link:
|
||||||
|
thumbnail = await c.download_media(replied.audio.thumbs[0].file_id)
|
||||||
|
else:
|
||||||
|
thumbnail = await user.download_media(replied.audio.thumbs[0].file_id)
|
||||||
|
duration = convert_seconds(replied.audio.duration)
|
||||||
|
elif replied.voice:
|
||||||
|
songname = "Voice Note"
|
||||||
|
duration = convert_seconds(replied.voice.duration)
|
||||||
|
except BaseException:
|
||||||
|
pass
|
||||||
|
|
||||||
|
if chat_id in QUEUE:
|
||||||
|
await suhu.edit("🔄 Queueing Track...")
|
||||||
|
gcname = m.chat.title
|
||||||
|
ctitle = await CHAT_TITLE(gcname)
|
||||||
|
title = songname
|
||||||
|
userid = m.from_user.id
|
||||||
|
image = await thumb(thumbnail, title, userid, ctitle)
|
||||||
|
pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0)
|
||||||
|
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||||
|
buttons = stream_markup(user_id)
|
||||||
|
await suhu.delete()
|
||||||
|
await m.reply_photo(
|
||||||
|
photo=image,
|
||||||
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
|
caption=f"💡 **Track added to queue »** `{pos}`\n\n"
|
||||||
|
f"🗂 **Name:** [{songname}]({link}) | `music`\n"
|
||||||
|
f"⏱️ **Duration:** `{duration}`\n"
|
||||||
|
f"🧸 **Request by:** {requester}",
|
||||||
|
)
|
||||||
|
remove_if_exists(image)
|
||||||
|
else:
|
||||||
|
try:
|
||||||
|
gcname = m.chat.title
|
||||||
|
ctitle = await CHAT_TITLE(gcname)
|
||||||
|
title = songname
|
||||||
|
userid = m.from_user.id
|
||||||
|
image = await thumb(thumbnail, title, userid, ctitle)
|
||||||
|
await suhu.edit("🔄 Joining Group Call...")
|
||||||
|
await music_on(chat_id)
|
||||||
|
await add_active_chat(chat_id)
|
||||||
|
await calls.join_group_call(
|
||||||
|
chat_id,
|
||||||
|
AudioPiped(
|
||||||
|
dl,
|
||||||
|
HighQualityAudio(),
|
||||||
|
),
|
||||||
|
stream_type=StreamType().pulse_stream,
|
||||||
|
)
|
||||||
|
add_to_queue(chat_id, songname, dl, link, "Audio", 0)
|
||||||
|
await suhu.delete()
|
||||||
|
buttons = stream_markup(user_id)
|
||||||
|
requester = (
|
||||||
|
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||||
|
)
|
||||||
|
await m.reply_photo(
|
||||||
|
photo=image,
|
||||||
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
|
caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n"
|
||||||
|
f"⏱️ **Duration:** `{duration}`\n"
|
||||||
|
f"🧸 **Request by:** {requester}",
|
||||||
|
)
|
||||||
|
await idle()
|
||||||
|
remove_if_exists(image)
|
||||||
|
except Exception as e:
|
||||||
|
await suhu.delete()
|
||||||
|
await remove_active_chat(chat_id)
|
||||||
|
traceback.print_exc()
|
||||||
|
await m.reply_text(f"🚫 error:\n\n» {e}")
|
||||||
|
else:
|
||||||
|
await m.reply(
|
||||||
|
"» reply to an **audio file** or **give something to search.**"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters)
|
@Client.on_message(command(["play", f"play@{BOT_USERNAME}"]) & other_filters)
|
||||||
@check_blacklist()
|
@check_blacklist()
|
||||||
@require_admin(permissions=["can_manage_voice_chats", "can_delete_messages", "can_invite_users"], self=True)
|
@require_admin(permissions=["can_manage_voice_chats", "can_delete_messages", "can_invite_users"], self=True)
|
||||||
@ -109,79 +212,7 @@ async def play(c: Client, m: Message):
|
|||||||
)
|
)
|
||||||
if replied:
|
if replied:
|
||||||
if replied.audio or replied.voice:
|
if replied.audio or replied.voice:
|
||||||
suhu = await replied.reply("📥 downloading audio...")
|
await play_tg_file(c, m, replied)
|
||||||
dl = await replied.download()
|
|
||||||
link = replied.link
|
|
||||||
songname = "Audio"
|
|
||||||
thumbnail = f"{IMG_5}"
|
|
||||||
try:
|
|
||||||
if replied.audio:
|
|
||||||
if replied.audio.title:
|
|
||||||
songname = replied.audio.title[:80]
|
|
||||||
else:
|
|
||||||
songname = replied.audio.file_name[:80]
|
|
||||||
if replied.audio.thumbs:
|
|
||||||
thumbnail = await c.download_media(replied.audio.thumbs[0].file_id)
|
|
||||||
duration = convert_seconds(replied.audio.duration)
|
|
||||||
elif replied.voice:
|
|
||||||
songname = "Voice Note"
|
|
||||||
duration = convert_seconds(replied.voice.duration)
|
|
||||||
except BaseException:
|
|
||||||
pass
|
|
||||||
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
await suhu.edit("🔄 Queueing Track...")
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
title = songname
|
|
||||||
userid = m.from_user.id
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
pos = add_to_queue(chat_id, songname, dl, link, "Audio", 0)
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await suhu.delete()
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
remove_if_exists(image)
|
|
||||||
else:
|
|
||||||
try:
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
title = songname
|
|
||||||
userid = m.from_user.id
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
await suhu.edit("🔄 Joining Group Call...")
|
|
||||||
await music_on(chat_id)
|
|
||||||
await add_active_chat(chat_id)
|
|
||||||
await calls.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioPiped(
|
|
||||||
dl,
|
|
||||||
HighQualityAudio(),
|
|
||||||
),
|
|
||||||
stream_type=StreamType().pulse_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, dl, link, "Audio", 0)
|
|
||||||
await suhu.delete()
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
requester = (
|
|
||||||
f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({link}) | `music`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
await idle()
|
|
||||||
remove_if_exists(image)
|
|
||||||
except Exception as e:
|
|
||||||
await suhu.delete()
|
|
||||||
await remove_active_chat(chat_id)
|
|
||||||
traceback.print_exc()
|
|
||||||
await m.reply_text(f"🚫 error:\n\n» {e}")
|
|
||||||
else:
|
else:
|
||||||
if len(m.command) < 2:
|
if len(m.command) < 2:
|
||||||
await m.reply(
|
await m.reply(
|
||||||
@ -257,6 +288,11 @@ async def play(c: Client, m: Message):
|
|||||||
await m.reply(
|
await m.reply(
|
||||||
"» reply to an **audio file** or **give something to search.**"
|
"» reply to an **audio file** or **give something to search.**"
|
||||||
)
|
)
|
||||||
|
elif "t.me" in m.command[1]:
|
||||||
|
for i in m.command[1:]:
|
||||||
|
if "t.me" in i:
|
||||||
|
await play_tg_file(c, m, link=i)
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
suhu = await c.send_message(chat_id, "🔍 **Loading...**")
|
suhu = await c.send_message(chat_id, "🔍 **Loading...**")
|
||||||
query = m.text.split(None, 1)[1]
|
query = m.text.split(None, 1)[1]
|
||||||
|
@ -4,18 +4,15 @@
|
|||||||
|
|
||||||
from config import BOT_USERNAME
|
from config import BOT_USERNAME
|
||||||
from pyrogram.types import (
|
from pyrogram.types import (
|
||||||
CallbackQuery,
|
|
||||||
InlineKeyboardButton,
|
InlineKeyboardButton,
|
||||||
InlineKeyboardMarkup,
|
InlineKeyboardMarkup,
|
||||||
Message,
|
Message,
|
||||||
)
|
)
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client
|
||||||
|
|
||||||
from driver.decorators import check_blacklist
|
from driver.decorators import check_blacklist
|
||||||
from driver.queues import QUEUE, get_queue
|
from driver.queues import QUEUE, get_queue
|
||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
|
||||||
|
|
||||||
|
|
||||||
keyboard = InlineKeyboardMarkup(
|
keyboard = InlineKeyboardMarkup(
|
||||||
[[InlineKeyboardButton("🗑 Close", callback_data="set_close")]]
|
[[InlineKeyboardButton("🗑 Close", callback_data="set_close")]]
|
||||||
@ -28,12 +25,17 @@ async def playlist(client, m: Message):
|
|||||||
chat_id = m.chat.id
|
chat_id = m.chat.id
|
||||||
if chat_id in QUEUE:
|
if chat_id in QUEUE:
|
||||||
chat_queue = get_queue(chat_id)
|
chat_queue = get_queue(chat_id)
|
||||||
if len(chat_queue)==1:
|
if len(chat_queue) == 1:
|
||||||
await m.reply(f"💡 **Currently Streaming**`:`\n\n*️⃣ [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][3]}`", reply_markup=keyboard, disable_web_page_preview=True)
|
await m.reply(
|
||||||
|
f"💡 **Currently Streaming**`:`\n\n"
|
||||||
|
f"*️⃣ [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][3]}`",
|
||||||
|
reply_markup=keyboard, disable_web_page_preview=True)
|
||||||
else:
|
else:
|
||||||
QUE = f"💡 **Currently Streaming**`:`\n\n*️⃣ [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][3]}` \n\n**📖 Queue song list**`:`\n"
|
QUE = f"💡 **Currently Streaming**`:`\n\n" \
|
||||||
|
f"*️⃣ [{chat_queue[0][0]}]({chat_queue[0][2]}) | `{chat_queue[0][3]}` \n\n" \
|
||||||
|
f"**📖 Queue song list**`:`\n"
|
||||||
l = len(chat_queue)
|
l = len(chat_queue)
|
||||||
for x in range (1, l):
|
for x in range(1, l):
|
||||||
han = chat_queue[x][0]
|
han = chat_queue[x][0]
|
||||||
hok = chat_queue[x][2]
|
hok = chat_queue[x][2]
|
||||||
hap = chat_queue[x][3]
|
hap = chat_queue[x][3]
|
||||||
|
@ -3,7 +3,7 @@
|
|||||||
|
|
||||||
import asyncio
|
import asyncio
|
||||||
|
|
||||||
from pyrogram import Client, filters
|
from pyrogram import Client
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
from pyrogram.errors import FloodWait
|
from pyrogram.errors import FloodWait
|
||||||
from driver.core import me_bot
|
from driver.core import me_bot
|
||||||
|
@ -15,13 +15,13 @@ from config import (
|
|||||||
from driver.decorators import check_blacklist
|
from driver.decorators import check_blacklist
|
||||||
from program import __version__
|
from program import __version__
|
||||||
from driver.core import bot, me_bot, me_user
|
from driver.core import bot, me_bot, me_user
|
||||||
from driver.filters import command, other_filters
|
from driver.filters import command
|
||||||
from driver.database.dbchat import add_served_chat, is_served_chat
|
from driver.database.dbchat import add_served_chat, is_served_chat
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
from driver.database.dbpunish import is_gbanned_user
|
||||||
from driver.database.dbusers import add_served_user
|
from driver.database.dbusers import add_served_user
|
||||||
from driver.database.dblockchat import blacklisted_chats
|
from driver.database.dblockchat import blacklisted_chats
|
||||||
from pyrogram import Client, filters, __version__ as pyrover
|
from pyrogram import Client, filters, __version__ as pyrover
|
||||||
from pyrogram.errors import FloodWait, MessageNotModified
|
from pyrogram.errors import FloodWait
|
||||||
from pytgcalls import (__version__ as pytover)
|
from pytgcalls import (__version__ as pytover)
|
||||||
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, ChatJoinRequest
|
from pyrogram.types import InlineKeyboardButton, InlineKeyboardMarkup, Message, ChatJoinRequest
|
||||||
|
|
||||||
|
@ -6,7 +6,6 @@ from driver.core import user, me_bot
|
|||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.database.dbchat import remove_served_chat
|
from driver.database.dbchat import remove_served_chat
|
||||||
from driver.database.dbqueue import remove_active_chat
|
from driver.database.dbqueue import remove_active_chat
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
|
||||||
from driver.decorators import authorized_users_only, bot_creator, check_blacklist
|
from driver.decorators import authorized_users_only, bot_creator, check_blacklist
|
||||||
|
|
||||||
from pyrogram.types import Message
|
from pyrogram.types import Message
|
||||||
|
196
program/video.py
196
program/video.py
@ -14,11 +14,9 @@ from driver.design.thumbnail import thumb
|
|||||||
from driver.design.chatname import CHAT_TITLE
|
from driver.design.chatname import CHAT_TITLE
|
||||||
from driver.filters import command, other_filters
|
from driver.filters import command, other_filters
|
||||||
from driver.queues import QUEUE, add_to_queue
|
from driver.queues import QUEUE, add_to_queue
|
||||||
from driver.core import calls, user, bot, me_user
|
from driver.core import calls, user, me_user
|
||||||
from driver.database.dbpunish import is_gbanned_user
|
|
||||||
from driver.database.dblockchat import blacklisted_chats
|
|
||||||
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
from driver.database.dbqueue import add_active_chat, remove_active_chat, music_on
|
||||||
from driver.utils import remove_if_exists
|
from driver.utils import remove_if_exists, from_tg_get_msg
|
||||||
# pyrogram stuff
|
# pyrogram stuff
|
||||||
from pyrogram import Client
|
from pyrogram import Client
|
||||||
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
from pyrogram.errors import UserAlreadyParticipant, UserNotParticipant
|
||||||
@ -77,6 +75,112 @@ def convert_seconds(seconds):
|
|||||||
return "%02d:%02d" % (minutes, seconds)
|
return "%02d:%02d" % (minutes, seconds)
|
||||||
|
|
||||||
|
|
||||||
|
async def play_tg_file(c: Client, m: Message, replied: Message = None, link: str = None):
|
||||||
|
chat_id = m.chat.id
|
||||||
|
user_id = m.from_user.id
|
||||||
|
if link:
|
||||||
|
try:
|
||||||
|
replied = await from_tg_get_msg(link)
|
||||||
|
except Exception as e:
|
||||||
|
traceback.print_exc()
|
||||||
|
return await m.reply_text(f"🚫 error:\n\n» {e}")
|
||||||
|
if not replied:
|
||||||
|
return await m.reply(
|
||||||
|
"» reply to an **audio file** or **give something to search.**"
|
||||||
|
)
|
||||||
|
if replied.video or replied.document:
|
||||||
|
if not link:
|
||||||
|
loser = await replied.reply("📥 downloading video...")
|
||||||
|
else:
|
||||||
|
loser = await m.reply("📥 downloading video...")
|
||||||
|
dl = await replied.download()
|
||||||
|
link = replied.link
|
||||||
|
songname = "video"
|
||||||
|
duration = "00:00"
|
||||||
|
Q = 720
|
||||||
|
pq = m.text.split(None, 1)
|
||||||
|
if ("t.me" not in m.text) and len(pq) > 1:
|
||||||
|
pq = pq[1]
|
||||||
|
if pq == "720" or pq == "480" or pq == "360":
|
||||||
|
Q = int(pq)
|
||||||
|
else:
|
||||||
|
await loser.edit(
|
||||||
|
"» only 720, 480, 360 allowed\n\n💡 now streaming video in **720p**"
|
||||||
|
)
|
||||||
|
try:
|
||||||
|
if replied.video:
|
||||||
|
songname = replied.video.file_name[:80]
|
||||||
|
duration = convert_seconds(replied.video.duration)
|
||||||
|
elif replied.document:
|
||||||
|
songname = replied.document.file_name[:80]
|
||||||
|
except BaseException:
|
||||||
|
songname = "Video"
|
||||||
|
|
||||||
|
if chat_id in QUEUE:
|
||||||
|
await loser.edit("🔄 Queueing Track...")
|
||||||
|
gcname = m.chat.title
|
||||||
|
ctitle = await CHAT_TITLE(gcname)
|
||||||
|
title = songname
|
||||||
|
userid = m.from_user.id
|
||||||
|
thumbnail = f"{IMG_5}"
|
||||||
|
image = await thumb(thumbnail, title, userid, ctitle)
|
||||||
|
pos = add_to_queue(chat_id, songname, dl, link, "Video", Q)
|
||||||
|
await loser.delete()
|
||||||
|
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||||
|
buttons = stream_markup(user_id)
|
||||||
|
await m.reply_photo(
|
||||||
|
photo=image,
|
||||||
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
|
caption=f"💡 **Track added to queue »** `{pos}`\n\n"
|
||||||
|
f"🗂 **Name:** [{songname}]({link}) | `video`\n"
|
||||||
|
f"⏱️ **Duration:** `{duration}`\n"
|
||||||
|
f"🧸 **Request by:** {requester}",
|
||||||
|
)
|
||||||
|
remove_if_exists(image)
|
||||||
|
else:
|
||||||
|
await loser.edit("🔄 Joining Group Call...")
|
||||||
|
gcname = m.chat.title
|
||||||
|
ctitle = await CHAT_TITLE(gcname)
|
||||||
|
title = songname
|
||||||
|
userid = m.from_user.id
|
||||||
|
thumbnail = f"{IMG_5}"
|
||||||
|
image = await thumb(thumbnail, title, userid, ctitle)
|
||||||
|
if Q == 720:
|
||||||
|
amaze = HighQualityVideo()
|
||||||
|
elif Q == 480:
|
||||||
|
amaze = MediumQualityVideo()
|
||||||
|
elif Q == 360:
|
||||||
|
amaze = LowQualityVideo()
|
||||||
|
await music_on(chat_id)
|
||||||
|
await add_active_chat(chat_id)
|
||||||
|
await calls.join_group_call(
|
||||||
|
chat_id,
|
||||||
|
AudioVideoPiped(
|
||||||
|
dl,
|
||||||
|
HighQualityAudio(),
|
||||||
|
amaze,
|
||||||
|
),
|
||||||
|
stream_type=StreamType().pulse_stream,
|
||||||
|
)
|
||||||
|
add_to_queue(chat_id, songname, dl, link, "Video", Q)
|
||||||
|
await loser.delete()
|
||||||
|
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
||||||
|
buttons = stream_markup(user_id)
|
||||||
|
await m.reply_photo(
|
||||||
|
photo=image,
|
||||||
|
reply_markup=InlineKeyboardMarkup(buttons),
|
||||||
|
caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n"
|
||||||
|
f"⏱️ **Duration:** `{duration}`\n"
|
||||||
|
f"🧸 **Request by:** {requester}",
|
||||||
|
)
|
||||||
|
await idle()
|
||||||
|
remove_if_exists(image)
|
||||||
|
else:
|
||||||
|
await m.reply(
|
||||||
|
"» reply to an **video file** or **give something to search.**"
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
@Client.on_message(command(["vplay", f"vplay@{BOT_USERNAME}"]) & other_filters)
|
@Client.on_message(command(["vplay", f"vplay@{BOT_USERNAME}"]) & other_filters)
|
||||||
@check_blacklist()
|
@check_blacklist()
|
||||||
@require_admin(permissions=["can_manage_voice_chats", "can_delete_messages", "can_invite_users"], self=True)
|
@require_admin(permissions=["can_manage_voice_chats", "can_delete_messages", "can_invite_users"], self=True)
|
||||||
@ -125,84 +229,7 @@ async def vplay(c: Client, m: Message):
|
|||||||
)
|
)
|
||||||
if replied:
|
if replied:
|
||||||
if replied.video or replied.document:
|
if replied.video or replied.document:
|
||||||
loser = await replied.reply("📥 downloading video...")
|
await play_tg_file(c, m, replied)
|
||||||
dl = await replied.download()
|
|
||||||
link = replied.link
|
|
||||||
if len(m.command) < 2:
|
|
||||||
Q = 720
|
|
||||||
else:
|
|
||||||
pq = m.text.split(None, 1)[1]
|
|
||||||
if pq == "720" or "480" or "360":
|
|
||||||
Q = int(pq)
|
|
||||||
else:
|
|
||||||
Q = 720
|
|
||||||
await loser.edit(
|
|
||||||
"» only 720, 480, 360 allowed\n\n💡 now streaming video in **720p**"
|
|
||||||
)
|
|
||||||
try:
|
|
||||||
if replied.video:
|
|
||||||
songname = replied.video.file_name[:80]
|
|
||||||
duration = convert_seconds(replied.video.duration)
|
|
||||||
elif replied.document:
|
|
||||||
songname = replied.document.file_name[:80]
|
|
||||||
duration = convert_seconds(replied.document.duration)
|
|
||||||
except BaseException:
|
|
||||||
songname = "Video"
|
|
||||||
|
|
||||||
if chat_id in QUEUE:
|
|
||||||
await loser.edit("🔄 Queueing Track...")
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
title = songname
|
|
||||||
userid = m.from_user.id
|
|
||||||
thumbnail = f"{IMG_5}"
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
pos = add_to_queue(chat_id, songname, dl, link, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"💡 **Track added to queue »** `{pos}`\n\n🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
remove_if_exists(image)
|
|
||||||
else:
|
|
||||||
await loser.edit("🔄 Joining Group Call...")
|
|
||||||
gcname = m.chat.title
|
|
||||||
ctitle = await CHAT_TITLE(gcname)
|
|
||||||
title = songname
|
|
||||||
userid = m.from_user.id
|
|
||||||
thumbnail = f"{IMG_5}"
|
|
||||||
image = await thumb(thumbnail, title, userid, ctitle)
|
|
||||||
if Q == 720:
|
|
||||||
amaze = HighQualityVideo()
|
|
||||||
elif Q == 480:
|
|
||||||
amaze = MediumQualityVideo()
|
|
||||||
elif Q == 360:
|
|
||||||
amaze = LowQualityVideo()
|
|
||||||
await music_on(chat_id)
|
|
||||||
await add_active_chat(chat_id)
|
|
||||||
await calls.join_group_call(
|
|
||||||
chat_id,
|
|
||||||
AudioVideoPiped(
|
|
||||||
dl,
|
|
||||||
HighQualityAudio(),
|
|
||||||
amaze,
|
|
||||||
),
|
|
||||||
stream_type=StreamType().pulse_stream,
|
|
||||||
)
|
|
||||||
add_to_queue(chat_id, songname, dl, link, "Video", Q)
|
|
||||||
await loser.delete()
|
|
||||||
requester = f"[{m.from_user.first_name}](tg://user?id={m.from_user.id})"
|
|
||||||
buttons = stream_markup(user_id)
|
|
||||||
await m.reply_photo(
|
|
||||||
photo=image,
|
|
||||||
reply_markup=InlineKeyboardMarkup(buttons),
|
|
||||||
caption=f"🗂 **Name:** [{songname}]({link}) | `video`\n⏱️ **Duration:** `{duration}`\n🧸 **Request by:** {requester}",
|
|
||||||
)
|
|
||||||
await idle()
|
|
||||||
remove_if_exists(image)
|
|
||||||
else:
|
else:
|
||||||
if len(m.command) < 2:
|
if len(m.command) < 2:
|
||||||
await m.reply(
|
await m.reply(
|
||||||
@ -279,6 +306,11 @@ async def vplay(c: Client, m: Message):
|
|||||||
await m.reply(
|
await m.reply(
|
||||||
"» reply to an **video file** or **give something to search.**"
|
"» reply to an **video file** or **give something to search.**"
|
||||||
)
|
)
|
||||||
|
elif "t.me" in m.command[1]:
|
||||||
|
for i in m.command[1:]:
|
||||||
|
if "t.me" in i:
|
||||||
|
await play_tg_file(c, m, link=i)
|
||||||
|
continue
|
||||||
else:
|
else:
|
||||||
loser = await c.send_message(chat_id, "🔍 **Loading...**")
|
loser = await c.send_message(chat_id, "🔍 **Loading...**")
|
||||||
query = m.text.split(None, 1)[1]
|
query = m.text.split(None, 1)[1]
|
||||||
|
Loading…
Reference in New Issue
Block a user