def init_genius(token): # get the genius instanse genius = Genius(token) # Turn off status messages genius.verbose = False # Remove section headers (e.g. [Chorus]) from lyrics when searching genius.remove_section_headers = True # Include hits thought to be non-songs (e.g. track lists) genius.skip_non_songs = False # Exclude songs with these words in their title genius.excluded_terms = ["(Remix)", "(Live)"] return genius
def main(): genius = Genius(apikeys.genius) genius.excluded_terms = ['(How to pronounce)'] genius.remove_section_headers = True genius.skip_non_songs = True pinyin = Pinyin() song_info = [ input("Enter the song name\n"), input( "Enter the artist name (recommended, leave blank if you don't know)\n" ) ] song = genius.search_song(song_info[0], song_info[1]) lyrics = song.lyrics pinyin_lyrics = pinyin.get_pinyin(lyrics, splitter=' ', tone_marks='marks') pinyin_lyrics = cleanup(pinyin_lyrics) print(pinyin_lyrics) outfile_path = "C:\\Users\\Declan\\Desktop\\" + song.title + ', ' + song.artist + '-Pinyin.txt' outfile = open(outfile_path, 'w', encoding='utf-8') outfile.write(pinyin_lyrics) outfile.close()
from lyricsgenius import Genius from colorama import init, Fore, Style from mutagen.easyid3 import EasyID3 from genius_tokens import CLIENT_ACCESS_TOKEN import sys args = sys.argv if len(args) == 1: print("Specify path to audio") exit(1) audio_path = args[1] audio = EasyID3(audio_path) genius = Genius(CLIENT_ACCESS_TOKEN) genius.verbose = False genius.remove_section_headers = True song = genius.search_song(audio["title"][0], audio["artist"][0]) print(song.lyrics)