dragonxd1 commited on
Commit
0d351fc
·
verified ·
1 Parent(s): da4e9a7

Update DragMusic/plugins/play/play.py

Browse files
Files changed (1) hide show
  1. DragMusic/plugins/play/play.py +123 -65
DragMusic/plugins/play/play.py CHANGED
@@ -3,18 +3,19 @@ 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
 
11
  from DragMusic import Apple, Resso, SoundCloud, Spotify, Telegram, YouTube, app
12
  from DragMusic.core.call import Drag
13
  from DragMusic.utils import seconds_to_min, time_to_seconds
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,7 +26,6 @@ from DragMusic.utils.inline import (
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(
@@ -35,7 +35,7 @@ from config import BANNED_USERS, lyrical, AYU
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(
@@ -98,8 +98,7 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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()
@@ -154,8 +153,7 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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()
@@ -169,27 +167,27 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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:
@@ -197,74 +195,95 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
197
  details, track_id = await Spotify.track(url)
198
  except:
199
  return await mystic.edit_text(_["play_3"])
200
- streamtype = "youtube"
201
  img = details["thumb"]
202
  cap = _["play_10"].format(details["title"], details["duration_min"])
 
 
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"
210
  img = config.SPOTIFY_PLAYLIST_IMG_URL
211
  cap = _["play_11"].format(app.mention, message.from_user.mention)
 
 
212
  elif "album" in url:
213
  try:
214
  details, plist_id = await Spotify.album(url)
215
  except:
216
  return await mystic.edit_text(_["play_3"])
217
- streamtype = "playlist"
218
  plist_type = "spalbum"
219
  img = config.SPOTIFY_ALBUM_IMG_URL
220
  cap = _["play_11"].format(app.mention, message.from_user.mention)
 
 
221
  elif "artist" in url:
222
  try:
223
  details, plist_id = await Spotify.artist(url)
224
  except:
225
  return await mystic.edit_text(_["play_3"])
226
- streamtype = "playlist"
227
  plist_type = "spartist"
228
  img = config.SPOTIFY_ARTIST_IMG_URL
229
  cap = _["play_11"].format(message.from_user.first_name)
 
 
230
  else:
231
  return await mystic.edit_text(_["play_15"])
 
232
  elif await Apple.valid(url):
233
  if "album" in url:
234
  try:
235
  details, track_id = await Apple.track(url)
236
  except:
237
  return await mystic.edit_text(_["play_3"])
238
- streamtype = "youtube"
239
  img = details["thumb"]
240
  cap = _["play_10"].format(details["title"], details["duration_min"])
 
 
241
  elif "playlist" in url:
242
  spotify = True
243
  try:
244
  details, plist_id = await Apple.playlist(url)
245
  except:
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)
256
  except:
257
  return await mystic.edit_text(_["play_3"])
258
- streamtype = "youtube"
259
  img = details["thumb"]
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,
@@ -277,10 +296,11 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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)
@@ -308,10 +328,11 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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(_)
@@ -319,14 +340,17 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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":
@@ -366,11 +390,12 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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))
@@ -385,11 +410,12 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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(
@@ -411,6 +437,7 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
411
  reply_markup=InlineKeyboardMarkup(buttons),
412
  )
413
  return await play_logs(message, streamtype="Searched on YouTube")
 
414
  else:
415
  buttons = track_markup(
416
  _,
@@ -421,16 +448,18 @@ async def play_command(client, message: Message, _, chat_id, video, channel, pla
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]
@@ -440,20 +469,31 @@ async def play_music(client, CallbackQuery, _):
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
  )
@@ -485,28 +525,32 @@ async def play_music(client, CallbackQuery, _):
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]
@@ -521,9 +565,19 @@ async def play_playlists_command(client, CallbackQuery, _):
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"
@@ -557,16 +611,17 @@ async def play_playlists_command(client, CallbackQuery, _):
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]
@@ -577,6 +632,7 @@ async def slider_queries(client, CallbackQuery, _):
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:
@@ -592,9 +648,11 @@ async def slider_queries(client, CallbackQuery, _):
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
 
 
3
  import asyncio
4
 
5
  from pyrogram import filters
 
6
  from pyrogram.errors import FloodWait, RandomIdDuplicate
7
+ from pyrogram.types import InlineKeyboardMarkup, InputMediaPhoto, Message
8
  from pytgcalls.exceptions import NoActiveGroupCall
9
 
10
  import config
11
+ from config import BANNED_USERS, lyrical, AYU
12
  from DragMusic import Apple, Resso, SoundCloud, Spotify, Telegram, YouTube, app
13
  from DragMusic.core.call import Drag
14
  from DragMusic.utils import seconds_to_min, time_to_seconds
