Esempio n. 1
0
@route('/do/<command>/')
def play(command):
    status = request.mpd.status().get( 'state', '')
    if command == 'play':
        request.mpd.pause() if status == 'play' else request.mpd.play()
    elif command == 'next':
        request.mpd.next()
    elif command == 'prev':
        request.mpd.previous()
    elif command == 'stop':
        request.mpd.stop()
    return redirect('/')
    
@route('/static/<filename:path>')
def send_static(filename):
    return static_file(filename, root=os.path.join(BASE_DIR, 'static'))

if __name__ == '__main__':
    Song.initialize()
    c = MPDClient()
    c.connect("localhost", 6600)
    for s in c.listallinfo():
        try:
            song = Song(**s)
        except Exception as e:
            print(e, s)
        else:
            song.save() 
    
    run(host='localhost', port=8080, reloader=True, debug=True)
Esempio n. 2
0
def index(sort_by='album'):
    songs = Song.find()
    current = request.mpd.currentsong()
    import ipdb; ipdb.set_trace()
    ordered = itertools.groupby(songs, key=operator.attrgetter(sort_by))
    return template('index', songs=ordered, current=current)
Esempio n. 3
0
from mpd import MPDClient
from mods import Song

c = MPDClient()
c.connect("localhost", 6600)

for s in c.listallinfo():
    song = Song(**s)
    song.save()