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