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 retrieve_song_lyrics(update, context):
    '''get song lyrics'''
    text = update.message.text
    genius = Genius(LYRICS_TOKEN)
    genius.skip_non_songs = True
    song = genius.search_song(text, artist='', get_full_info=False)
    if not song:
        update.message.reply_text("Unable to find lyrics for the given song.")
    else:
        lyrics = song.lyrics
        song_length = len(lyrics)
        count = 0
        try:
            while song_length > 4096:
                update.message.reply_text(lyrics[:4096])
                song_length -= 4096
                count += 1
            update.message.reply_text(lyrics[4096 * count:])
        except:
            update.message.reply_text(
                "Unable to find lyrics for the given song.")
    update.message.reply_text("Use /help to list available actions.")
    return ConversationHandler.END
Beispiel #3
0
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()
Beispiel #4
0
from datetime import datetime
from Creds import token, csv_pre

from lyricsgenius import Genius
import os
import pandas as pd

genius = Genius(token, timeout=10)
path = 'Songs/'
# genius formatting
genius.remove_section_headers = True
genius.skip_non_songs = True
genius.excluded_terms = ["(Remix)"]


class ReadArtist:
    def __init__(self, artist):
        self.time = datetime.now()
        self.artist = artist
        self.artist_dict = {}
        self.file_n = path + artist + csv_pre
        self.artist_time = {}

    def collect_song_data(self, song_obj):

        song_dict = song_obj.to_dict()

        song_dict['Artist'] = self.artist
        if type(song_dict['year']) == float:
            str(song_dict['year'])
        if song_dict['year'] == 'nan':