Esempio n. 1
0
def play_music_album(artist, album):
    """
    Shuffle the album.
    :param artist: String of artist name
    :param album: String of album name
    :return: Not important
    """
    artist = artist.replace("_", " ")
    album = album.replace("_", " ")

    album_object = library.get_album(artist, album)
    songs = album_object.get_songs()
    random.shuffle(songs)

    # Set playlist
    playlist = []
    for song in songs:
        artist_name = song.get_artist().get_name()
        album_title = song.get_album().get_title()
        song_name = song.get_title()
        playlist.append([artist_name, album_title, song_name])

    variables.put("queue", playlist)

    # Play first song
    song = songs[0]
    server.audio.play(song)
    return "Playing %s by %s : %s" % (song.get_title(),
                                      song.get_artist().get_name(),
                                      song.get_album().get_title())
Esempio n. 2
0
def get_songs_of_album(artist, album):
    artist = artist.replace("_", " ")
    album = album.replace("_", " ")
    album_object = library.get_album(artist, album)
    s = ""
    for song in sorted(album_object.get_songs(), key=lambda a: a.get_order()):
        s += song.get_title() + ":" + str(song.get_duration()) + ";"
    return s[:-1]
Esempio n. 3
0
def get_album_image(artist, album):
    artist = artist.replace("_", " ")
    album = album.replace("_", " ")
    try:
        filename = library.get_album(artist, album).get_image()
    except StandardError:
        # The image is not found
        return abort(404)
    return send_file(filename, mimetype="image/jpg")