Пример #1
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()
Пример #2
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()
Пример #3
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()
Пример #4
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()
Пример #5
0
def delete_path(userid, path):
    api = get_api(userid)
    try:
        plugin.notify('正在删除文件,请稍候...', delay=2000)
        api.delete(path)
    except PCSApiError as e:
        xbmcutils.show_msg(str(e), '错误')
    else:
        xbmc.sleep(1000)
        xbmcutils.refresh()
Пример #6
0
def delete_path(userid, path):
    api = get_api(userid)
    try:
        plugin.notify('正在删除文件,请稍候...', delay=2000)
        api.delete(path)
    except PCSApiError as e:
        xbmcutils.show_msg(str(e), '错误')
    else:
        xbmc.sleep(1000)
        xbmcutils.refresh()
Пример #7
0
def index():
    userid = get_default_userid()

    items = [
        {
            'label':
            '[COLOR FFFFFF00]记事本[/COLOR]',
            'path':
            plugin.url_for('mynotes', userid=userid),
            'thumbnail':
            os.path.join(plugin_path, 'resources/skins/Default/720p/note.png')
        },
        {
            #     'label': '[COLOR FFFFFF00]分享动态[/COLOR]',
            #     'path': plugin.url_for('dynamic_list', userid=userid, page=0)
            # }, {
            'label': '[COLOR FFFFFF00]我的关注[/COLOR]',
            'path': plugin.url_for('myfollows', userid=userid, page=0)
        }
    ] if userid else []

    items.extend([{
        'label': '[COLOR FFFFFF00]资源分享[/COLOR]',
        'path': plugin.url_for('hdp_albums')
    }, {
        'label': '[COLOR FFFFFF00]热门资源[/COLOR]',
        'path': plugin.url_for('resources')
    }, {
        'label':
        '[COLOR FFFFFF00]达人推荐[/COLOR]',
        'path':
        plugin.url_for('hot_user_list', userid=str(userid), page=0)
    }, {
        'label': '[COLOR FFFFFF00]设置[/COLOR]',
        'path': plugin.url_for('settings'),
    }])

    if plugin.get_setting('test_features', bool):
        items.append({
            'label': '[COLOR FFFFFF00]打开目录[/COLOR]',
            'path': plugin.url_for('open_dir'),
        })

    try:
        items[0:0] = list_dir(userid)
    except:
        plugin.log.info(traceback.format_exc())
        xbmcutils.show_msg('获取目录列表失败,请检查帐号设置是否正确!', '错误')

    return plugin.finish(items, view_mode='thumbnail')
Пример #8
0
def index():
    userid = get_default_userid()

    items = [{
        'label': '[COLOR FFFFFF00]记事本[/COLOR]',
        'path': plugin.url_for('mynotes', userid=userid),
        'thumbnail': os.path.join(
            plugin_path, 'resources/skins/Default/720p/note.png')
    }, {
        #     'label': '[COLOR FFFFFF00]分享动态[/COLOR]',
        #     'path': plugin.url_for('dynamic_list', userid=userid, page=0)
        # }, {
        'label': '[COLOR FFFFFF00]我的关注[/COLOR]',
        'path': plugin.url_for('myfollows', userid=userid, page=0)
    }] if userid else []

    items.extend([{
        'label': '[COLOR FFFFFF00]资源分享[/COLOR]',
        'path': plugin.url_for('hdp_albums')
    }, {
        'label': '[COLOR FFFFFF00]热门资源[/COLOR]',
        'path': plugin.url_for('resources')
    }, {
        'label': '[COLOR FFFFFF00]达人推荐[/COLOR]',
        'path': plugin.url_for('hot_user_list', userid=str(userid),
                               page=0)
    }, {
        'label': '[COLOR FFFFFF00]设置[/COLOR]',
        'path': plugin.url_for('settings'),
    }])

    if plugin.get_setting('test_features', bool):
        items.append({
            'label': '[COLOR FFFFFF00]打开目录[/COLOR]',
            'path': plugin.url_for('open_dir'),
        })

    try:
        items[0:0] = list_dir(userid)
    except:
        plugin.log.info(traceback.format_exc())
        xbmcutils.show_msg('获取目录列表失败,请检查帐号设置是否正确!', '错误')

    return plugin.finish(items, view_mode='thumbnail')
Пример #9
0
def index():
    userid = get_default_userid()

    items = (
        [
            {
                "label": "[COLOR FFFFFF00]记事本[/COLOR]",
                "path": plugin.url_for("mynotes", userid=userid),
                "thumbnail": os.path.join(plugin_path, "resources/skins/Default/720p/note.png"),
            },
            {
                #     'label': '[COLOR FFFFFF00]分享动态[/COLOR]',
                #     'path': plugin.url_for('dynamic_list', userid=userid, page=0)
                # }, {
                "label": "[COLOR FFFFFF00]我的关注[/COLOR]",
                "path": plugin.url_for("myfollows", userid=userid, page=0),
            },
        ]
        if userid
        else []
    )

    items.extend(
        [
            {"label": "[COLOR FFFFFF00]资源分享[/COLOR]", "path": plugin.url_for("hdp_albums")},
            {"label": "[COLOR FFFFFF00]热门资源[/COLOR]", "path": plugin.url_for("resources")},
            {
                "label": "[COLOR FFFFFF00]达人推荐[/COLOR]",
                "path": plugin.url_for("hot_user_list", userid=str(userid), page=0),
            },
            {"label": "[COLOR FFFFFF00]设置[/COLOR]", "path": plugin.url_for("settings")},
        ]
    )

    if plugin.get_setting("test_features", bool):
        items.append({"label": "[COLOR FFFFFF00]打开目录[/COLOR]", "path": plugin.url_for("open_dir")})

    try:
        items[0:0] = list_dir(userid)
    except:
        plugin.log.info(traceback.format_exc())
        xbmcutils.show_msg("获取目录列表失败,请检查帐号设置是否正确!", "错误")

    return plugin.finish(items, view_mode="thumbnail")