예제 #1
0
파일: artist.py 프로젝트: nikhilm/muzicast
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 []
예제 #2
0
파일: search.py 프로젝트: nikhilm/muzicast
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
예제 #3
0
파일: artist.py 프로젝트: nikhilm/muzicast
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)
예제 #4
0
파일: artist.py 프로젝트: nikhilm/muzicast
def index(id):
    try:
        artist = Artist.get(id)
        return render_master_page("artist.html", title="Artist", artist=artist)
    except SQLObjectNotFound:
        abort(404)