def top_artists(n): try: top = [t.artist for t in ArtistStatistics.select(orderBy=DESC(ArtistStatistics.q.play_count))[:n]] if len(top) < n: top = top + [artist for artist in Artist.select()[:n-len(top)] if artist not in top] return top except SQLObjectNotFound: return []
def artist_search(keylist): artist=[] for keyword in keylist: #tmp= Track.select(AND(Artist.q.name.contains(keyword),Artist.q.id==Track.q.artist)) tmp= Artist.select(Artist.q.name.contains(keyword)) artist.extend(tmp) artist=set(artist) return artist
def add_artist_to_playlist(id): try: artist = Artist.get(id) for album in artist.albums: for track in album.tracks: playlist.add_to_playlist(track.id) return redirect(request.headers['referer']) except LookupError: abort(400)
def index(id): try: artist = Artist.get(id) return render_master_page("artist.html", title="Artist", artist=artist) except SQLObjectNotFound: abort(404)