15
  from DragMusic.utils.channelplay import get_channeplayCB
16
  from DragMusic.utils.decorators.language import languageCB
17
  from DragMusic.utils.decorators.play import PlayWrapper
18
+ from DragMusic.utils.errors import capture_err, capture_callback_err
19
  from DragMusic.utils.formatters import formats
20
  from DragMusic.utils.inline import (
21
  botplaylist_markup,
 
26
  )
27
  from DragMusic.utils.logger import play_logs
28
  from DragMusic.utils.stream.stream import stream
 
29
 
30
 
31
  @app.on_message(
 
35
  ]) & filters.group & ~BANNED_USERS
36
  )
37
  @PlayWrapper
38
+ @capture_err
39
  async def play_command(client, message: Message, _, chat_id, video, channel, playmode, url, fplay):
40
  try:
41
  mystic = await message.reply_text(
 
98
  forceplay=fplay,
99
  )
100
  except Exception as e:
101
+ err = e if type(e).__name__ == "AssistantErr" else _["general_2"].format(type(e).__name__)
 
102
  return await mystic.edit_text(err)
103
 
104
  return await mystic.delete()
 
153
  forceplay=fplay,
154
  )
155
  except Exception as e:
156
+ err = e if type(e).__name__ == "AssistantErr" else _["general_2"].format(type(e).__name__)
 
157
  return await mystic.edit_text(err)
158
 
159
  return await mystic.delete()
 
167
  except:
168
  return await mystic.edit_text(_["play_3"])
169
 
 
170
  plist_type = "yt"
171
+ plist_id = (url.split("="))[1].split("&")[0] if "&" in url else (url.split("="))[1]
 
 
 
172
  img = config.PLAYLIST_IMG_URL
173
  cap = _["play_9"]
174
+ streamtype = "playlist"
175
+
176
  else:
177
  try:
178
  details, track_id = await YouTube.track(url)
179
+ except:
180
  return await mystic.edit_text(_["play_3"])
181
+
182
  img = details["thumb"]
183
  cap = _["play_10"].format(details["title"], details["duration_min"])
184
+ streamtype = "youtube"
185
+
186
  elif await Spotify.valid(url):
187
  spotify = True
188
  if not config.SPOTIFY_CLIENT_ID or not config.SPOTIFY_CLIENT_SECRET:
189
  return await mystic.edit_text(
190
+ sᴘᴏᴛɪғʏ ɪs ɴᴏᴛ sᴜᴘᴘᴏʀᴛᴇᴅ ʏᴇᴛ.\n\nᴘʟᴇᴀsᴇ ᴛʀʏ ᴀɢᴀɪɴ ʟᴀᴛᴇʀ."
191
  )
192
 
193
  if "track" in url:
 
195
  details, track_id = await Spotify.track(url)
196
  except:
197
  return await mystic.edit_text(_["play_3"])
198
+
199
  img = details["thumb"]
200
  cap = _["play_10"].format(details["title"], details["duration_min"])
201
+ streamtype = "youtube"
202
+
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
+
209
  plist_type = "spplay"
210
  img = config.SPOTIFY_PLAYLIST_IMG_URL
211
  cap = _["play_11"].format(app.mention, message.from_user.mention)
212
+ streamtype = "playlist"
213
+
214
  elif "album" in url:
215
  try:
216
  details, plist_id = await Spotify.album(url)
217
  except:
218
  return await mystic.edit_text(_["play_3"])
219
+
220
  plist_type = "spalbum"
221
  img = config.SPOTIFY_ALBUM_IMG_URL
222
  cap = _["play_11"].format(app.mention, message.from_user.mention)
223
+ streamtype = "playlist"
224
+
225
  elif "artist" in url:
226
  try:
227
  details, plist_id = await Spotify.artist(url)
228
  except:
229
  return await mystic.edit_text(_["play_3"])
230
+
231
  plist_type = "spartist"
232
  img = config.SPOTIFY_ARTIST_IMG_URL
233
  cap = _["play_11"].format(message.from_user.first_name)
234
+ streamtype = "playlist"
235
+
236
  else:
237
  return await mystic.edit_text(_["play_15"])
238
+
239
  elif await Apple.valid(url):
240
  if "album" in url:
241
  try:
242
  details, track_id = await Apple.track(url)
243
  except:
244
  return await mystic.edit_text(_["play_3"])
245
+
246
  img = details["thumb"]
247
  cap = _["play_10"].format(details["title"], details["duration_min"])
248
+ streamtype = "youtube"
249
+
250
  elif "playlist" in url:
251
  spotify = True
252
  try:
253
  details, plist_id = await Apple.playlist(url)
254
  except:
255
  return await mystic.edit_text(_["play_3"])
