Ejemplo n.º 1
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 = 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
Ejemplo n.º 2
0
def search():
    user_info = get_user_info()
    user_cookie = user_info['cookie']
    user_tokens = user_info['tokens']
    key = cnkeyboard.keyboard(heading=u'输入文件名/关键词')
    if key:
        s = pcs.search(user_cookie, user_tokens, key)
        items = []
        if len(s['list']) == 1:
            for result in s['list']:
                if result['isdir'] == 1:
                    item = {
                            'label': result['server_filename'],
                            'path': plugin.url_for('directory', path=result['path'].encode('utf-8')),
                            'is_playable': False
                            }
                    items.append(item)
                elif result['category'] == 1:
                    if 'thumbs' in result and 'url2' in result['thumbs']:
                        ThumbPath = result['thumbs']['url2']
                        item = {
                                'label': result['server_filename'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                'icon': ThumbPath,
                                }
                    else:
                        item = {
                                'label': result['server_filename'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                }
                    items.append(item)
                elif result['category'] == 2:
                    item = {
                             'label': result['server_filename'],
                             'path': plugin.url_for('play_music', filepath=result['path'].encode('utf-8')),
                             'is_playable': False,
                            }
                    items.append(item)
            if items:
                return plugin.finish(items)
            else:
                dialog.ok('',u'搜素的文件不属于文件夹、视频或音频')

        elif s['list']:
            for result in s['list']:
                if result['isdir'] == 1:
                    item = {
                            'label': result['path'],
                            'path': plugin.url_for('directory', path=result['path'].encode('utf-8')),
                            'is_playable': False
                            }
                    items.insert(0, item)
                elif result['category'] == 1:
                    if 'thumbs' in result and 'url2' in result['thumbs']:
                        ThumbPath = result['thumbs']['url2']
                        item = {
                                'label': result['path'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                'icon': ThumbPath,
                                }
                    else:
                        item = {
                                'label': result['path'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                }
                    items.append(item)
                elif result['category'] == 2:
                    item = {
                             'label': result['path'],
                             'path': plugin.url_for('play_music', filepath=result['path'].encode('utf-8')),
                             'is_playable': False,
                            }
                    items.append(item)
            if items:
                return plugin.finish(items)
            else:
                dialog.ok('',u'搜素的文件不属于文件夹、视频或音频')

        else:
            dialog.ok('',u'没有找到文件')
            return None

    return
Ejemplo n.º 3
0
def search():
    user_info = get_user_info()
    user_cookie = user_info['cookie']
    user_tokens = user_info['tokens']
    key = cnkeyboard.keyboard(heading=u'输入文件名/关键词')
    if key:
        s = pcs.search(user_cookie, user_tokens, key)
        items = []
        if len(s['list']) == 1:
            for result in s['list']:
                if result['isdir'] == 1:
                    item = {
                            'label': result['server_filename'],
                            'path': plugin.url_for('directory', path=result['path'].encode('utf-8')),
                            'is_playable': False
                            }
                    items.append(item)
                elif result['category'] == 1:
                    if 'thumbs' in result and 'url2' in result['thumbs']:
                        ThumbPath = result['thumbs']['url2']
                        item = {
                                'label': result['server_filename'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                'icon': ThumbPath,
                                }
                    else:
                        item = {
                                'label': result['server_filename'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                }
                    items.append(item)
                elif result['category'] == 2:
                    item = {
                             'label': result['server_filename'],
                             'path': plugin.url_for('play_music', filepath=result['path'].encode('utf-8')),
                             'is_playable': False,
                            }
                    items.append(item)
            if items:
                return plugin.finish(items)
            else:
                dialog.ok('',u'搜素的文件不属于文件夹、视频或音频')

        elif s['list']:
            for result in s['list']:
                if result['isdir'] == 1:
                    item = {
                            'label': result['path'],
                            'path': plugin.url_for('directory', path=result['path'].encode('utf-8')),
                            'is_playable': False
                            }
                    items.insert(0, item)
                elif result['category'] == 1:
                    if 'thumbs' in result and 'url2' in result['thumbs']:
                        ThumbPath = result['thumbs']['url2']
                        item = {
                                'label': result['path'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                'icon': ThumbPath,
                                }
                    else:
                        item = {
                                'label': result['path'],
                                'path': plugin.url_for('quality', filepath=result['path'].encode('utf-8')),
                                'is_playable': False,
                                }
                    items.append(item)
                elif result['category'] == 2:
                    item = {
                             'label': result['path'],
                             'path': plugin.url_for('play_music', filepath=result['path'].encode('utf-8')),
                             'is_playable': False,
                            }
                    items.append(item)
            if items:
                return plugin.finish(items)
            else:
                dialog.ok('',u'搜素的文件不属于文件夹、视频或音频')

        else:
            dialog.ok('',u'没有找到文件')
            return None

    return