Пример #1
0
def find_metadata():
    results = sp.search(q=spotilib.song(), limit=50)
    for i, t in enumerate(results['tracks']['items']):
        artist_meta = str(t['artists'])
        temp_artist_meta = artist_meta.split(',')
        track = (t['name']).encode('utf-8')
        track_uri = (t['uri']).encode('utf-8')

        artist, artist_uri = get_artist_uri(n=len(temp_artist_meta),
                                            dataset=temp_artist_meta)

        if spotilib.artist() in artist and track == spotilib.song():
            return track, track_uri, artist, artist_uri
Пример #2
0
def get_album_art():
    art.image = None
    title.pack_forget()
    album_art.pack(side=LEFT)
    title.pack(side=LEFT)
    artist = spotilib.artist()
    song = spotilib.song()
    # Prints song name and artist for console logging
    print(song, '-', artist)
    try:
        spotify = spotipy.Spotify()
        querry = '{0} - {1}'.format(song, artist)
        results = spotify.search(q=querry, type='track', limit=1)

        items = results['tracks']['items']
        track = items[0]
        url = track['album']['images'][2]['url']
        print('Found album art at:', url)

        u = urlopen(url)
        image_bytes = u.read()
        data_stream = io.BytesIO(image_bytes)
        album_art_data = img.open(data_stream)
        u.close()
        album = ImageTk.PhotoImage(album_art_data)
        art.config(image=album)
        art.image = album
        art.grid()
    except Exception:
        title.pack()
        print('^ Album art not found! ^')
Пример #3
0
def main():
    old_song = 'None'

    while True:
        time.sleep(5)
        song = spotilib.song()
        if song != old_song:
            update()
            old_song = song
Пример #4
0
def update():
    os.system('cls')
    print generateMessage()

    artist = spotilib.artist()
    song = spotilib.song()

    lyrics = getLyrics(artist, song)
    os.system('cls')
    print(lyrics)
Пример #5
0
def track(Type):
    if find_metadata() is None:
        print "spotimeta wasn\'t able to get all metadata of current song"
        return spotilib.song()
    elif Type == 'name':
        return find_metadata()[0]
    elif Type == "uri":
        return find_metadata()[1]
    else:
        print "Error: Invalid Type"
Пример #6
0
def check_save_button():
    artist = spotilib.artist()
    song = spotilib.song().split(' - ', 1)[0]
    master.update_idletasks()
    if os.path.isfile('{0}/lyrics/{1} - {2}.txt'.format(
            os.getcwd(), song, artist)):
        save_button.configure(image=saved_icon, state='normal')

    else:
        save_button.configure(image=save_icon, state='normal')
    master.update_idletasks()
Пример #7
0
def get_title():
    title = {}
    if _PLAYER == 'spotify':
        title['artist'] = spotilib.artist()
        title['songname'] = spotilib.song()
    else:
        try:
            with open(fullpath, 'r') as file:
                fulltitle = file.read()
        except:
            fulltitle = 'Not Found - Not Found'
        title['artist'] = fulltitle.split('-')[0].lstrip()
        title['songname'] = fulltitle.split('-')[1].lstrip()
    return jdumps(title)
Пример #8
0
def save():
    global lyrics
    directory = '{0}/lyrics/'.format(os.getcwd())
    if not os.path.exists(directory):
        os.makedirs(directory)
    artist = spotilib.artist()
    song = spotilib.song().split(' - ', 1)[0]
    file = '{0}/lyrics/{1} - {2}.txt'.format(os.getcwd(), song, artist)
    if not os.path.isfile(file):
        # lyrics = lyric.get(artist, song)
        with open(file, 'w') as lyricfile:
            lyricfile.write(lyrics)
            lyricfile.close()
        print('File "{0}" saved \n'.format(file))
        check_save_button()

    else:
        os.remove(file)
        print('File "{0}" removed \n'.format(file))
        check_save_button()
Пример #9
0
searchURL = "http://www.google.com/?#q="

