Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Sign up
Appearance settings

Commit 4a3a69e

Browse files
Create script.py
1 parent c0b68a7 commit 4a3a69e

File tree

1 file changed

+24
-0
lines changed

1 file changed

+24
-0
lines changed

‎Lyrics Finder /script.py‎

Lines changed: 24 additions & 0 deletions
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)

AltStyle によって変換されたページ (->オリジナル) /