Amazing-Python-Scripts

Форк
0
26 строк · 987.0 Байт
1
import requests
2

3

4
def find_lyrics(artist, title):
5
    base_url = 'https://api.lyrics.ovh/v1/{}/{}'.format(artist, title)
6
    response = requests.get(base_url)
7

8
    if response.status_code == 200:
9
        data = response.json()
10
        lyrics = data.get('lyrics', 'Lyrics not found for this song.')
11
        return lyrics
12
    else:
13
        return 'Error fetching lyrics. Please check the artist and title and try again.'
14

15

16
if __name__ == '__main__':
17
    artist_name = input('Enter the artist name: ')
18
    song_title = input('Enter the song title: ')
19

20
    lyrics = find_lyrics(artist_name, song_title)
21
    print('\nLyrics:\n')
22
    print(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

Использование cookies

Мы используем файлы cookie в соответствии с Политикой конфиденциальности и Политикой использования cookies.

Нажимая кнопку «Принимаю», Вы даете АО «СберТех» согласие на обработку Ваших персональных данных в целях совершенствования нашего веб-сайта и Сервиса GitVerse, а также повышения удобства их использования.

Запретить использование cookies Вы можете самостоятельно в настройках Вашего браузера.