256
+
257
  plist_type = "apple"
258
  img = url
259
  cap = _["play_12"].format(app.mention, message.from_user.mention)
260
+ streamtype = "playlist"
261
+
262
  else:
263
  return await mystic.edit_text(_["play_3"])
264
+
265
  elif await Resso.valid(url):
266
  try:
267
  details, track_id = await Resso.track(url)
268
  except:
269
  return await mystic.edit_text(_["play_3"])
270
+
271
  img = details["thumb"]
272
  cap = _["play_10"].format(details["title"], details["duration_min"])
273
+ streamtype = "youtube"
274
+
275
  elif await SoundCloud.valid(url):
276
  try:
277
  details, track_path = await SoundCloud.download(url)
278
+ except:
279
+ return await mystic.edit_text(_["play_3"])
280
+
281
+ if details["duration_sec"] > config.DURATION_LIMIT:
282
+ return await mystic.edit_text(
283
+ _["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
284
+ )
285
+
286
+ try:
287
  await stream(
288
  _,
289
  mystic,
 
296
  forceplay=fplay,
297
  )
298
  except Exception as e:
299
+ err = e if type(e).__name__ == "AssistantErr" else _["general_2"].format(type(e).__name__)
 
300
  return await mystic.edit_text(err)
301
+
302
  return await mystic.delete()
303
+
304
  else:
305
  try:
306
  await Drag.stream_call(url)
 
328
  forceplay=fplay,
329
  )
330
  except Exception as e:
331
+ err = e if type(e).__name__ == "AssistantErr" else _["general_2"].format(type(e).__name__)
 
332
  return await mystic.edit_text(err)
333
+
334
  return await play_logs(message, streamtype="M3U8 or Index Link")
335
+
336
  else:
337
  if len(message.command) < 2:
338
  buttons = botplaylist_markup(_)
 
340
  _["play_18"],
341
  reply_markup=InlineKeyboardMarkup(buttons),
342
  )
343
+
344
  slider = True
345
  query = message.text.split(None, 1)[1]
346
  if "-v" in query:
347
  query = query.replace("-v", "")
348
+
349
  try:
350
+ details, track_id = await YouTube.track(query)
351
  except:
352
  return await mystic.edit_text(_["play_3"])
353
+
354
  streamtype = "youtube"
355
 
356
  if str(playmode) == "Direct":
 
390
  forceplay=fplay,
391
  )
392
  except Exception as e:
393
+ err = e if type(e).__name__ == "AssistantErr" else _["general_2"].format(type(e).__name__)
 
394
  return await mystic.edit_text(err)
395
+
396
  await mystic.delete()
397
  return await play_logs(message, streamtype=streamtype)
398
+
399
  else:
400
  if plist_type:
401
  ran_hash = "".join(random.choices(string.ascii_uppercase + string.digits, k=10))
 
410
  )
411
  await mystic.delete()
412
  await message.reply_photo(
413
+ photo=(details["thumb"] if plist_type == "yt" else (details if plist_type == "apple" else img)),
414
  caption=cap,
415
  reply_markup=InlineKeyboardMarkup(buttons),
416
  )
417
  return await play_logs(message, streamtype=f"Playlist : {plist_type}")
418
+
419
  else:
420
  if slider:
421
  buttons = slider_markup(
 
437
  reply_markup=InlineKeyboardMarkup(buttons),
438
  )
439
  return await play_logs(message, streamtype="Searched on YouTube")
440
+
441
  else:
442
  buttons = track_markup(
443
  _,
 
448
  )
449
  await mystic.delete()
450
  await message.reply_photo(
451
+ photo=details["thumb"],
452
+ caption=_["play_10"].format(
453
+ details["title"],
454
+ details["duration_min"],
455
+ ),
456
  reply_markup=InlineKeyboardMarkup(buttons),
457
  )
458
  return await play_logs(message, streamtype="URL Search Inline")
459
 
 
460
  @app.on_callback_query(filters.regex("MusicStream") & ~BANNED_USERS)
461
  @languageCB
462
+ @capture_callback_err
463
  async def play_music(client, CallbackQuery, _):
464
  try:
465
  callback_data = CallbackQuery.data.split(None, 1)[1]
 
469
  return await CallbackQuery.answer(_["playcb_1"], show_alert=True)
470
 
471
  chat_id, channel = await get_channeplayCB(_, cplay, CallbackQuery)
472
+
473
  user_name = CallbackQuery.from_user.first_name
474
  await CallbackQuery.message.delete()
475
  await CallbackQuery.answer()
476
 
477
  try:
