コード例 #1
0
ファイル: get_auth.py プロジェクト: peiit/kodi_plugins
def run(username, password):
    cookie = auth.get_BAIDUID()
    token = auth.get_token(cookie)
    tokens = {'token': token}
    ubi = auth.get_UBI(cookie, tokens)
    cookie = auth.add_cookie(cookie, ubi, ['UBI', 'PASSID'])
    key_data = auth.get_public_key(cookie, tokens)
    pubkey = key_data['pubkey']
    rsakey = key_data['key']
    password_enc = auth.RSA_encrypt(pubkey, password)
    err_no, query = auth.post_login(cookie, tokens, username, password_enc,
                                    rsakey)
    if err_no == 257:
        vcodetype = query['vcodetype']
        codeString = query['codeString']
        vcode_path = auth.get_signin_vcode(cookie, codeString)

        win = VcodeWindow(cookie, tokens, vcodetype, codeString, vcode_path)
        win.doModal()
        codeString = win.codeString

        verifycode = cnkeyboard.keyboard(heading=u'验证码')
        if verifycode:
            err_no, query = auth.post_login(cookie, tokens, username,
                                            password_enc, rsakey, verifycode,
                                            codeString)
            if err_no == 0:
                temp_cookie = query
                auth_cookie, bdstoken = auth.get_bdstoken(temp_cookie)
                if bdstoken:
                    tokens['bdstoken'] = bdstoken
                    return auth_cookie, tokens

            elif err_no == 4:
                dialog.ok('Error', u'密码错误')

            elif err_no == 6:
                dialog.ok('Error', u'验证码错误')

            else:
                dialog.ok('Error', u'未知错误,请重试')
        else:
            dialog.ok('Error', u'请输入验证码')

    elif err_no == 4:
        dialog.ok('Error', u'密码错误')

    elif err_no == 0:
        auth_cookie = query
        bdstoken = auth.get_bdstoken(auth_cookie)
        if bdstoken:
            tokens['bdstoken'] = bdstoken
            return auth_cookie, tokens

    else:
        dialog.ok('Error', u'未知错误,请重试')

    return None, None
コード例 #2
0
def run(username, password):
    cookie = auth.get_BAIDUID()
    token = auth.get_token(cookie)
    tokens = {'token': token}
    ubi = auth.get_UBI(cookie, tokens)
    cookie = auth.add_cookie(cookie, ubi, ['UBI', 'PASSID'])
    key_data = auth.get_public_key(cookie, tokens)
    pubkey = key_data['pubkey']
    rsakey = key_data['key']
    password_enc = auth.RSA_encrypt(pubkey, password)
    err_no, query = auth.post_login(cookie, tokens, username, password_enc,
                                    rsakey)
    if err_no == 257:
        vcodetype = query['vcodetype']
        codeString = query['codeString']
        vcode_path = auth.get_signin_vcode(cookie, codeString)

        win = VcodeWindow(vcode_path)
        win.doModal()

        verifycode = dialog.input(u'验证码', type=xbmcgui.INPUT_ALPHANUM)
        if len(verifycode) == 4:
            err_no, query = auth.post_login(cookie, tokens, username,
                                            password_enc, rsakey, verifycode,
                                            codeString)
            if err_no == 0:
                auth_cookie = query
                bdstoken = auth.get_bdstoken(auth_cookie)
                if bdstoken:
                    tokens['bdstoken'] = bdstoken
                    return auth_cookie, tokens

            elif err_no == 4:
                dialog.ok('Error', u'密码错误')

            elif err_no == 6:
                dialog.ok('Error', u'验证码错误')

            else:
                dialog.ok('Error', u'未知错误,请重试')
        else:
            dialog.ok('Error', u'验证码为四位数')

    elif err_no == 4:
        dialog.ok('Error', u'密码错误')

    elif err_no == 0:
        auth_cookie = query
        bdstoken = auth.get_bdstoken(auth_cookie)
        if bdstoken:
            tokens['bdstoken'] = bdstoken
            return auth_cookie, tokens

    else:
        dialog.ok('Error', u'未知错误,请重试')

    return None, None
