From 4bdc5867772466cf49e88694fbfc65ba984935ad Mon Sep 17 00:00:00 2001 From: athphane Date: Thu, 13 Jun 2024 00:51:09 +0500 Subject: [PATCH] - spotify music "downloading" --- userbot/plugins/spotify.py | 24 ++++++++++++++++++++++++ 1 file changed, 24 insertions(+) diff --git a/userbot/plugins/spotify.py b/userbot/plugins/spotify.py index b954178e..ae5842ab 100644 --- a/userbot/plugins/spotify.py +++ b/userbot/plugins/spotify.py @@ -1,4 +1,7 @@ +import asyncio + from pyrogram import emoji, filters +from pyrogram.enums import ParseMode from pyrogram.types import Message from userbot import ALLOWED_USERS, UserBot @@ -25,6 +28,27 @@ async def now_playing(bot: UserBot, message: Message): await message.edit(f'{emoji.MUSICAL_NOTE} Currently Playing: {song}') +@UserBot.on_message(filters.command(["npd"], ".") & (filters.me | filters.user(ALLOWED_USERS))) +async def download_now_playing_song(bot: UserBot, message: Message): + current_track = await spotify.now_playing() + + if not current_track: + await message.edit("I am not playing any music right now!") + return + + if current_track == "API details not set": + await message.edit("API details not set. Please read the README!") + return + + track = current_track['item'] + link = track['external_urls']['spotify'] + + await asyncio.gather( + bot.send_message('@deezermusicbot', link, parse_mode=ParseMode.DISABLED), + message.delete() + ) + + @UserBot.on_message( filters.command(["sdev", "sdevices", "spotifydevices", "sd"], ".") & (filters.me | filters.user(ALLOWED_USERS))) async def list_devices(bot: UserBot, message: Message):