def get_albums_of_artist(artist): artist = artist.replace("_", " ") artist_object = library.get_artist(artist) s = "" for album in artist_object.get_albums(): s += album.get_title() + ";" return s[:-1]
def play_music_artist(artist): """ Shuffle the artist. :param artist: String of artist name :return: Not important """ artist = artist.replace("_", " ") artist_object = library.get_artist(artist) albums = artist_object.get_albums() songs = [] for album in albums: for song in album.get_songs(): songs.append(song) 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]) # TODO: push queue to user 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())
def get_artist_image(artist): artist = artist.replace("_", " ") try: filename = library.get_artist(artist).get_image() except StandardError: # The image is not found return abort(404) return send_file(filename, mimetype="image/jpg")
def get2_albums_of_artist(artist): artist = artist.replace("_", " ") artist_object = library.get_artist(artist) albums = artist_object.get_albums() album_list = [] for album in albums: song_list = [] for song in sorted(album.get_songs(), key=lambda a: a.get_order()): song_list.append({"title": song.get_title(), "order": song.get_order(), "duration": song.get_duration()}) album_list.append({"title": album.get_title(), "songs": song_list}) json = {"albums": album_list} return flask.jsonify(**json)