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