Skip to content

Commit

Permalink
Create lyrics.py
Browse files Browse the repository at this point in the history
  • Loading branch information
Tanjiroop authored Aug 11, 2024
1 parent 28f80e6 commit 1ff94f4
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions plugins/helpers/lyrics.py
Original file line number Diff line number Diff line change
@@ -0,0 +1,27 @@
from pyrogram import Client, filters
import requests

@Client.on_message(filters.command("lyrics"))
async def lyrics(client, message):
args = message.text.split(" ")
if len(args) < 2:
await message.reply_text("Please provide a song name! 🔎")
return

song_name = " ".join(args[1:])
api = f"https://horrid-api.onrender.com/lyrics?song={song_name}"

try:
response = requests.get(api)
response.raise_for_status()
data = response.json()
title = data.get('title', 'Title not found')
artist = data.get('artist', 'Artist not found')
lyrics = data.get('lyrics', 'Lyrics not found')

await message.reply_text(f"Title: {title}\nArtist: {artist}\n\nLyrics:\n{lyrics}")

except requests.RequestException as e:
await message.reply_text(f"Error fetching lyrics: {str(e)}")
except ValueError:
await message.reply_text("Error decoding response.")

0 comments on commit 1ff94f4

Please sign in to comment.