taslim19
commited on
Commit
·
0127f13
1
Parent(s):
b269b33
feat: Overhaul play command with advanced features
Browse files- DragMusic/platforms/Youtube.py +94 -38
- DragMusic/plugins/play/play.py +347 -219
- DragMusic/utils/errors.py +13 -0
- config.py +11 -0
- cookies.txt +0 -17
- cookies/cookies.txt +0 -1
DragMusic/platforms/Youtube.py
CHANGED
@@ -1,15 +1,18 @@
|
|
1 |
import asyncio
|
2 |
import os
|
3 |
import re
|
4 |
-
from typing import Union
|
5 |
|
6 |
import yt_dlp
|
7 |
from pyrogram.enums import MessageEntityType
|
8 |
from pyrogram.types import Message
|
|
|
9 |
|
10 |
from DragMusic.utils.database import is_on_off
|
|
|
11 |
from DragMusic.utils.formatters import time_to_seconds
|
12 |
|
|
|
13 |
|
14 |
async def shell_cmd(cmd):
|
15 |
proc = await asyncio.create_subprocess_shell(
|
@@ -35,6 +38,43 @@ class YouTubeAPI:
|
|
35 |
if os.path.exists(cookie_file):
|
36 |
self.opts["cookiefile"] = cookie_file
|
37 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
async def get_info(self, link: str):
|
39 |
"""Fetches all video information using yt-dlp."""
|
40 |
full_url = self.base + link if not link.startswith("http") else link
|
@@ -42,16 +82,56 @@ class YouTubeAPI:
|
|
42 |
info = ydl.extract_info(full_url, download=False)
|
43 |
return info
|
44 |
|
45 |
-
|
|
|
46 |
"""Gets essential video details."""
|
47 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
48 |
title = info.get("title", "Unknown Title")
|
49 |
-
duration_min = info.get("
|
50 |
-
duration_sec =
|
51 |
-
thumbnail = info.get("thumbnail", "")
|
52 |
vidid = info.get("id", "")
|
53 |
return title, duration_min, duration_sec, thumbnail, vidid
|
54 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
55 |
async def url(self, message: "Message") -> Union[str, None]:
|
56 |
"""Extracts a URL from a Pyrogram message."""
|
57 |
for entity in message.entities or message.caption_entities or []:
|
@@ -59,37 +139,22 @@ class YouTubeAPI:
|
|
59 |
return entity.url or message.text[entity.offset:entity.offset + entity.length]
|
60 |
return None
|
61 |
|
|
|
62 |
async def title(self, link: str):
|
63 |
info = await self.get_info(link)
|
64 |
return info.get("title", "Unknown Title")
|
65 |
|
|
|
66 |
async def duration(self, link: str):
|
67 |
info = await self.get_info(link)
|
68 |
return info.get("duration_string", "0:00")
|
69 |
|
|
|
70 |
async def thumbnail(self, link: str):
|
71 |
info = await self.get_info(link)
|
72 |
return info.get("thumbnail", "")
|
73 |
|
74 |
-
|
75 |
-
"""Searches for a video and returns its details."""
|
76 |
-
search_opts = self.opts.copy()
|
77 |
-
try:
|
78 |
-
with yt_dlp.YoutubeDL(search_opts) as ydl:
|
79 |
-
info = ydl.extract_info(f"ytsearch:{query}", download=False)['entries'][0]
|
80 |
-
|
81 |
-
details = {
|
82 |
-
"title": info.get("title", "Unknown Title"),
|
83 |
-
"link": info.get("webpage_url", ""),
|
84 |
-
"vidid": info.get("id", ""),
|
85 |
-
"duration_min": info.get("duration_string", "0:00"),
|
86 |
-
"thumb": info.get("thumbnail", ""),
|
87 |
-
}
|
88 |
-
track_id = info.get("id", "")
|
89 |
-
return details, track_id
|
90 |
-
except Exception:
|
91 |
-
return None, None
|
92 |
-
|
93 |
async def get_best_audio_url(self, link: str):
|
94 |
"""Gets the URL of the best quality audio stream."""
|
95 |
info = await self.get_info(link)
|
@@ -100,6 +165,7 @@ class YouTubeAPI:
|
|
100 |
best_audio = f
|
101 |
return best_audio["url"] if best_audio else None
|
102 |
|
|
|
103 |
async def get_best_video_url(self, link: str, quality: str = "720"):
|
104 |
"""Gets the URL of the best video stream for a given quality."""
|
105 |
info = await self.get_info(link)
|
@@ -110,7 +176,7 @@ class YouTubeAPI:
|
|
110 |
best_video = f
|
111 |
return best_video["url"] if best_video else None
|
112 |
|
113 |
-
|
114 |
async def playlist(self, link: str, limit: int, user_id, videoid: bool = False):
|
115 |
"""Fetches video IDs from a playlist."""
|
116 |
if videoid:
|
@@ -124,18 +190,7 @@ class YouTubeAPI:
|
|
124 |
info = ydl.extract_info(link, download=False)
|
125 |
return [entry["id"] for entry in info.get("entries", []) if entry]
|
126 |
|
127 |
-
|
128 |
-
"""Gets track details for a single video."""
|
129 |
-
info = await self.get_info(link)
|
130 |
-
track_details = {
|
131 |
-
"title": info.get("title", "Unknown Title"),
|
132 |
-
"link": info.get("webpage_url", ""),
|
133 |
-
"vidid": info.get("id", ""),
|
134 |
-
"duration_min": info.get("duration_string", "0:00"),
|
135 |
-
"thumb": info.get("thumbnail", ""),
|
136 |
-
}
|
137 |
-
return track_details, info.get("id", "")
|
138 |
-
|
139 |
async def formats(self, link: str):
|
140 |
"""Gets available formats for a video."""
|
141 |
info = await self.get_info(link)
|
@@ -152,6 +207,7 @@ class YouTubeAPI:
|
|
152 |
})
|
153 |
return formats_available, info.get("webpage_url", "")
|
154 |
|
|
|
155 |
async def download(self, link: str, mystic, video: bool = None, format_id: str = None) -> Union[str, None]:
|
156 |
"""Downloads a video or audio file and returns the path."""
|
157 |
file_path = f"downloads/{link}.%(ext)s"
|
|
|
1 |
import asyncio
|
2 |
import os
|
3 |
import re
|
4 |
+
from typing import Dict, List, Optional, Tuple, Union
|
5 |
|
6 |
import yt_dlp
|
7 |
from pyrogram.enums import MessageEntityType
|
8 |
from pyrogram.types import Message
|
9 |
+
from youtubesearchpython.__future__ import VideosSearch
|
10 |
|
11 |
from DragMusic.utils.database import is_on_off
|
12 |
+
from DragMusic.utils.errors import capture_internal_err
|
13 |
from DragMusic.utils.formatters import time_to_seconds
|
14 |
|
15 |
+
_cache = {}
|
16 |
|
17 |
async def shell_cmd(cmd):
|
18 |
proc = await asyncio.create_subprocess_shell(
|
|
|
38 |
if os.path.exists(cookie_file):
|
39 |
self.opts["cookiefile"] = cookie_file
|
40 |
|
41 |
+
@capture_internal_err
|
42 |
+
async def exists(self, url: str):
|
43 |
+
return bool(re.search(r"youtube\.com|youtu\.be", url))
|
44 |
+
|
45 |
+
@capture_internal_err
|
46 |
+
async def slider(self, query: str, query_type: int):
|
47 |
+
search = VideosSearch(query, limit=10)
|
48 |
+
results = await search.next()
|
49 |
+
result_list = results.get("result", [])
|
50 |
+
if not result_list:
|
51 |
+
return None, None, None, None
|
52 |
+
|
53 |
+
if query_type >= len(result_list):
|
54 |
+
query_type = 0
|
55 |
+
|
56 |
+
info = result_list[query_type]
|
57 |
+
title = info.get("title", "Unknown Title")
|
58 |
+
duration_min = info.get("duration", "0:00")
|
59 |
+
thumbnail = info.get("thumbnails", [{}])[0].get("url", "").split("?")[0]
|
60 |
+
vidid = info.get("id", "")
|
61 |
+
return title, duration_min, thumbnail, vidid
|
62 |
+
|
63 |
+
@capture_internal_err
|
64 |
+
async def _fetch_info(self, query: str, use_cache: bool = True):
|
65 |
+
if use_cache and query in _cache:
|
66 |
+
return _cache[query]
|
67 |
+
|
68 |
+
search = VideosSearch(query, limit=1)
|
69 |
+
results = await search.next()
|
70 |
+
result_data = results.get("result", [])
|
71 |
+
|
72 |
+
if result_data:
|
73 |
+
_cache[query] = result_data[0]
|
74 |
+
return result_data[0]
|
75 |
+
return None
|
76 |
+
|
77 |
+
@capture_internal_err
|
78 |
async def get_info(self, link: str):
|
79 |
"""Fetches all video information using yt-dlp."""
|
80 |
full_url = self.base + link if not link.startswith("http") else link
|
|
|
82 |
info = ydl.extract_info(full_url, download=False)
|
83 |
return info
|
84 |
|
85 |
+
@capture_internal_err
|
86 |
+
async def details(self, link: str, videoid: bool = False):
|
87 |
"""Gets essential video details."""
|
88 |
+
if videoid:
|
89 |
+
link = self.base + link
|
90 |
+
|
91 |
+
info = await self._fetch_info(link, use_cache=False)
|
92 |
+
if not info:
|
93 |
+
info = await self.get_info(link)
|
94 |
+
|
95 |
title = info.get("title", "Unknown Title")
|
96 |
+
duration_min = info.get("duration", "0:00")
|
97 |
+
duration_sec = time_to_seconds(duration_min) if duration_min else 0
|
98 |
+
thumbnail = info.get("thumbnails", [{}])[0].get("url", "").split("?")[0] or info.get("thumbnail", "")
|
99 |
vidid = info.get("id", "")
|
100 |
return title, duration_min, duration_sec, thumbnail, vidid
|
101 |
|
102 |
+
@capture_internal_err
|
103 |
+
async def search(self, query: str):
|
104 |
+
"""Searches for a video and returns its details."""
|
105 |
+
info = await self._fetch_info(query)
|
106 |
+
if not info:
|
107 |
+
return None, None
|
108 |
+
|
109 |
+
details = {
|
110 |
+
"title": info.get("title", "Unknown Title"),
|
111 |
+
"link": info.get("link", ""),
|
112 |
+
"vidid": info.get("id", ""),
|
113 |
+
"duration_min": info.get("duration", "0:00"),
|
114 |
+
"thumb": info.get("thumbnails", [{}])[0].get("url", "").split("?")[0],
|
115 |
+
}
|
116 |
+
track_id = info.get("id", "")
|
117 |
+
return details, track_id
|
118 |
+
|
119 |
+
@capture_internal_err
|
120 |
+
async def track(self, link: str, videoid: bool = False):
|
121 |
+
"""Gets track details for a single video."""
|
122 |
+
if videoid:
|
123 |
+
link = self.base + link
|
124 |
+
info = await self.get_info(link)
|
125 |
+
track_details = {
|
126 |
+
"title": info.get("title", "Unknown Title"),
|
127 |
+
"link": info.get("webpage_url", ""),
|
128 |
+
"vidid": info.get("id", ""),
|
129 |
+
"duration_min": info.get("duration_string", "0:00"),
|
130 |
+
"thumb": info.get("thumbnail", ""),
|
131 |
+
}
|
132 |
+
return track_details, info.get("id", "")
|
133 |
+
|
134 |
+
@capture_internal_err
|
135 |
async def url(self, message: "Message") -> Union[str, None]:
|
136 |
"""Extracts a URL from a Pyrogram message."""
|
137 |
for entity in message.entities or message.caption_entities or []:
|
|
|
139 |
return entity.url or message.text[entity.offset:entity.offset + entity.length]
|
140 |
return None
|
141 |
|
142 |
+
@capture_internal_err
|
143 |
async def title(self, link: str):
|
144 |
info = await self.get_info(link)
|
145 |
return info.get("title", "Unknown Title")
|
146 |
|
147 |
+
@capture_internal_err
|
148 |
async def duration(self, link: str):
|
149 |
info = await self.get_info(link)
|
150 |
return info.get("duration_string", "0:00")
|
151 |
|
152 |
+
@capture_internal_err
|
153 |
async def thumbnail(self, link: str):
|
154 |
info = await self.get_info(link)
|
155 |
return info.get("thumbnail", "")
|
156 |
|
157 |
+
@capture_internal_err
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
158 |
async def get_best_audio_url(self, link: str):
|
159 |
"""Gets the URL of the best quality audio stream."""
|
160 |
info = await self.get_info(link)
|
|
|
165 |
best_audio = f
|
166 |
return best_audio["url"] if best_audio else None
|
167 |
|
168 |
+
@capture_internal_err
|
169 |
async def get_best_video_url(self, link: str, quality: str = "720"):
|
170 |
"""Gets the URL of the best video stream for a given quality."""
|
171 |
info = await self.get_info(link)
|
|
|
176 |
best_video = f
|
177 |
return best_video["url"] if best_video else None
|
178 |
|
179 |
+
@capture_internal_err
|
180 |
async def playlist(self, link: str, limit: int, user_id, videoid: bool = False):
|
181 |
"""Fetches video IDs from a playlist."""
|
182 |
if videoid:
|
|
|
190 |
info = ydl.extract_info(link, download=False)
|
191 |
return [entry["id"] for entry in info.get("entries", []) if entry]
|
192 |
|
193 |
+
@capture_internal_err
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
194 |
async def formats(self, link: str):
|
195 |
"""Gets available formats for a video."""
|
196 |
info = await self.get_info(link)
|
|
|
207 |
})
|
208 |
return formats_available, info.get("webpage_url", "")
|
209 |
|
210 |
+
@capture_internal_err
|
211 |
async def download(self, link: str, mystic, video: bool = None, format_id: str = None) -> Union[str, None]:
|
212 |
"""Downloads a video or audio file and returns the path."""
|
213 |
file_path = f"downloads/{link}.%(ext)s"
|
DragMusic/plugins/play/play.py
CHANGED
@@ -1,8 +1,10 @@
|
|
1 |
import random
|
2 |
import string
|
|
|
3 |
|
4 |
from pyrogram import filters
|
5 |
from pyrogram.types import InlineKeyboardMarkup, InputMediaPhoto, Message
|
|
|
6 |
from pytgcalls.exceptions import NoActiveGroupCall
|
7 |
|
8 |
import config
|
@@ -12,6 +14,7 @@ from DragMusic.utils import seconds_to_min, time_to_seconds
|
|
12 |
from DragMusic.utils.channelplay import get_channeplayCB
|
13 |
from DragMusic.utils.decorators.language import languageCB
|
14 |
from DragMusic.utils.decorators.play import PlayWrapper
|
|
|
15 |
from DragMusic.utils.formatters import formats
|
16 |
from DragMusic.utils.inline import (
|
17 |
botplaylist_markup,
|
@@ -22,69 +25,59 @@ from DragMusic.utils.inline import (
|
|
22 |
)
|
23 |
from DragMusic.utils.logger import play_logs
|
24 |
from DragMusic.utils.stream.stream import stream
|
25 |
-
from config import BANNED_USERS, lyrical
|
26 |
|
27 |
|
28 |
@app.on_message(
|
29 |
-
filters.command(
|
30 |
-
|
31 |
-
|
32 |
-
|
33 |
-
"cplay",
|
34 |
-
"cvplay",
|
35 |
-
"playforce",
|
36 |
-
"vplayforce",
|
37 |
-
"cplayforce",
|
38 |
-
"cvplayforce",
|
39 |
-
]
|
40 |
-
)
|
41 |
-
& filters.group
|
42 |
-
& ~BANNED_USERS
|
43 |
)
|
44 |
@PlayWrapper
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
51 |
-
|
52 |
-
|
53 |
-
|
54 |
-
|
55 |
-
)
|
56 |
-
|
57 |
-
|
58 |
-
|
59 |
-
|
60 |
-
|
61 |
-
|
62 |
-
spotify = None
|
63 |
user_id = message.from_user.id
|
64 |
user_name = message.from_user.first_name
|
|
|
65 |
audio_telegram = (
|
66 |
(message.reply_to_message.audio or message.reply_to_message.voice)
|
67 |
-
if message.reply_to_message
|
68 |
-
else None
|
69 |
-
)
|
70 |
-
video_telegram = (
|
71 |
-
(message.reply_to_message.video or message.reply_to_message.document)
|
72 |
-
if message.reply_to_message
|
73 |
-
else None
|
74 |
)
|
|
|
75 |
if audio_telegram:
|
76 |
if audio_telegram.file_size > 104857600:
|
77 |
return await mystic.edit_text(_["play_5"])
|
|
|
78 |
duration_min = seconds_to_min(audio_telegram.duration)
|
79 |
-
if
|
80 |
return await mystic.edit_text(
|
81 |
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
82 |
)
|
|
|
83 |
file_path = await Telegram.get_filepath(audio=audio_telegram)
|
84 |
-
|
|
|
85 |
message_link = await Telegram.get_link(message)
|
86 |
file_name = await Telegram.get_filename(audio_telegram, audio=True)
|
87 |
dur = await Telegram.get_duration(audio_telegram, file_path)
|
|
|
88 |
details = {
|
89 |
"title": file_name,
|
90 |
"link": message_link,
|
@@ -105,37 +98,48 @@ async def play_commnd(
|
|
105 |
forceplay=fplay,
|
106 |
)
|
107 |
except Exception as e:
|
108 |
-
print(f"Error: {e}")
|
109 |
ex_type = type(e).__name__
|
110 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
111 |
return await mystic.edit_text(err)
|
|
|
112 |
return await mystic.delete()
|
113 |
return
|
114 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
115 |
if message.reply_to_message.document:
|
116 |
try:
|
117 |
ext = video_telegram.file_name.split(".")[-1]
|
118 |
if ext.lower() not in formats:
|
119 |
return await mystic.edit_text(
|
120 |
-
_["play_7"].format(
|
121 |
)
|
122 |
except:
|
123 |
return await mystic.edit_text(
|
124 |
-
_["play_7"].format(
|
125 |
)
|
|
|
126 |
if video_telegram.file_size > config.TG_VIDEO_FILESIZE_LIMIT:
|
127 |
return await mystic.edit_text(_["play_8"])
|
|
|
128 |
file_path = await Telegram.get_filepath(video=video_telegram)
|
129 |
-
|
|
|
130 |
message_link = await Telegram.get_link(message)
|
131 |
file_name = await Telegram.get_filename(video_telegram)
|
132 |
dur = await Telegram.get_duration(video_telegram, file_path)
|
|
|
133 |
details = {
|
134 |
"title": file_name,
|
135 |
"link": message_link,
|
136 |
"path": file_path,
|
137 |
"dur": dur,
|
138 |
}
|
|
|
139 |
try:
|
140 |
await stream(
|
141 |
_,
|
@@ -150,36 +154,44 @@ async def play_commnd(
|
|
150 |
forceplay=fplay,
|
151 |
)
|
152 |
except Exception as e:
|
153 |
-
print(f"Error: {e}")
|
154 |
ex_type = type(e).__name__
|
155 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
156 |
return await mystic.edit_text(err)
|
|
|
157 |
return await mystic.delete()
|
158 |
return
|
159 |
-
|
160 |
-
|
161 |
-
|
162 |
-
|
163 |
-
|
164 |
-
config.PLAYLIST_FETCH_LIMIT,
|
165 |
-
|
166 |
-
|
167 |
-
|
168 |
-
|
169 |
-
|
170 |
-
|
171 |
-
|
172 |
-
|
|
|
|
|
|
|
173 |
else:
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
177 |
elif await Spotify.valid(url):
|
178 |
spotify = True
|
179 |
-
if not config.SPOTIFY_CLIENT_ID
|
180 |
return await mystic.edit_text(
|
181 |
"» sᴘᴏᴛɪғʏ ɪs ɴᴏᴛ sᴜᴘᴘᴏʀᴛᴇᴅ ʏᴇᴛ.\n\nᴘʟᴇᴀsᴇ ᴛʀʏ ᴀɢᴀɪɴ ʟᴀᴛᴇʀ."
|
182 |
)
|
|
|
183 |
if "track" in url:
|
184 |
try:
|
185 |
details, track_id = await Spotify.track(url)
|
@@ -191,7 +203,7 @@ async def play_commnd(
|
|
191 |
elif "playlist" in url:
|
192 |
try:
|
193 |
details, plist_id = await Spotify.playlist(url)
|
194 |
-
except
|
195 |
return await mystic.edit_text(_["play_3"])
|
196 |
streamtype = "playlist"
|
197 |
plist_type = "spplay"
|
@@ -234,10 +246,10 @@ async def play_commnd(
|
|
234 |
return await mystic.edit_text(_["play_3"])
|
235 |
streamtype = "playlist"
|
236 |
plist_type = "apple"
|
237 |
-
cap = _["play_12"].format(app.mention, message.from_user.mention)
|
238 |
img = url
|
|
|
239 |
else:
|
240 |
-
return await mystic.edit_text(_["
|
241 |
elif await Resso.valid(url):
|
242 |
try:
|
243 |
details, track_id = await Resso.track(url)
|
@@ -248,48 +260,97 @@ async def play_commnd(
|
|
248 |
cap = _["play_10"].format(details["title"], details["duration_min"])
|
249 |
elif await SoundCloud.valid(url):
|
250 |
try:
|
251 |
-
details,
|
252 |
-
|
253 |
-
|
254 |
-
|
255 |
-
|
256 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
257 |
else:
|
258 |
try:
|
259 |
-
|
260 |
-
|
261 |
-
|
262 |
-
|
263 |
-
|
264 |
-
"
|
265 |
-
"thumb": thumbnail,
|
266 |
-
}
|
267 |
-
streamtype = "youtube"
|
268 |
-
img = details["thumb"]
|
269 |
-
cap = _["play_10"].format(
|
270 |
-
details["title"],
|
271 |
-
details["duration_min"],
|
272 |
)
|
273 |
except Exception as e:
|
274 |
-
|
275 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
276 |
else:
|
277 |
if len(message.command) < 2:
|
278 |
-
|
279 |
-
|
|
|
|
|
|
|
|
|
280 |
query = message.text.split(None, 1)[1]
|
|
|
|
|
281 |
try:
|
282 |
details, track_id = await YouTube.search(query)
|
283 |
-
if details is None:
|
284 |
-
return await mystic.edit_text(_["play_3"])
|
285 |
except:
|
286 |
return await mystic.edit_text(_["play_3"])
|
287 |
streamtype = "youtube"
|
288 |
-
|
289 |
-
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
293 |
try:
|
294 |
await stream(
|
295 |
_,
|
@@ -300,112 +361,118 @@ async def play_commnd(
|
|
300 |
user_name,
|
301 |
message.chat.id,
|
302 |
video=video,
|
303 |
-
streamtype=
|
304 |
-
|
305 |
-
playlist_type=plist_type,
|
306 |
forceplay=fplay,
|
307 |
)
|
308 |
except Exception as e:
|
309 |
-
print(f"Error: {e}")
|
310 |
ex_type = type(e).__name__
|
311 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
312 |
return await mystic.edit_text(err)
|
313 |
-
|
|
|
314 |
else:
|
315 |
-
if
|
316 |
-
|
|
|
|
|
317 |
_,
|
318 |
-
|
319 |
user_id,
|
320 |
-
|
321 |
-
|
322 |
-
"
|
323 |
-
video,
|
324 |
-
fplay,
|
325 |
)
|
326 |
await mystic.delete()
|
327 |
-
await
|
328 |
-
|
329 |
-
photo=img,
|
330 |
-
caption=_["play_20"].format(app.mention),
|
331 |
-
reply_markup=InlineKeyboardMarkup(buttons),
|
332 |
-
)
|
333 |
-
return
|
334 |
-
else:
|
335 |
-
buttons = track_markup(
|
336 |
-
_,
|
337 |
-
track_id,
|
338 |
-
user_id,
|
339 |
-
chat_id,
|
340 |
-
video,
|
341 |
-
fplay,
|
342 |
-
)
|
343 |
-
await mystic.delete()
|
344 |
-
await app.send_photo(
|
345 |
-
chat_id=message.chat.id,
|
346 |
-
photo=img,
|
347 |
caption=cap,
|
348 |
reply_markup=InlineKeyboardMarkup(buttons),
|
349 |
)
|
350 |
-
return
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
351 |
|
352 |
|
353 |
@app.on_callback_query(filters.regex("MusicStream") & ~BANNED_USERS)
|
354 |
@languageCB
|
|
|
355 |
async def play_music(client, CallbackQuery, _):
|
356 |
-
callback_data = CallbackQuery.data.strip()
|
357 |
-
callback_request = callback_data.split(None, 1)[1]
|
358 |
-
(
|
359 |
-
videoid,
|
360 |
-
user_id,
|
361 |
-
what,
|
362 |
-
chattype,
|
363 |
-
fplay,
|
364 |
-
) = callback_request.split("|")
|
365 |
-
if CallbackQuery.from_user.id != int(user_id):
|
366 |
-
try:
|
367 |
-
return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
|
368 |
-
except:
|
369 |
-
return
|
370 |
-
try:
|
371 |
-
chat_id, channel = await get_channeplayCB(_, what, ch)
|
372 |
-
except:
|
373 |
-
return await CallbackQuery.edit_message_text(_["play_14"])
|
374 |
-
video = True if what == "v" else None
|
375 |
-
user_name = CallbackQuery.from_user.first_name
|
376 |
-
await CallbackQuery.message.delete()
|
377 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
378 |
await CallbackQuery.answer()
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
return await mystic.edit_text(
|
390 |
-
_["
|
391 |
)
|
392 |
-
|
393 |
-
|
394 |
-
|
395 |
-
|
396 |
-
user_id,
|
397 |
-
"play",
|
398 |
-
chat_id,
|
399 |
-
video,
|
400 |
-
)
|
401 |
-
return await mystic.edit_text(
|
402 |
-
_["play_13"],
|
403 |
-
reply_markup=InlineKeyboardMarkup(buttons),
|
404 |
-
)
|
405 |
-
video = True if what == "v" else None
|
406 |
-
ffplay = True if fplay == "f" else None
|
407 |
-
await play_logs(CallbackQuery, streamtype="Video" if video else "Audio")
|
408 |
-
try:
|
409 |
await stream(
|
410 |
_,
|
411 |
mystic,
|
@@ -416,57 +483,118 @@ async def play_music(client, CallbackQuery, _):
|
|
416 |
CallbackQuery.message.chat.id,
|
417 |
video,
|
418 |
streamtype="youtube",
|
419 |
-
forceplay=
|
420 |
)
|
|
|
421 |
except Exception as e:
|
422 |
-
print(f"Error: {e}")
|
423 |
ex_type = type(e).__name__
|
424 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
425 |
-
return await
|
426 |
-
return await mystic.delete()
|
427 |
|
428 |
|
429 |
@app.on_callback_query(filters.regex("DragmousAdmin") & ~BANNED_USERS)
|
430 |
-
|
431 |
-
|
432 |
-
|
433 |
-
|
434 |
-
|
435 |
-
|
436 |
-
|
437 |
-
|
|
|
438 |
|
439 |
|
440 |
@app.on_callback_query(filters.regex("AviaxPlaylists") & ~BANNED_USERS)
|
441 |
@languageCB
|
|
|
442 |
async def play_playlists_command(client, CallbackQuery, _):
|
443 |
-
callback_data = CallbackQuery.data.strip()
|
444 |
-
callback_request = callback_data.split(None, 1)[1]
|
445 |
-
(
|
446 |
-
videoid,
|
447 |
-
user_id,
|
448 |
-
ptype,
|
449 |
-
mode,
|
450 |
-
cplay,
|
451 |
-
fplay,
|
452 |
-
) = callback_request.split("|")
|
453 |
-
if CallbackQuery.from_user.id != int(user_id):
|
454 |
-
try:
|
455 |
-
return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
|
456 |
-
except:
|
457 |
-
return
|
458 |
try:
|
|
|
|
|
|
|
|
|
|
|
|
|
459 |
chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery)
|
460 |
-
|
461 |
-
|
462 |
-
user_name = CallbackQuery.from_user.first_name
|
463 |
-
await CallbackQuery.message.delete()
|
464 |
-
try:
|
465 |
await CallbackQuery.answer()
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
466 |
except:
|
467 |
pass
|
468 |
-
mystic = await CallbackQuery.message.reply_text(
|
469 |
-
_["play_2"].format(channel) if channel else _["play_1"]
|
470 |
-
)
|
471 |
-
videoid = lyrical.get(videoid)
|
472 |
-
video = True if mode == "v" else None
|
|
|
1 |
import random
|
2 |
import string
|
3 |
+
import asyncio
|
4 |
|
5 |
from pyrogram import filters
|
6 |
from pyrogram.types import InlineKeyboardMarkup, InputMediaPhoto, Message
|
7 |
+
from pyrogram.errors import FloodWait, RandomIdDuplicate
|
8 |
from pytgcalls.exceptions import NoActiveGroupCall
|
9 |
|
10 |
import config
|
|
|
14 |
from DragMusic.utils.channelplay import get_channeplayCB
|
15 |
from DragMusic.utils.decorators.language import languageCB
|
16 |
from DragMusic.utils.decorators.play import PlayWrapper
|
17 |
+
from DragMusic.utils.errors import capture_internal_err
|
18 |
from DragMusic.utils.formatters import formats
|
19 |
from DragMusic.utils.inline import (
|
20 |
botplaylist_markup,
|
|
|
25 |
)
|
26 |
from DragMusic.utils.logger import play_logs
|
27 |
from DragMusic.utils.stream.stream import stream
|
28 |
+
from config import BANNED_USERS, lyrical, AYU
|
29 |
|
30 |
|
31 |
@app.on_message(
|
32 |
+
filters.command([
|
33 |
+
"play", "vplay", "cplay", "cvplay",
|
34 |
+
"playforce", "vplayforce", "cplayforce", "cvplayforce"
|
35 |
+
]) & filters.group & ~BANNED_USERS
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
36 |
)
|
37 |
@PlayWrapper
|
38 |
+
@capture_internal_err
|
39 |
+
async def play_command(client, message: Message, _, chat_id, video, channel, playmode, url, fplay):
|
40 |
+
try:
|
41 |
+
mystic = await message.reply_text(
|
42 |
+
_["play_2"].format(channel) if channel else random.choice(AYU)
|
43 |
+
)
|
44 |
+
except FloodWait as e:
|
45 |
+
await asyncio.sleep(e.value)
|
46 |
+
mystic = await message.reply_text(
|
47 |
+
_["play_2"].format(channel) if channel else random.choice(AYU)
|
48 |
+
)
|
49 |
+
except RandomIdDuplicate:
|
50 |
+
mystic = await app.send_message(
|
51 |
+
message.chat.id,
|
52 |
+
_["play_2"].format(channel) if channel else random.choice(AYU)
|
53 |
+
)
|
54 |
+
|
55 |
+
plist_id, plist_type, spotify, slider = None, None, None, None
|
56 |
user_id = message.from_user.id
|
57 |
user_name = message.from_user.first_name
|
58 |
+
|
59 |
audio_telegram = (
|
60 |
(message.reply_to_message.audio or message.reply_to_message.voice)
|
61 |
+
if message.reply_to_message else None
|
|
|
|
|
|
|
|
|
|
|
|
|
62 |
)
|
63 |
+
|
64 |
if audio_telegram:
|
65 |
if audio_telegram.file_size > 104857600:
|
66 |
return await mystic.edit_text(_["play_5"])
|
67 |
+
|
68 |
duration_min = seconds_to_min(audio_telegram.duration)
|
69 |
+
if audio_telegram.duration > config.DURATION_LIMIT:
|
70 |
return await mystic.edit_text(
|
71 |
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
72 |
)
|
73 |
+
|
74 |
file_path = await Telegram.get_filepath(audio=audio_telegram)
|
75 |
+
downloaded = await Telegram.download(_, message, mystic, file_path)
|
76 |
+
if downloaded:
|
77 |
message_link = await Telegram.get_link(message)
|
78 |
file_name = await Telegram.get_filename(audio_telegram, audio=True)
|
79 |
dur = await Telegram.get_duration(audio_telegram, file_path)
|
80 |
+
|
81 |
details = {
|
82 |
"title": file_name,
|
83 |
"link": message_link,
|
|
|
98 |
forceplay=fplay,
|
99 |
)
|
100 |
except Exception as e:
|
|
|
101 |
ex_type = type(e).__name__
|
102 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
103 |
return await mystic.edit_text(err)
|
104 |
+
|
105 |
return await mystic.delete()
|
106 |
return
|
107 |
+
|
108 |
+
video_telegram = (
|
109 |
+
(message.reply_to_message.video or message.reply_to_message.document)
|
110 |
+
if message.reply_to_message else None
|
111 |
+
)
|
112 |
+
|
113 |
+
if video_telegram:
|
114 |
if message.reply_to_message.document:
|
115 |
try:
|
116 |
ext = video_telegram.file_name.split(".")[-1]
|
117 |
if ext.lower() not in formats:
|
118 |
return await mystic.edit_text(
|
119 |
+
_["play_7"].format(" | ".join(formats))
|
120 |
)
|
121 |
except:
|
122 |
return await mystic.edit_text(
|
123 |
+
_["play_7"].format(" | ".join(formats))
|
124 |
)
|
125 |
+
|
126 |
if video_telegram.file_size > config.TG_VIDEO_FILESIZE_LIMIT:
|
127 |
return await mystic.edit_text(_["play_8"])
|
128 |
+
|
129 |
file_path = await Telegram.get_filepath(video=video_telegram)
|
130 |
+
downloaded = await Telegram.download(_, message, mystic, file_path)
|
131 |
+
if downloaded:
|
132 |
message_link = await Telegram.get_link(message)
|
133 |
file_name = await Telegram.get_filename(video_telegram)
|
134 |
dur = await Telegram.get_duration(video_telegram, file_path)
|
135 |
+
|
136 |
details = {
|
137 |
"title": file_name,
|
138 |
"link": message_link,
|
139 |
"path": file_path,
|
140 |
"dur": dur,
|
141 |
}
|
142 |
+
|
143 |
try:
|
144 |
await stream(
|
145 |
_,
|
|
|
154 |
forceplay=fplay,
|
155 |
)
|
156 |
except Exception as e:
|
|
|
157 |
ex_type = type(e).__name__
|
158 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
159 |
return await mystic.edit_text(err)
|
160 |
+
|
161 |
return await mystic.delete()
|
162 |
return
|
163 |
+
|
164 |
+
if url:
|
165 |
+
if await YouTube.exists(url):
|
166 |
+
if "playlist" in url:
|
167 |
+
try:
|
168 |
+
details = await YouTube.playlist(url, config.PLAYLIST_FETCH_LIMIT, user_id)
|
169 |
+
except:
|
170 |
+
return await mystic.edit_text(_["play_3"])
|
171 |
+
|
172 |
+
streamtype = "playlist"
|
173 |
+
plist_type = "yt"
|
174 |
+
if "&" in url:
|
175 |
+
plist_id = (url.split("=")[1]).split("&")[0]
|
176 |
+
else:
|
177 |
+
plist_id = url.split("=")[1]
|
178 |
+
img = config.PLAYLIST_IMG_URL
|
179 |
+
cap = _["play_9"]
|
180 |
else:
|
181 |
+
try:
|
182 |
+
details, track_id = await YouTube.track(url)
|
183 |
+
except Exception:
|
184 |
+
return await mystic.edit_text(_["play_3"])
|
185 |
+
streamtype = "youtube"
|
186 |
+
img = details["thumb"]
|
187 |
+
cap = _["play_10"].format(details["title"], details["duration_min"])
|
188 |
elif await Spotify.valid(url):
|
189 |
spotify = True
|
190 |
+
if not config.SPOTIFY_CLIENT_ID or not config.SPOTIFY_CLIENT_SECRET:
|
191 |
return await mystic.edit_text(
|
192 |
"» sᴘᴏᴛɪғʏ ɪs ɴᴏᴛ sᴜᴘᴘᴏʀᴛᴇᴅ ʏᴇᴛ.\n\nᴘʟᴇᴀsᴇ ᴛʀʏ ᴀɢᴀɪɴ ʟᴀᴛᴇʀ."
|
193 |
)
|
194 |
+
|
195 |
if "track" in url:
|
196 |
try:
|
197 |
details, track_id = await Spotify.track(url)
|
|
|
203 |
elif "playlist" in url:
|
204 |
try:
|
205 |
details, plist_id = await Spotify.playlist(url)
|
206 |
+
except:
|
207 |
return await mystic.edit_text(_["play_3"])
|
208 |
streamtype = "playlist"
|
209 |
plist_type = "spplay"
|
|
|
246 |
return await mystic.edit_text(_["play_3"])
|
247 |
streamtype = "playlist"
|
248 |
plist_type = "apple"
|
|
|
249 |
img = url
|
250 |
+
cap = _["play_12"].format(app.mention, message.from_user.mention)
|
251 |
else:
|
252 |
+
return await mystic.edit_text(_["play_3"])
|
253 |
elif await Resso.valid(url):
|
254 |
try:
|
255 |
details, track_id = await Resso.track(url)
|
|
|
260 |
cap = _["play_10"].format(details["title"], details["duration_min"])
|
261 |
elif await SoundCloud.valid(url):
|
262 |
try:
|
263 |
+
details, track_path = await SoundCloud.download(url)
|
264 |
+
if details["duration_sec"] > config.DURATION_LIMIT:
|
265 |
+
return await mystic.edit_text(
|
266 |
+
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
267 |
+
)
|
268 |
+
await stream(
|
269 |
+
_,
|
270 |
+
mystic,
|
271 |
+
user_id,
|
272 |
+
details,
|
273 |
+
chat_id,
|
274 |
+
user_name,
|
275 |
+
message.chat.id,
|
276 |
+
streamtype="soundcloud",
|
277 |
+
forceplay=fplay,
|
278 |
+
)
|
279 |
+
except Exception as e:
|
280 |
+
ex_type = type(e).__name__
|
281 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
282 |
+
return await mystic.edit_text(err)
|
283 |
+
return await mystic.delete()
|
284 |
else:
|
285 |
try:
|
286 |
+
await Drag.stream_call(url)
|
287 |
+
except NoActiveGroupCall:
|
288 |
+
await mystic.edit_text(_["black_9"])
|
289 |
+
return await app.send_message(
|
290 |
+
chat_id=config.LOGGER_ID,
|
291 |
+
text=_["play_17"],
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
292 |
)
|
293 |
except Exception as e:
|
294 |
+
return await mystic.edit_text(_["general_2"].format(type(e).__name__))
|
295 |
+
|
296 |
+
await mystic.edit_text(_["str_2"])
|
297 |
+
try:
|
298 |
+
await stream(
|
299 |
+
_,
|
300 |
+
mystic,
|
301 |
+
user_id,
|
302 |
+
url,
|
303 |
+
chat_id,
|
304 |
+
user_name,
|
305 |
+
message.chat.id,
|
306 |
+
video=video,
|
307 |
+
streamtype="index",
|
308 |
+
forceplay=fplay,
|
309 |
+
)
|
310 |
+
except Exception as e:
|
311 |
+
ex_type = type(e).__name__
|
312 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
313 |
+
return await mystic.edit_text(err)
|
314 |
+
return await play_logs(message, streamtype="M3U8 or Index Link")
|
315 |
else:
|
316 |
if len(message.command) < 2:
|
317 |
+
buttons = botplaylist_markup(_)
|
318 |
+
return await mystic.edit_text(
|
319 |
+
_["play_18"],
|
320 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
321 |
+
)
|
322 |
+
slider = True
|
323 |
query = message.text.split(None, 1)[1]
|
324 |
+
if "-v" in query:
|
325 |
+
query = query.replace("-v", "")
|
326 |
try:
|
327 |
details, track_id = await YouTube.search(query)
|
|
|
|
|
328 |
except:
|
329 |
return await mystic.edit_text(_["play_3"])
|
330 |
streamtype = "youtube"
|
331 |
+
|
332 |
+
if str(playmode) == "Direct":
|
333 |
+
if not plist_type:
|
334 |
+
if details.get("duration_min"):
|
335 |
+
duration_sec = time_to_seconds(details["duration_min"])
|
336 |
+
if duration_sec and duration_sec > config.DURATION_LIMIT:
|
337 |
+
return await mystic.edit_text(
|
338 |
+
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
339 |
+
)
|
340 |
+
else:
|
341 |
+
buttons = livestream_markup(
|
342 |
+
_,
|
343 |
+
track_id,
|
344 |
+
user_id,
|
345 |
+
"v" if video else "a",
|
346 |
+
"c" if channel else "g",
|
347 |
+
"f" if fplay else "d",
|
348 |
+
)
|
349 |
+
return await mystic.edit_text(
|
350 |
+
_["play_13"],
|
351 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
352 |
+
)
|
353 |
+
|
354 |
try:
|
355 |
await stream(
|
356 |
_,
|
|
|
361 |
user_name,
|
362 |
message.chat.id,
|
363 |
video=video,
|
364 |
+
streamtype=streamtype,
|
365 |
+
spotify=spotify,
|
|
|
366 |
forceplay=fplay,
|
367 |
)
|
368 |
except Exception as e:
|
|
|
369 |
ex_type = type(e).__name__
|
370 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
371 |
return await mystic.edit_text(err)
|
372 |
+
await mystic.delete()
|
373 |
+
return await play_logs(message, streamtype=streamtype)
|
374 |
else:
|
375 |
+
if plist_type:
|
376 |
+
ran_hash = "".join(random.choices(string.ascii_uppercase + string.digits, k=10))
|
377 |
+
lyrical[ran_hash] = plist_id
|
378 |
+
buttons = playlist_markup(
|
379 |
_,
|
380 |
+
ran_hash,
|
381 |
user_id,
|
382 |
+
plist_type,
|
383 |
+
"c" if channel else "g",
|
384 |
+
"f" if fplay else "d",
|
|
|
|
|
385 |
)
|
386 |
await mystic.delete()
|
387 |
+
await message.reply_photo(
|
388 |
+
photo=(details["thumb"] if plist_type == "yt" else img),
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
389 |
caption=cap,
|
390 |
reply_markup=InlineKeyboardMarkup(buttons),
|
391 |
)
|
392 |
+
return await play_logs(message, streamtype=f"Playlist : {plist_type}")
|
393 |
+
else:
|
394 |
+
if slider:
|
395 |
+
buttons = slider_markup(
|
396 |
+
_,
|
397 |
+
track_id,
|
398 |
+
user_id,
|
399 |
+
query,
|
400 |
+
0,
|
401 |
+
"c" if channel else "g",
|
402 |
+
"f" if fplay else "d",
|
403 |
+
)
|
404 |
+
await mystic.delete()
|
405 |
+
await message.reply_photo(
|
406 |
+
photo=details["thumb"],
|
407 |
+
caption=_["play_10"].format(
|
408 |
+
details["title"].title(),
|
409 |
+
details["duration_min"],
|
410 |
+
),
|
411 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
412 |
+
)
|
413 |
+
return await play_logs(message, streamtype="Searched on YouTube")
|
414 |
+
else:
|
415 |
+
buttons = track_markup(
|
416 |
+
_,
|
417 |
+
track_id,
|
418 |
+
user_id,
|
419 |
+
"c" if channel else "g",
|
420 |
+
"f" if fplay else "d",
|
421 |
+
)
|
422 |
+
await mystic.delete()
|
423 |
+
await message.reply_photo(
|
424 |
+
photo=img,
|
425 |
+
caption=cap,
|
426 |
+
reply_markup=InlineKeyboardMarkup(buttons),
|
427 |
+
)
|
428 |
+
return await play_logs(message, streamtype="URL Search Inline")
|
429 |
|
430 |
|
431 |
@app.on_callback_query(filters.regex("MusicStream") & ~BANNED_USERS)
|
432 |
@languageCB
|
433 |
+
@capture_internal_err
|
434 |
async def play_music(client, CallbackQuery, _):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
435 |
try:
|
436 |
+
callback_data = CallbackQuery.data.split(None, 1)[1]
|
437 |
+
vidid, user_id, mode, cplay, fplay = callback_data.split("|")
|
438 |
+
|
439 |
+
if CallbackQuery.from_user.id != int(user_id):
|
440 |
+
return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
|
441 |
+
|
442 |
+
chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery)
|
443 |
+
user_name = CallbackQuery.from_user.first_name
|
444 |
+
await CallbackQuery.message.delete()
|
445 |
await CallbackQuery.answer()
|
446 |
+
|
447 |
+
try:
|
448 |
+
mystic = await app.send_message(chat_id, random.choice(AYU))
|
449 |
+
except (FloodWait, RandomIdDuplicate):
|
450 |
+
pass
|
451 |
+
|
452 |
+
details, track_id = await YouTube.track(vidid, videoid=True)
|
453 |
+
|
454 |
+
if details.get("duration_min"):
|
455 |
+
duration_sec = time_to_seconds(details["duration_min"])
|
456 |
+
if duration_sec > config.DURATION_LIMIT:
|
457 |
+
return await mystic.edit_text(
|
458 |
+
_["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
|
459 |
+
)
|
460 |
+
else:
|
461 |
+
buttons = livestream_markup(
|
462 |
+
_,
|
463 |
+
track_id,
|
464 |
+
CallbackQuery.from_user.id,
|
465 |
+
mode,
|
466 |
+
"c" if cplay == "c" else "g",
|
467 |
+
"f" if fplay else "d",
|
468 |
+
)
|
469 |
return await mystic.edit_text(
|
470 |
+
_["play_13"], reply_markup=InlineKeyboardMarkup(buttons)
|
471 |
)
|
472 |
+
|
473 |
+
video = mode == "v"
|
474 |
+
forceplay = fplay == "f"
|
475 |
+
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
476 |
await stream(
|
477 |
_,
|
478 |
mystic,
|
|
|
483 |
CallbackQuery.message.chat.id,
|
484 |
video,
|
485 |
streamtype="youtube",
|
486 |
+
forceplay=forceplay,
|
487 |
)
|
488 |
+
await mystic.delete()
|
489 |
except Exception as e:
|
|
|
490 |
ex_type = type(e).__name__
|
491 |
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
492 |
+
return await CallbackQuery.message.reply_text(err)
|
|
|
493 |
|
494 |
|
495 |
@app.on_callback_query(filters.regex("DragmousAdmin") & ~BANNED_USERS)
|
496 |
+
@capture_internal_err
|
497 |
+
async def anonymous_check(client, CallbackQuery):
|
498 |
+
await CallbackQuery.answer(
|
499 |
+
"» ʀᴇᴠᴇʀᴛ ʙᴀᴄᴋ ᴛᴏ ᴜsᴇʀ ᴀᴄᴄᴏᴜɴᴛ :\n\n"
|
500 |
+
"ᴏᴘᴇɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ sᴇᴛᴛɪɴɢs.\n"
|
501 |
+
"-> ᴀᴅᴍɪɴɪsᴛʀᴀᴛᴏʀs\n-> ᴄʟɪᴄᴋ ᴏɴ ʏᴏᴜʀ ɴᴀᴍᴇ\n"
|
502 |
+
"-> ᴜɴᴄʜᴇᴄᴋ ᴀɴᴏɴʏᴍᴏᴜs ᴀᴅᴍɪɴ ᴘᴇʀᴍɪssɪᴏɴs.",
|
503 |
+
show_alert=True,
|
504 |
+
)
|
505 |
|
506 |
|
507 |
@app.on_callback_query(filters.regex("AviaxPlaylists") & ~BANNED_USERS)
|
508 |
@languageCB
|
509 |
+
@capture_internal_err
|
510 |
async def play_playlists_command(client, CallbackQuery, _):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
511 |
try:
|
512 |
+
callback_data = CallbackQuery.data.split(None, 1)[1]
|
513 |
+
videoid, user_id, ptype, mode, cplay, fplay = callback_data.split("|")
|
514 |
+
|
515 |
+
if CallbackQuery.from_user.id != int(user_id):
|
516 |
+
return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
|
517 |
+
|
518 |
chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery)
|
519 |
+
user_name = CallbackQuery.from_user.first_name
|
520 |
+
await CallbackQuery.message.delete()
|
|
|
|
|
|
|
521 |
await CallbackQuery.answer()
|
522 |
+
|
523 |
+
try:
|
524 |
+
mystic = await app.send_message(chat_id, random.choice(AYU))
|
525 |
+
except (FloodWait, RandomIdDuplicate):
|
526 |
+
pass
|
527 |
+
|
528 |
+
videoid = lyrical.get(videoid)
|
529 |
+
video = mode == "v"
|
530 |
+
forceplay = fplay == "f"
|
531 |
+
spotify = True
|
532 |
+
|
533 |
+
if ptype == "yt":
|
534 |
+
spotify = False
|
535 |
+
result = await YouTube.playlist(videoid, config.PLAYLIST_FETCH_LIMIT, CallbackQuery.from_user.id, True)
|
536 |
+
elif ptype == "spplay":
|
537 |
+
result, _ = await Spotify.playlist(videoid)
|
538 |
+
elif ptype == "spalbum":
|
539 |
+
result, _ = await Spotify.album(videoid)
|
540 |
+
elif ptype == "spartist":
|
541 |
+
result, _ = await Spotify.artist(videoid)
|
542 |
+
elif ptype == "apple":
|
543 |
+
result, _ = await Apple.playlist(videoid, True)
|
544 |
+
else:
|
545 |
+
return
|
546 |
+
|
547 |
+
await stream(
|
548 |
+
_,
|
549 |
+
mystic,
|
550 |
+
CallbackQuery.from_user.id,
|
551 |
+
result,
|
552 |
+
chat_id,
|
553 |
+
user_name,
|
554 |
+
CallbackQuery.message.chat.id,
|
555 |
+
video,
|
556 |
+
streamtype="playlist",
|
557 |
+
spotify=spotify,
|
558 |
+
forceplay=forceplay,
|
559 |
+
)
|
560 |
+
await mystic.delete()
|
561 |
+
except Exception as e:
|
562 |
+
ex_type = type(e).__name__
|
563 |
+
err = e if ex_type == "AssistantErr" else _["general_2"].format(ex_type)
|
564 |
+
return await CallbackQuery.message.reply_text(err)
|
565 |
+
|
566 |
+
|
567 |
+
@app.on_callback_query(filters.regex("slider") & ~BANNED_USERS)
|
568 |
+
@languageCB
|
569 |
+
@capture_internal_err
|
570 |
+
async def slider_queries(client, CallbackQuery, _):
|
571 |
+
try:
|
572 |
+
callback_data = CallbackQuery.data.split(None, 1)[1]
|
573 |
+
what, rtype, query, user_id, cplay, fplay = callback_data.split("|")
|
574 |
+
|
575 |
+
if CallbackQuery.from_user.id != int(user_id):
|
576 |
+
return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
|
577 |
+
|
578 |
+
rtype = int(rtype)
|
579 |
+
query_type = (rtype + 1) if what == "F" else (rtype - 1)
|
580 |
+
if query_type > 9:
|
581 |
+
query_type = 0
|
582 |
+
if query_type < 0:
|
583 |
+
query_type = 9
|
584 |
+
|
585 |
+
title, duration_min, thumbnail, vidid = await YouTube.slider(query, query_type)
|
586 |
+
|
587 |
+
buttons = slider_markup(_, vidid, user_id, query, query_type, cplay, fplay)
|
588 |
+
med = InputMediaPhoto(
|
589 |
+
media=thumbnail,
|
590 |
+
caption=_["play_10"].format(
|
591 |
+
title.title(),
|
592 |
+
duration_min,
|
593 |
+
),
|
594 |
+
)
|
595 |
+
await CallbackQuery.edit_message_media(
|
596 |
+
media=med, reply_markup=InlineKeyboardMarkup(buttons)
|
597 |
+
)
|
598 |
+
await CallbackQuery.answer(_["playcb_2"])
|
599 |
except:
|
600 |
pass
|
|
|
|
|
|
|
|
|
|
DragMusic/utils/errors.py
ADDED
@@ -0,0 +1,13 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
from functools import wraps
|
2 |
+
import traceback
|
3 |
+
|
4 |
+
def capture_internal_err(func):
|
5 |
+
@wraps(func)
|
6 |
+
async def wrapper(*args, **kwargs):
|
7 |
+
try:
|
8 |
+
return await func(*args, **kwargs)
|
9 |
+
except Exception as e:
|
10 |
+
print(f"An internal error occurred in {func.__name__}:")
|
11 |
+
traceback.print_exc()
|
12 |
+
return None
|
13 |
+
return wrapper
|
config.py
CHANGED
@@ -117,3 +117,14 @@ if SUPPORT_CHAT:
|
|
117 |
raise SystemExit(
|
118 |
"[ERROR] - Your SUPPORT_CHAT url is wrong. Please ensure that it starts with https://"
|
119 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
117 |
raise SystemExit(
|
118 |
"[ERROR] - Your SUPPORT_CHAT url is wrong. Please ensure that it starts with https://"
|
119 |
)
|
120 |
+
|
121 |
+
# Miscellaneous
|
122 |
+
REPLY_MESSAGE = getenv("REPLY_MESSAGE", None)
|
123 |
+
F_SUB_URL = getenv("F_SUB_URL", None)
|
124 |
+
WELCOME_DELAY_KICK_SEC = getenv("WELCOME_DELAY_KICK_SEC", None)
|
125 |
+
|
126 |
+
# Add these new variables
|
127 |
+
AYU = [
|
128 |
+
"❤️", "✨", "🔥", "🎵", "🎶",
|
129 |
+
"🎉", "😊", "👍", "🚀", "🌟"
|
130 |
+
]
|
cookies.txt
DELETED
@@ -1,17 +0,0 @@
|
|
1 |
-
# Netscape HTTP Cookie File
|
2 |
-
# http://curl.haxx.se/rfc/cookie_spec.html
|
3 |
-
# This file was generated by Cookie-Editor
|
4 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1742921152 YTSESSION-1b ANPz9Kij0V5aPjAttfZnRD4suOkGNjcz71q/xU0sngZqCq6hloIsSWAFbPEQs27oatdAAu+UOnVdqHYpAHAX/sazeOPD+W6qV1UK1w4=
|
5 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1777481033 __Secure-3PSID g.a000vAg8Bwo4A5fv1NfvT2I_Xqfi4q1nb9NAILFCge0h-2Cy7HusWTyvvIa4FO4BSmdbR6CFxwACgYKAaISARYSFQHGX2MijMXK3BV7jH8exWDuhU97choVAUF8yKobdzO11tjJBgWksmpx0h9L0076
|
6 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1742922832 GPS 1
|
7 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1774457033 __Secure-1PSIDTS sidts-CjEB7pHptSAYHEZy5rb_OuZ_7NBWl8AzZVFx7tIFEB4aNPNKlP715S5LMgfhdD5n2_MtEAA
|
8 |
-
.youtube.com TRUE / TRUE 1777481033 SAPISID 3GQv2sj-2w3zrw2J/AvZHeLBzSCg3geUBk
|
9 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1774457132 __Secure-1PSIDCC AKEyXzUwvFFY1fEphh9h5DcjJ_qi4A81tMwebn_aCgQ8FAyahMtFeczYZvw7wMv5e4tlO9W9Sw
|
10 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1777481033 SSID ALdDq3hPOhryHiBTk
|
11 |
-
.youtube.com TRUE / TRUE 1777481033 __Secure-1PAPISID 3GQv2sj-2w3zrw2J/AvZHeLBzSCg3geUBk
|
12 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1777481033 __Secure-1PSID g.a000vAg8Bwo4A5fv1NfvT2I_Xqfi4q1nb9NAILFCge0h-2Cy7HusUywUecfgnF11rqmsMWsLsQACgYKAb0SARYSFQHGX2MiwbMAvy-q6FczWi2M0wMoQhoVAUF8yKrzvMeeJByv6o9DZGxhhH4n0076
|
13 |
-
.youtube.com TRUE / TRUE 1777481033 __Secure-3PAPISID 3GQv2sj-2w3zrw2J/AvZHeLBzSCg3geUBk
|
14 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1774457132 __Secure-3PSIDCC AKEyXzXj1GiFMV5Umszk5kRXg8j6dmUEDJdjkv_ty12JJm5zood-XieGGKljVfqEVo5Xncd0Pw
|
15 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1774457033 __Secure-3PSIDTS sidts-CjEB7pHptSAYHEZy5rb_OuZ_7NBWl8AzZVFx7tIFEB4aNPNKlP715S5LMgfhdD5n2_MtEAA
|
16 |
-
#HttpOnly_.youtube.com TRUE / TRUE 1777481033 LOGIN_INFO AFmmF2swRQIgdcJU8AlPASy-JQuMIAgtjaemwSB4uvrzaeU9T-xHuqgCIQCov2OFYIGh9LQtaoKwDe6g3_ByZU_YtmBIQTRCNsSEBw:QUQ3MjNmejlhUTh1bkNYMkRod2t6akFMVHNaV0M5UEFGSkZXbEQ5Qy01Rkp0X25wTkw3NU5ra1lSdTZDZ0h1akxJdlpQU2wtaEo4Y3NCVk9kV1VkYm9Lblp5RmFfQXYzcUE5UGdfbm1jdXM2TEc5U3Q5OV94NXE3N05GYXBTVDVOMzdIcmFEckVzQmN0cl9OSzhDemJPb1lIT2lkZkk0MUln
|
17 |
-
.youtube.com TRUE / TRUE 1777481036 PREF tz=Asia.Calcutta
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
cookies/cookies.txt
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
|
|
|
|