def getLyrics(track, artist): try: s = Song(track, artist) if not s.lyrics: azLink = lyricsLink(track, artist, 'azlyrics') return "no lyrics not found on metrolyrics redirect to azlyrics", azLink return s.lyrics except KeyError: metLink = lyricsLink(track, artist, 'metrolyrics') try: s = Song(url=metLink) return s.lyrics except AttributeError: return "could not find lyrics:("
def analysis_rapper(title, artist): s = Song(artist=artist, title=title) lyrics = s.lyrics.encode("utf-8") try: lyrics = clean_lyrics(lyrics) except: lyrics = lyrics return analysis(lyrics, title)
def getLyrics(song, artist): try: s = Song(song, artist) if not s.lyrics: raise Exception return s.lyrics except Exception as e: try: az = AzRequest(song, artist) print("searching az lyrics") lyrics = az.get_lyrics() return lyrics except Exception as e: print(e) return "lyrics not found:/"
def handle(self, *args, **kwargs): user = self._get_user() project = self._get_project(user) songdict = { a: [Song(artist=artist, title=t) for t in v] for a, v in albums.items() } self._load_lyrics(songdict) for album, songlist in songdict.items(): category = Category.objects.create(title=album, project=project) category.save() for song in songlist: lyriclines = song.lyrics.splitlines() lyriclines = [l + ' ' for l in lyriclines] post = Post.objects.create(title=song._title, content='\n'.join(lyriclines), category=category, project=project, date_created=timezone.now(), date_updated=timezone.now()) post.save()
def get_lyrics(self, song_title, artist_name): parsed_song = Song(title=song_title, artist=artist_name) self._lyrics = parsed_song.lyrics return parsed_song.lyrics
if not option == 'q': # MetroLyrics if option == '1': from tswift import Song print('You can either get the song with the song title and artist' 'name, or you can search via lyrics.') print('Please choose which method you would like to use.') print('a. Artist Name + Song Title') print('b. Search by lyrics') ml_option = input(': ') if ml_option == 'a': artist_name = input('Type in the name of the artist: ') song_title = input('Type in the title of the song: ') lyrics = Song(title=song_title, artist=artist_name) filename = (artist_name + ' - ' + song_title + '.txt') if Path('in/').exists(): basepath = Path('in/') else: os.mkdir('in') if Path('in/').exists(): basepath = Path('in/') with open(basepath / filename, 'w', encoding='utf-8') as export: export.write(lyrics.format()) export.close() print('Downloaded: ' + artist_name + ' - ' + song_title)
def test(): s = Song('Taylor Swift', 'Love Story') s = Song.find_song('Love Story') print(s.lyrics)