#user guide
print('O programa coleta a musica que voce esta ouvindo no spotify e')
print('abre a respectiva pagina da letra no Genius.com através do Firefox.')
print('Pause a música para desligar o programa. Ele fechará todas abas.')
print('~~~Bem vindos ao SpotiGenius fetcher~~~')
print()
info = spotilib.song_info()
if info == "Spotify":
    print('Nada tocando... vou dar play')
    spotilib.play()
    time.sleep(3)
art = spotilib.artist()  #returns the artist of the current playing song
son = spotilib.song()  #returns the song title of the current playing song
get_songname(art, son)
g = spotilib.song_info()
while g != "Spotify":
    art1 = spotilib.artist()
    son1 = spotilib.song()
    if son1 == son:
        time.sleep(1)
    else:
        print('Tocando agora:', son1, '-', art1)
        del art, son
        art = art1
        son = son1
        get_songname(art, son)
    del g
    g = spotilib.song_info()
Пример #10
0
        }],
        'outtmpl':
        'songs/%(title)s.%(ext)s'
    }

    try:
        with youtube_dl.YoutubeDL(ydl_opts) as ydl:
            ydl.download([url])
    except:
        print "Error downloading song from YouTube, try running the script again or updating youtube_dl."


if os.name == 'nt':
    import spotilib

    if spotilib.song() == "There is nothing playing at this moment":
        print spotilib.song()
    else:
        song_string = spotilib.song() + ' by ' + spotilib.artist()
        downloadSong(song_string)

