Пример #1
0
def web_logout():
    alux_id = request.get_cookie("alux_id")
    userInfo = alux.checkUserAuthed(alux_id)
    if not alux_id or not userInfo:
        redirect("/")
    alux.deauthorize(alux_id)
    redirect("/")
Пример #2
0
def listnew():
    alux_id = request.query.alux_id
    if not alux.checkUserAuthed(alux_id):
        response.status = 401
        return
    playlists = alux.getNewPlaylists()
    response.status = 200
    return {'playlists': sorted(playlists)}
Пример #3
0
def getplaylists():
    hidden = False
    alux_id = request.query.alux_id
    if alux.checkUserAuthed(alux_id):
        hidden = True
    playing = alux.getPlaylists(hidden=hidden)
    response.status = 200
    return {'playlists': sorted(playing, key=lambda k: k['title'])}
Пример #4
0
def modify():
    alux_id = request.query.alux_id
    if not alux.checkUserAuthed(alux_id):
        response.status = 401
        return
    this_request = request.json
    alux.modifyPlaylist(this_request['id'], this_request)
    response.status = 201
    return {'id': this_request['id']}
Пример #5
0
def remove():
    alux_id = request.query.alux_id
    if not alux.checkUserAuthed(alux_id):
        response.status = 401
        return
    this_request = request.json
    alux.removePlaylist(this_request['id'])
    response.status = 204
    return
Пример #6
0
def logout():
    alux_id = request.query.alux_id
    if not alux.checkUserAuthed(alux_id):
        response.status = 401
        return
    this_request = request.json
    alux.deauthorize(this_request['alux_id'])
    response.status = 205
    return
Пример #7
0
def add():
    alux_id = request.query.alux_id
    if not alux.checkUserAuthed(alux_id):
        response.status = 401
        return
    this_request = request.json
    alux.addPlaylist(this_request['playlist'], this_request['title'],
                     this_request['artist'], this_request['genre'],
                     this_request['image_url'], this_request['thing_from'],
                     this_request['hidden'], this_request['background'])
    playlist = alux.getPlaylist(playlist=this_request['playlist'])
    response.status = 204
    return {'id': playlist['id']}
Пример #8
0
def index():
    alux_id = request.get_cookie("alux_id")
    alux_expiration = request.get_cookie("alux_expiration")
    userInfo = alux.checkUserAuthed(alux_id)
    if not alux_id or not alux_expiration or not userInfo:
        new_id = getid()
        response.set_cookie("alux_id",
                            new_id['alux_id'],
                            expires=new_id['expiration'])
        response.set_cookie("alux_expiration",
                            str(new_id['expiration']),
                            expires=new_id['expiration'])
        userInfo = {
            'username': None,
            'password': None,
            'alux_id': new_id['alux_id'],
            'expiration': new_id['expiration']
        }
    playcheck = alux.checkPlayPossible()
    return template('default',
                    radioStation=config['radioStation'],
                    userInfo=userInfo,
                    playcheck=playcheck)
Пример #9
0
def play():
    this_request = request.json
    playcheck = alux.checkPlayPossible()
    if playcheck:
        if alux.getPlaylist(ident=this_request['id']):
            alux.stopPlaylist()
            alux.playPlaylist(ident=this_request['id'],
                              repeat=this_request['repeat'])
            playing = alux.checkPlayingStatus()
            t = Timer(
                playing['time_since_start'] + playing['time_remaining'] + 1,
                restart_background)
            t.start()
            response.status = 205
            return
        response.status = 404
        return
    else:
        playstatus = alux.checkPlayingStatus()
        alux_id = request.query.alux_id
        if playstatus['playing'] == False and alux.checkUserAuthed(alux_id):
            if alux.getPlaylist(ident=this_request['id']):
                alux.stopPlaylist()
                alux.playPlaylist(ident=this_request['id'],
                                  repeat=this_request['repeat'])
                playing = alux.checkPlayingStatus()
                t = Timer(
                    playing['time_since_start'] + playing['time_remaining'] +
                    1, restart_background)
                t.start()
                response.status = 205
                return
            response.status = 404
            return
    response.status = 409
    return