Spaces:
Running
Running
Update DragMusic/plugins/play/play.py
Browse files
DragMusic/plugins/play/play.py
CHANGED
@@ -2,7 +2,7 @@ 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
|
@@ -22,7 +22,6 @@ from DragMusic.utils.inline import (
|
|
22 |
)
|
23 |
from DragMusic.utils.logger import play_logs
|
24 |
from DragMusic.utils.stream.stream import stream
|
25 |
-
from DragMusic.core import nowplaying
|
26 |
from config import BANNED_USERS, lyrical
|
27 |
|
28 |
|
@@ -92,8 +91,7 @@ async def play_commnd(
|
|
92 |
"path": file_path,
|
93 |
"dur": dur,
|
94 |
}
|
95 |
-
|
96 |
-
nowplaying.set_current_song(details)
|
97 |
try:
|
98 |
await stream(
|
99 |
_,
|
@@ -138,8 +136,6 @@ async def play_commnd(
|
|
138 |
"path": file_path,
|
139 |
"dur": dur,
|
140 |
}
|
141 |
-
# Store current song info for web player
|
142 |
-
nowplaying.set_current_song(details)
|
143 |
try:
|
144 |
await stream(
|
145 |
_,
|
@@ -338,12 +334,10 @@ async def play_commnd(
|
|
338 |
query = query.replace("-v", "")
|
339 |
try:
|
340 |
details, track_id = await YouTube.track(query)
|
341 |
-
except
|
342 |
-
await mystic.edit_text(
|
343 |
-
return
|
344 |
if not details:
|
345 |
-
await mystic.edit_text("
|
346 |
-
return
|
347 |
streamtype = "youtube"
|
348 |
if str(playmode) == "Direct":
|
349 |
if not plist_type:
|
@@ -446,52 +440,6 @@ async def play_commnd(
|
|
446 |
return await play_logs(message, streamtype=f"URL Searched Inline")
|
447 |
|
448 |
|
449 |
-
@app.on_message(filters.command("webplay") & ~BANNED_USERS)
|
450 |
-
async def webplay_command(client, message: Message):
|
451 |
-
query = None
|
452 |
-
if len(message.command) > 1:
|
453 |
-
query = " ".join(message.command[1:])
|
454 |
-
else:
|
455 |
-
await message.reply_text("Please provide a song name or YouTube link to play in the web app.")
|
456 |
-
return
|
457 |
-
mystic = await message.reply_text("Searching for your song on YouTube...")
|
458 |
-
# Search YouTube and get track info
|
459 |
-
try:
|
460 |
-
details, track_id = await YouTube.track(query)
|
461 |
-
except Exception as e:
|
462 |
-
await mystic.edit_text(f"Failed to find song: {e}")
|
463 |
-
return
|
464 |
-
if not details:
|
465 |
-
await mystic.edit_text("❌ Could not fetch video details. Please try again later.")
|
466 |
-
return
|
467 |
-
# Download audio
|
468 |
-
try:
|
469 |
-
file_path, _ = await YouTube.download(details["link"], mystic)
|
470 |
-
except Exception as e:
|
471 |
-
await mystic.edit_text(f"Failed to download song: {e}")
|
472 |
-
return
|
473 |
-
# Store in nowplaying
|
474 |
-
song_info = {
|
475 |
-
"title": details["title"],
|
476 |
-
"link": details["link"],
|
477 |
-
"path": file_path,
|
478 |
-
"dur": details["duration_min"],
|
479 |
-
"thumb": details.get("thumb"),
|
480 |
-
}
|
481 |
-
nowplaying.set_current_song(song_info)
|
482 |
-
# Delete the status message before sending the web app button
|
483 |
-
try:
|
484 |
-
await mystic.delete()
|
485 |
-
except:
|
486 |
-
pass
|
487 |
-
await message.reply(
|
488 |
-
"Song is ready in the mini web app!",
|
489 |
-
reply_markup=InlineKeyboardMarkup(
|
490 |
-
[[InlineKeyboardButton("Open Player", web_app=WebAppInfo(url="https://huggingface.co/spaces/dragonxd1/DragMusicV2"))]]
|
491 |
-
)
|
492 |
-
)
|
493 |
-
|
494 |
-
|
495 |
@app.on_callback_query(filters.regex("MusicStream") & ~BANNED_USERS)
|
496 |
@languageCB
|
497 |
async def play_music(client, CallbackQuery, _):
|
@@ -605,4 +553,4 @@ async def play_playlists_command(client, CallbackQuery, _):
|
|
605 |
_["play_2"].format(channel) if channel else _["play_1"]
|
606 |
)
|
607 |
videoid = lyrical.get(videoid)
|
608 |
-
video = Tr
|
|
|
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
|
|
|
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 |
|
|
|
91 |
"path": file_path,
|
92 |
"dur": dur,
|
93 |
}
|
94 |
+
|
|
|
95 |
try:
|
96 |
await stream(
|
97 |
_,
|
|
|
136 |
"path": file_path,
|
137 |
"dur": dur,
|
138 |
}
|
|
|
|
|
139 |
try:
|
140 |
await stream(
|
141 |
_,
|
|
|
334 |
query = query.replace("-v", "")
|
335 |
try:
|
336 |
details, track_id = await YouTube.track(query)
|
337 |
+
except:
|
338 |
+
return await mystic.edit_text(_["play_3"])
|
|
|
339 |
if not details:
|
340 |
+
return await mystic.edit_text(_["play_3"])
|
|
|
341 |
streamtype = "youtube"
|
342 |
if str(playmode) == "Direct":
|
343 |
if not plist_type:
|
|
|
440 |
return await play_logs(message, streamtype=f"URL Searched Inline")
|
441 |
|
442 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
443 |
@app.on_callback_query(filters.regex("MusicStream") & ~BANNED_USERS)
|
444 |
@languageCB
|
445 |
async def play_music(client, CallbackQuery, _):
|
|
|
553 |
_["play_2"].format(channel) if channel else _["play_1"]
|
554 |
)
|
555 |
videoid = lyrical.get(videoid)
|
556 |
+
video = Tr
|