|
| 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