478
+ mystic = await CallbackQuery.message.reply_text(
479
+ _["play_2"].format(channel) if channel else random.choice(AYU)
480
+ )
481
+ except FloodWait as e:
482
+ await asyncio.sleep(e.value)
483
+ mystic = await CallbackQuery.message.reply_text(
484
+ _["play_2"].format(channel) if channel else random.choice(AYU)
485
+ )
486
+ except RandomIdDuplicate:
487
+ mystic = await app.send_message(
488
+ CallbackQuery.message.chat.id,
489
+ _["play_2"].format(channel) if channel else random.choice(AYU)
490
+ )
491
 
492
+ details, track_id = await YouTube.track(vidid, videoid=vidid)
493
 
494
  if details.get("duration_min"):
495
  duration_sec = time_to_seconds(details["duration_min"])
496
+ if duration_sec and duration_sec > config.DURATION_LIMIT:
497
  return await mystic.edit_text(
498
  _["play_6"].format(config.DURATION_LIMIT_MIN, app.mention)
499
  )
 
525
  streamtype="youtube",
526
  forceplay=forceplay,
527
  )
528
+
529
  await mystic.delete()
530
+
531
  except Exception as e:
532
+ err = e if type(e).__name__ == "AssistantErr" else _["general_2"].format(type(e).__name__)
 
533
  return await CallbackQuery.message.reply_text(err)
534
 
535
 
536
+ @app.on_callback_query(filters.regex("AnonymousAdmin") & ~BANNED_USERS)
537
+ @capture_callback_err
538
  async def anonymous_check(client, CallbackQuery):
539
+ try:
540
+ await CallbackQuery.answer(
541
+ "» ʀᴇᴠᴇʀᴛ ʙᴀᴄᴋ ᴛᴏ ᴜsᴇʀ ᴀᴄᴄᴏᴜɴᴛ :\n\n"
542
+ "ᴏᴘᴇɴ ʏᴏᴜʀ ɢʀᴏᴜᴘ sᴇᴛᴛɪɴɢs.\n"
543
+ "-> ᴀᴅᴍɪɴɪsᴛʀᴀᴛᴏʀs\n-> ᴄʟɪᴄᴋ ᴏɴ ʏᴏᴜʀ ɴᴀᴍᴇ\n"
544
+ "-> ᴜɴᴄʜᴇᴄᴋ ᴀɴᴏɴʏᴍᴏᴜs ᴀᴅᴍɪɴ ᴘᴇʀᴍɪssɪᴏɴs.",
545
+ show_alert=True,
546
+ )
547
+ except:
548
+ pass
549
 
550
 
551
+ @app.on_callback_query(filters.regex("AnniePlaylists") & ~BANNED_USERS)
552
  @languageCB
553
+ @capture_callback_err
554
  async def play_playlists_command(client, CallbackQuery, _):
555
  try:
556
  callback_data = CallbackQuery.data.split(None, 1)[1]
 
565
  await CallbackQuery.answer()
566
 
567
  try:
568
+ mystic = await CallbackQuery.message.reply_text(
569
+ _["play_2"].format(channel) if channel else random.choice(AYU)
570
+ )
571
+ except FloodWait as e:
572
+ await asyncio.sleep(e.value)
573
+ mystic = await CallbackQuery.message.reply_text(
574
+ _["play_2"].format(channel) if channel else random.choice(AYU)
575
+ )
576
+ except RandomIdDuplicate:
577
+ mystic = await app.send_message(
578
+ CallbackQuery.message.chat.id,
579
+ _["play_2"].format(channel) if channel else random.choice(AYU)
580
+ )
581
 
582
  videoid = lyrical.get(videoid)
583
  video = mode == "v"
 
611
  spotify=spotify,
612
  forceplay=forceplay,
613
  )
614
+
615
  await mystic.delete()
616
+
617
  except Exception as e:
618
+ err = e if type(e).__name__ == "AssistantErr" else _["general_2"].format(type(e).__name__)
 
619
  return await CallbackQuery.message.reply_text(err)
620
 
621
 
622
  @app.on_callback_query(filters.regex("slider") & ~BANNED_USERS)
623
  @languageCB
624
+ @capture_callback_err
625
  async def slider_queries(client, CallbackQuery, _):
626
  try:
627
  callback_data = CallbackQuery.data.split(None, 1)[1]
 
632
 
633
  rtype = int(rtype)
634
  query_type = (rtype + 1) if what == "F" else (rtype - 1)
635
+
636
  if query_type > 9:
637
  query_type = 0
638
  if query_type < 0:
 
648
  duration_min,
649
  ),
650
  )
651
+
652
  await CallbackQuery.edit_message_media(
653
  media=med, reply_markup=InlineKeyboardMarkup(buttons)
654
  )
655
  await CallbackQuery.answer(_["playcb_2"])
656
+
657
+ except Exception:
658
+ pass