Exemplo n.º 1
0
def add_user():
    userid = (xbmcutils.keyboard(heading='请输入您的百度云帐号')
              or '').strip()
    if not userid:
        return

    config = plugin.get_storage('config')
    users = config.setdefault('users', {})
    if userid in users:
        plugin.notify('用户已存在', delay=2000)
        return

    password = (xbmcutils.keyboard(heading='请输入密码', hidden=True)
                or '').strip()
    if not password:
        return

    api = creaet_api_with_publickey()
    try:
        login_info = api.try_login(userid, password, on_verifycode)
    except Exception as e:
        plugin.log.info(traceback.format_exc())
        if isinstance(e, ClientApiError):
            e = e.get_errmsg()
        xbmcutils.show_msg('登录失败: %s' % e)
        return

    if not login_info:
        return

    _save_user_info(config, userid, password, login_info, api)

    plugin.notify('用户添加成功', delay=3000)
    xbmcutils.refresh()
Exemplo n.º 2
0
def add_user():
    userid = (xbmcutils.keyboard(heading='请输入您的百度云帐号') or '').strip()
    if not userid:
        return

    config = plugin.get_storage('config')
    users = config.setdefault('users', {})
    if userid in users:
        plugin.notify('用户已存在', delay=2000)
        return

    password = (xbmcutils.keyboard(heading='请输入密码', hidden=True) or '').strip()
    if not password:
        return

    api = creaet_api_with_publickey()
    try:
        login_info = api.try_login(userid, password, on_verifycode)
    except Exception as e:
        plugin.log.info(traceback.format_exc())
        if isinstance(e, ClientApiError):
            e = e.get_errmsg()
        xbmcutils.show_msg('登录失败: %s' % e)
        return

    if not login_info:
        return

    _save_user_info(config, userid, password, login_info, api)

    plugin.notify('用户添加成功', delay=3000)
    xbmcutils.refresh()
Exemplo n.º 3
0
def relogin(userid):
    config = plugin.get_storage('config')
    users = config['users']
    old_password = users[userid]

    password = (xbmcutils.keyboard(old_password, '请输入密码', True) or '').strip()
    if not password:
        return

    api = creaet_api_with_publickey()
    try:
        login_info = api.try_login(userid, password, on_verifycode)
    except Exception as e:
        plugin.log.info(traceback.format_exc())
        if isinstance(e, ClientApiError):
            e = e.get_errmsg()
        xbmcutils.show_msg('登录失败: %s' % e)
        return

    if not login_info:
        return

    _save_user_info(config, userid, password, login_info, api)

    plugin.notify('用户登录成功', delay=3000)
    xbmcutils.refresh()
Exemplo n.º 4
0
def relogin(userid):
    config = plugin.get_storage('config')
    users = config['users']
    old_password = users[userid]

    password = (xbmcutils.keyboard(old_password, '请输入密码', True) or '').strip()
    if not password:
        return

    api = creaet_api_with_publickey()
    try:
        login_info = api.try_login(userid, password, on_verifycode)
    except Exception as e:
        plugin.log.info(traceback.format_exc())
        if isinstance(e, ClientApiError):
            e = e.get_errmsg()
        xbmcutils.show_msg('登录失败: %s' % e)
        return

    if not login_info:
        return

    _save_user_info(config, userid, password, login_info, api)

    plugin.notify('用户登录成功', delay=3000)
    xbmcutils.refresh()
Exemplo n.º 5
0
def search():
    query = (xbmcutils.keyboard(heading=u'请输入搜索内容') or '').strip()
    if query:
        m.plugin.redirect(m.url_for('search_result', keyword=query))
Exemplo n.º 6
0
def search():
    query = (xbmcutils.keyboard(heading=u'请输入搜索内容') or '').strip()
    if query:
        m.plugin.redirect(m.url_for(
            'search_result', keyword=query))