Skip to content

Commit

Permalink
- spotify music "downloading"
Browse files Browse the repository at this point in the history
  • Loading branch information
athphane committed Jun 12, 2024
1 parent 8cef339 commit 4bdc586
Showing 1 changed file with 24 additions and 0 deletions.
24 changes: 24 additions & 0 deletions userbot/plugins/spotify.py
Original file line number Diff line number Diff line change
@@ -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
Expand All @@ -25,6 +28,27 @@ async def now_playing(bot: UserBot, message: Message):
await message.edit(f'{emoji.MUSICAL_NOTE} Currently Playing: <a href="{link}">{song}</a>')


@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):
Expand Down

0 comments on commit 4bdc586

Please sign in to comment.