Amazing-Python-Scripts
26 строк · 987.0 Байт
1import requests
2
3
4def find_lyrics(artist, title):
5base_url = 'https://api.lyrics.ovh/v1/{}/{}'.format(artist, title)
6response = requests.get(base_url)
7
8if response.status_code == 200:
9data = response.json()
10lyrics = data.get('lyrics', 'Lyrics not found for this song.')
11return lyrics
12else:
13return 'Error fetching lyrics. Please check the artist and title and try again.'
14
15
16if __name__ == '__main__':
17artist_name = input('Enter the artist name: ')
18song_title = input('Enter the song title: ')
19
20lyrics = find_lyrics(artist_name, song_title)
21print('\nLyrics:\n')
22print(lyrics)
23
24# Make sure you have the requests library installed in your Python environment before running this script. You can install it using pip install requests.
25
26# 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.
27