Ejemplo n.º 1
0
def request_song(data):
    if current_user.admin:
        player.play_song_next(data['uri'])
        message('Song has been admin queued.', 'success')
    else:
        if redis.scard('user:'******'Too many open requests.', 'danger')
            return
        if redis.exists('request:' + data['uri']):
            message('Song was already requested!', 'warning')
        else:
            song = provider.lookup(data['uri'])
            artist = ", ".join([a['name'] for a in song['artists']])
            redis.sadd('requests', data['uri'])
            redis.hmset(
                'request:' + data['uri'], {
                    'title': song['name'],
                    'artist': artist,
                    'user': current_user.username,
                })
            redis.sadd('user:'******'uri'])
            message('Requested "{}" by "{}"'.format(song['name'], artist),
                    'success')
Ejemplo n.º 2
0
def connect():
    if current_user.is_authenticated:
        redis.sadd('chatcount', current_user.username)
        emit('chatcount', redis.scard('chatcount'), broadcast=True)