Beispiel #1
0
def save_menu():
    from collections import OrderedDict
    from spotify_item import SpotifyItem
    from util import my_playlists_file, notify_context

    rofi = Rofi(rofi_args=["-no-sort", "-i"])

    track: Track = get_current_track()

    options = OrderedDict()

    options[add_icon_to_str("Save Song", "emblem-favorite")] = track.save
    options[add_icon_to_str(
        "Add song to playlist",
        "list-add")] = lambda: add_to_playlist_menu(my_playlists_file, track)
    options[add_icon_to_str(
        "Play track album", "media-playback-start"
    )] = lambda: SpotifyItem.from_uri(track.uri).album.play()
    options[add_icon_to_str("Query context",
                            "dialog-question")] = lambda: notify_context()
    options[add_icon_to_str("Remove song", "user-trash")] = track.unsave
    index, key = rofi.select("Music",
                             list(options.keys()),
                             message=rofi.escape(str(track)))

    # user escape/quit
    if index == -1:
        return

    # call the lambda at the chosen index
    list(options.values())[index]()
Beispiel #2
0
    playlists = user.get_all_playlists()
    r.close()

    if "default_device" in config["global"]:
        for d in devices:
            if str(d) == config["global"]["default_device"]:
                device = d

    options = []
    for p in playlists:
        options.append(p.name)

    msg = "<b>Currently Playing:</b> "
    curr = user.currently_playing()
    if 'item' in curr:
        msg += Rofi.escape(curr['item'].name + " - " +
                           curr['item'].artist.name)

    playlist_index, playlist_key = r.select('Playlist',
                                            options,
                                            message=msg,
                                            key5=('Alt+Return', "Play/Pause"),
                                            key6=('Alt+Left', "Previous"),
                                            key7=('Alt+Right', "Next"),
                                            rofi_args=['-i'])

    if (playlist_key == 0):  # Enter from playlist selection
        r.status("Loading songs...")
        songs = playlists[playlist_index].get_all_tracks()
        r.close()
        options = ["Shuffle"]
        for s in songs: