Skip to content

Commit d0ee849

Browse files
Merge pull request avinashkranjan#2609 from Abhinavcode13/master-2
Create script.py
2 parents b96cc8d + 4a3a69e commit d0ee849

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

Lyrics Finder /script.py

+24
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
import requests
2+
3+
def find_lyrics(artist, title):
4+
base_url = 'https://api.lyrics.ovh/v1/{}/{}'.format(artist, title)
5+
response = requests.get(base_url)
6+
7+
if response.status_code == 200:
8+
data = response.json()
9+
lyrics = data.get('lyrics', 'Lyrics not found for this song.')
10+
return lyrics
11+
else:
12+
return 'Error fetching lyrics. Please check the artist and title and try again.'
13+
14+
if __name__ == '__main__':
15+
artist_name = input('Enter the artist name: ')
16+
song_title = input('Enter the song title: ')
17+
18+
lyrics = find_lyrics(artist_name, song_title)
19+
print('\nLyrics:\n')
20+
print(lyrics)
21+
22+
#Make sure you have the requests library installed in your Python environment before running this script. You can install it using pip install requests.
23+
24+
#To use the script, simply run it, and it will prompt you to enter the artist name and song title. After entering the details, it will fetch and display the lyrics for the specified song.

0 commit comments

Comments
 (0)