else:
    import applescript

    scpt = applescript.AppleScript('''
	set currentlyPlayingTrack to getCurrentlyPlayingTrack()
	on getCurrentlyPlayingTrack()
	tell application "Spotify"
	    set currentArtist to artist of current track as string
	    set currentTrack to name of current track as string
	
Пример #11
0
def lyric_handler(artist, song):
    global lyrics
    master.update()

    lyrics = lyric.saved_lyric(artist, song)
    master.update_idletasks()
    if lyrics is not None:
        print('Found! \n')
        save_button.configure(image=saved_icon, state='normal')
        return lyrics

    elif not lyric.internet_on():
        master.update_idletasks()
        print('No internet \n')
        return 'Lyric not found'

    if lyric.internet_on() and (song
                                == spotilib.song()) and (artist
                                                         == spotilib.artist()):
        master.update_idletasks()
        lyrics = lyric.lyricswikia(artist, song)
        master.update_idletasks()
        if lyrics is not None:
            print('Found! \n')
            return lyrics

    if lyric.internet_on() and (song
                                == spotilib.song()) and (artist
                                                         == spotilib.artist()):
        master.update_idletasks()
        lyrics = lyric.vagalume(artist, song)
        master.update_idletasks()
        if lyrics is not None:
            print('Found! \n')
            return lyrics

    if lyric.internet_on() and (song
                                == spotilib.song()) and (artist
                                                         == spotilib.artist()):
        master.update_idletasks()
        lyrics = lyric.letrasmusbr(artist, song)
        if lyrics is not None:
            print('Found! \n')
            return lyrics

    if lyric.internet_on() and (song
                                == spotilib.song()) and (artist
                                                         == spotilib.artist()):
        master.update_idletasks()
        lyrics = lyric.metrolyrics(artist, song)
        master.update_idletasks()
        if lyrics is not None:
            print('Found! \n')
            return lyrics

    if lyric.internet_on() and (song
                                == spotilib.song()) and (artist
                                                         == spotilib.artist()):
        master.update_idletasks()
        lyrics = lyric.lyricsdotcom(artist, song)
        master.update_idletasks()
        if lyrics is not None:
            print('Found! \n')
            return lyrics

    if (song == spotilib.song()) and (artist == spotilib.artist()):
        master.update_idletasks()
        return 'Lyric not found'
        master.update_idletasks()

    if (song != spotilib.song()) or (artist != spotilib.artist()):
        master.update_idletasks()
        print('Song changed \n')
        return 'Next/Previous'
        master.update_idletasks()
Пример #12
0
def get_lyrics(refresh=False, old_song=None, old_artist=None):
    # try:
    global change_check
    global lyrics
    # Gets artist name from spotilib and stores it in the artist var
    artist = spotilib.artist()
    # Gets song name from spotilib and stores it in the song var
    song = spotilib.song()
    if platform.system() == 'Linux':
        # receives the status on linux
        status = spotilib.linux_status()
    else:
        status = None
    # Checks if there is nothing playing
    if (artist == 'There is nothing playing at this moment') or (
            song
            == 'There is nothing playing at this moment') or (status
                                                              == 'Paused'):
        album_art.pack_forget()
        save_button.configure(image=no_save_icon, state='disabled')
        # Then set the lyric to tell the user about it
        lyric_space.setvalue('There is nothing playing at this moment')
        # Creates the tag to centralize the lyrics
        lyric_space.tag_configure('config',
                                  justify='center',
                                  foreground='white',
                                  font=('arial', fontsize(), fontstyle()))
        # centralizes the Lyric Text using a tag
        lyric_space.tag_add("config", 1.0, "end")
        # Changes the song title on the upper part of the window
        song_title.set('There is nothing playing at this moment')
        # Changes the artist title on the upper part of the window
        artist_title.set('')
        # Set the play/pause button to play option
        play_button.configure(image=play_icon)
        master.update_idletasks()
        # Set the old_song and old_artist variable to check for changes
        old_song = song
        old_artist = artist
    # checks if the old_song or old_artist variable are different
    # from the current one
    elif old_song != song or old_artist != artist:
        master.update_idletasks()
        art.image = None
        # Changes the song title on the upper part of the window
        song_title.set(song)
        # Changes the artist title on the upper part of the window
        artist_title.set(artist)
        master.update_idletasks()
        # Set the play/pause button to pause option
        play_button.configure(image=pause_icon)
        # Placeholder while system searchs for lyric
        lyric_space.setvalue('Searching...')
        # Creates the tag to centralize the lyrics
        lyric_space.tag_configure('config',
                                  justify='center',
                                  foreground='white',
                                  font=('arial', fontsize(), fontstyle()))
        lyric_space.tag_add("config", 1.0, "end")
        master.update_idletasks()
        get_album_art()
        master.update_idletasks()
        # then try to get the lyric with that info
        lyrics = lyric_handler(artist, song)
        if lyrics != 'Lyric not found' and lyrics != 'Next/Previous':
            # Changes the lyric text to the current lyric
            lyric_space.setvalue(lyrics)
            # Creates the tag to centralize the lyrics
            lyric_space.tag_configure('config',
                                      justify='center',
                                      foreground='white',
                                      font=('arial', fontsize(), fontstyle()))
            # centralizes the Lyric Text using a tag
            lyric_space.tag_add("config", 1.0, "end")
            # Set the old_song and old_artist variable to check for changes
        elif lyrics == 'Next/Previous':
            pass
        else:
            # warns the user on the lyric text about the failure
            lyric_space.setvalue('Lyric not found!')
            # Creates the tag to centralize the lyrics
            lyric_space.tag_configure('config',
                                      justify='center',
                                      foreground='white',
                                      font=('arial', fontsize(), fontstyle()))
            # centralizes the Lyric Text using a tag
            lyric_space.tag_add("config", 1.0, "end")
        # Set the old_song and old_artist variable to check for changes
        old_song = song
        old_artist = artist
    else:
        # just resets the value of old_song and old_artist
        old_song = song
        old_artist = artist
    if refresh is False:
        # Repeats this function every 1 second(1000ms)
        master.after(1000, get_lyrics, False, old_song, old_artist)
Пример #13
0

def mute():
    volume.SetMasterVolumeLevel(-60, None)


def unmute():
    global master
    volume.SetMasterVolumeLevel(master, None)


lastsong = ""
state = "unmute"
for i in range(0, 1000):
    artist = spotilib.artist()
    song = spotilib.song()

    if lastsong != song:
        print artist, ":", song

    if "There is noting" in artist or "There is noting" in song:
        if state == "unmute":
            print "mute"
        mute()
        state = "mute"
    else:
        if state == "mute":
            print "unmute"
        else:
            master = volume.GetMasterVolumeLevel()
        unmute()