-
Notifications
You must be signed in to change notification settings - Fork 39
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.") |