def download_lyrics(artist=str): api = azapi.AZlyrics(proxies=proxyDict) api.artist = artist all_songs = api.getSongs() print('Found {} total songs'.format(len(all_songs))) for song in all_songs: # check if lyric file exists already file_name = '{} - {}.txt'.format(str(song).strip(), api.artist) if not os.path.isfile(file_name): print('Getting lyrics for {}...'.format(str(song))) api.getLyrics(url=all_songs[song]["url"], save=True, sleep=30.0) else: print('Lyric file exists already for {}'.format(str(song)))
async def lyr_command(self, ctx, title): channel_lyrics = self.client.get_channel(784434857445949490) await channel_lyrics.send( "<:mag_right:782771344726687764> `Searching for the lyrics...`") API = azapi.AZlyrics('google', accuracy=0.5) # API.artist = artist API.title = title #get and/or save the lyrics lyrics = API.getLyrics() lyrics1 = lyrics[:1995] lyrics2 = lyrics[1995:] await channel_lyrics.send(f"`{lyrics1}`") await channel_lyrics.send(f"`{lyrics2}`")
ydl_opts = { 'format': 'bestaudio', 'outtmpl': selectedSong['artists'][0]['name'] + ' - ' + selectedSong['title'] + '.m4a', 'quiet': 'true' } with youtube_dl.YoutubeDL(ydl_opts) as ydl: ydl.download([selectedSong['videoId']]) print('✅ Downloaded \033[95m\033[1m', selectedSong['title'], '\033[0m') ## Thumbnail Grabber # Grabs album art from Youtube Music with ytmusicapi. thumbnailURL = selectedSong['thumbnails'][0]['url'].split( '=' )[0] # Since the thumbnail URL contains image dimensions, this splits size data off to save in highest resolution available. wget.download(thumbnailURL, 'thumbnail.jpg' ) # There's probably a better solution than wget but ¯\_(ツ)_/¯ # Lyrics Collector # Data is acquired from AZLyrics.com using azapi. api = azapi.AZlyrics() api.artist = selectedSong['artists'][0]['name'] api.title = selectedSong['title'] api.getLyrics(save=True) # Saves the lyrics as a (Title) - (Artist).txt
from dearpygui.dearpygui import * from dearpygui.wrappers import * import azapi api = azapi.AZlyrics('google', accuracy=0.5) set_main_window_size(850,800) set_main_window_title("GUI Lyrics") def mainCallback(sender, data): if get_table_selections("songlisttable"): index = get_table_selections("songlisttable") urls = get_data("songs") url = urls[index[0][0]] set_value(get_data("lyricsdata"), api.getLyrics(url)) print(api.getLyrics(url)) add_data("lyricsdata", api.getLyrics(url)) set_table_selection("songlisttable", row=index[0][0], column=index[0][1], value=False) def searchHandler(sender, data): clear_table("songlisttable") if get_value("artist") and get_value("title"): api.artist = get_value("artist") api.title = get_value("title") try: set_value(get_data("lyricsdata"), api.getLyrics()) add_data("lyricsdata", api.getLyrics()) except: add_text(get_data("lyricsdata"), "Try another Search term") add_data("lyricsdata", "Try another Search term") songs = api.getSongs()
import azapi # playlist.txt 파일에서 가수와 제목을 가져옴 with open('playlist.txt', 'r') as f: playlist = f.readlines() # 개행 문자 제거 playlist = list(map(lambda s:s.strip(), playlist)) playlist_splited = list() for i in range(len(playlist)) : # '-'를 기준으로 가수와 제목을 구분 playlist_splited.append(playlist[i].split(' - ')) # 앞에서 가져온 가수와 제목을 바탕으로 az api를 이용해 가사 검색 & 명사, 형용사 키워드 추출 Music = azapi.AZlyrics() for artist, title in playlist_splited : print(artist, '-', title) # 가사 검색 lyric = Music.getLyrics(artist=artist, title=title) # 가사를 모두 소문자로 변경 lyric = lyric.lower() # lyric 문자열을 토큰화 한 다음 universal 품사 tagset 적용 lyric_tokens = pos_tag(word_tokenize(lyric), tagset='universal') # 명사, 형용사 태그의 토큰들만 모아 각각 리스트를 만듦 lyric_noun_list = [word for word, pos in lyric_tokens if pos in ['NOUN']] lyric_adj_list = [word for word, pos in lyric_tokens if pos in ['ADJ']] # 길이 3 미만의 단어는 제외 lyric_noun_list = [word for word in lyric_noun_list if not len(word) < 3]
import azapi import re import pprint import json import time azAPI = azapi.AZlyrics() def getCleanedLyrics(songData, retries=3): lyrics_from_api = getLyricsFromAPI(songData, retries) if lyrics_from_api == None: print("Error: Unable to fetch: " + songData['title'] + " by " + songData['artist']) return None else: cleaned_lyrics = cleanLyrics(lyrics_from_api) return cleaned_lyrics def getLyricsFromAPI(songData, retries): counter = 0 while (counter < retries): print("------------------------------") print("Attempting to fetch: " + songData['title'] + " by " + songData['artist']) print("------------------------------") try: azAPI.artist = songData['artist'] azAPI.title = songData['title'] res = azAPI.getLyrics(save=False, sleep=10)