コード例 #3
0
def run(username,password):
    cookie = auth.get_BAIDUID()
    token = auth.get_token(cookie)
    tokens = {'token': token}
    ubi = auth.get_UBI(cookie,tokens)
    cookie = auth.add_cookie(cookie,ubi,['UBI','PASSID'])
    key_data = auth.get_public_key(cookie,tokens)
    pubkey = key_data['pubkey']
    rsakey = key_data['key']
    password_enc = auth.RSA_encrypt(pubkey, password)
    err_no,query = auth.post_login(cookie,tokens,username,password_enc,rsakey)
    if err_no == 257:
        vcodetype = query['vcodetype']
        codeString = query['codeString']
        vcode_path = auth.get_signin_vcode(cookie, codeString)

        win = VcodeWindow(cookie, tokens, vcodetype, codeString, vcode_path)
        win.doModal()
        codeString = win.codeString

        verifycode = dialog.input(u'验证码', type=xbmcgui.INPUT_ALPHANUM)
        if len(verifycode) == 4:
            err_no,query = auth.post_login(cookie,tokens,username,password_enc,rsakey,verifycode,codeString)
            if err_no == 0:
                temp_cookie = query
                auth_cookie, bdstoken = auth.get_bdstoken(temp_cookie)
                if bdstoken:
                    tokens['bdstoken'] = bdstoken
                    return auth_cookie,tokens

            elif err_no == 4:
                dialog.ok('Error',u'密码错误')

            elif err_no == 6:
                dialog.ok('Error',u'验证码错误')

            else:
                dialog.ok('Error',u'未知错误,请重试')
        else:
            dialog.ok('Error',u'验证码为四位数')
    
    elif err_no == 4:
        dialog.ok('Error',u'密码错误')

    elif err_no == 0:
        auth_cookie = query
        bdstoken = auth.get_bdstoken(auth_cookie)
        if bdstoken:
            tokens['bdstoken'] = bdstoken
            return auth_cookie,tokens

    else:
        dialog.ok('Error',u'未知错误,请重试')
    
    return None,None
コード例 #4
0
def run(username, password):
    cookie = auth.get_BAIDUID()
    token = auth.get_token(cookie)
    tokens = {'token': token}
    ubi = auth.get_UBI(cookie, tokens)
    cookie = auth.add_cookie(cookie, ubi, ['UBI', 'PASSID'])
    key_data = auth.get_public_key(cookie, tokens)
    pubkey = key_data['pubkey']
    rsakey = key_data['key']
    password_enc = auth.RSA_encrypt(pubkey, password)
    err_no, query, authCookie = auth.post_login(cookie, tokens, username,
                                                password_enc, rsakey)
    if err_no == 257:
        vcodetype = query['vcodetype']
        codeString = query['codeString']
        vcode_path = auth.get_signin_vcode(cookie, codeString)

        win = VcodeWindow(cookie, tokens, vcodetype, codeString, vcode_path)
        win.doModal()
        codeString = win.codeString

        verifycode = dialog.input(heading=u'验证码')
        if verifycode:
            err_no, query, authCookie = auth.post_login(
                cookie, tokens, username, password_enc, rsakey, verifycode,
                codeString)

            if err_no == 0:
                temp_cookie = authCookie
                auth_cookie, bdstoken = auth.get_bdstoken(temp_cookie)
                if bdstoken:
                    tokens['bdstoken'] = bdstoken
                    return auth_cookie, tokens

            elif err_no == 4:
                dialog.ok('Error', u'密码错误')

            elif err_no == 6:
                dialog.ok('Error', u'验证码错误')

            elif err_no == 120021:
                dialog.ok('Info', u'发送电邮验证')
                #send email verification
                authToken = query['authtoken']
                loginProxyUrl = query['loginproxy']

                sndResp = auth.send_email_verfication(authToken)
                if sndResp.ok:
                    emailVerifyCode = dialog.input(heading=u'电邮验证码')
                    temp_cookie = auth.send_email_verification_code(
                        authToken, emailVerifyCode, loginProxyUrl, cookie)
                    if temp_cookie:

                        auth_cookie, bdstoken = auth.get_bdstoken(temp_cookie)
                        if bdstoken:
                            tokens['bdstoken'] = bdstoken
                            return auth_cookie, tokens

                # failure status
                dialog.ok('Error', u'未知错误,请重试')
            else:
                dialog.ok('Error', u'未知错误,请重试')

        else:
            dialog.ok('Error', u'请输入验证码')

    elif err_no == 4:
        dialog.ok('Error', u'密码错误')

    elif err_no == 0:
        auth_cookie = authCookie
        bdstoken = auth.get_bdstoken(auth_cookie)
        if bdstoken:
            tokens['bdstoken'] = bdstoken
            return auth_cookie, tokens

    else:
        dialog.ok('Error', u'未知错误,请重试')

    return None, None