예제 #1
0
def refresh_signin_vcode(cookie, tokens, vcodetype):
    '''刷新验证码.

    vcodetype - 在调用check_login()时返回的vcodetype.
    '''
    url = ''.join([
        const.PASSPORT_BASE,
        'v2/?reggetcodestr',
        '&token=',
        tokens['token'],
        '&tpl=pp&apiver=v3',
        '&tt=',
        util.timestamp(),
        '&fr=ligin',
        '&vcodetype=',
        encoder.encode_uri(vcodetype),
    ])
    headers = {
        'Cookie': cookie.header_output(),
        'Referer': const.REFERER,
    }
    logger.debug('refresh vcode url: %s' % url)
    req = net.urlopen(url, headers=headers)
    if req:
        try:
            data = req.data.decode('gbk')
            logger.debug('refresh vcode: %s' % data)
            return json.loads(data)
        except ValueError:
            logger.error(traceback.format_exc())
    return None
예제 #2
0
def enable_private_share(cookie, tokens, fid_list, passwd='pf9n'):
    '''建立新的私密分享.

    密码是在本地生成的, 然后上传到服务器.
    '''
    print('enable private share:', fid_list, cookie, tokens)
    url = ''.join([
        const.PAN_URL,
        'share/set?channel=chunlei&clienttype=0&web=1',
        '&bdstoken=',
        tokens['bdstoken'],
        '&channel=chunlei&clienttype=0&web=1',
        '&appid=250528',
    ])
    print('url:', url)
    #passwd = 'dmlg'
    data = encoder.encode_uri(''.join([
        'fid_list=',
        str(fid_list),
        '&schannel=4&channel_list=[]',
        '&pwd=',
        passwd,
    ]))
    print('data:', data)
    req = net.urlopen(url,
                      headers={
                          'Cookie': cookie.header_output(),
                          'Content-type': const.CONTENT_FORM_UTF8,
                      },
                      data=data.encode())
    if req:
        content = req.data
        return json.loads(content.decode()), passwd
    else:
        return None, passwd
예제 #3
0
파일: pcs.py 프로젝트: stepheny/bcloud-core
def enable_private_share(cookie, tokens, fid_list, passwd="pf9n"):
    """建立新的私密分享.

    密码是在本地生成的, 然后上传到服务器.
    """
    print("enable private share:", fid_list, cookie, tokens)
    url = "".join(
        [
            const.PAN_URL,
            "share/set?channel=chunlei&clienttype=0&web=1",
            "&bdstoken=",
            tokens["bdstoken"],
            "&channel=chunlei&clienttype=0&web=1",
            "&appid=250528",
        ]
    )
    print("url:", url)
    # passwd = 'dmlg'
    data = encoder.encode_uri("".join(["fid_list=", str(fid_list), "&schannel=4&channel_list=[]", "&pwd=", passwd]))
    print("data:", data)
    req = net.urlopen(
        url, headers={"Cookie": cookie.header_output(), "Content-type": const.CONTENT_FORM_UTF8}, data=data.encode()
    )
    if req:
        content = req.data
        return json.loads(content.decode()), passwd
    else:
        return None, passwd
예제 #4
0
def enable_share(cookie, tokens, fid_list):
    '''建立新的分享.

    fid_list - 是一个list, 里面的每一条都是一个文件的fs_id
    一次可以分享同一个目录下的多个文件/目录, 它们会会打包为一个分享链接,
    这个分享链接还有一个对应的shareid. 我们可以用uk与shareid来在百度网盘里
    面定位到这个分享内容.
    @return - 会返回分享链接和shareid.
    '''
    url = ''.join([
        const.PAN_URL,
        'share/set?channel=chunlei&clienttype=0&web=1',
        '&bdstoken=',
        tokens['bdstoken'],
    ])
    data = encoder.encode_uri(
        'fid_list={0}&schannel=0&channel_list=[]'.format(fid_list))
    req = net.urlopen(url,
                      headers={
                          'Cookie': cookie.header_output(),
                          'Content-type': const.CONTENT_FORM_UTF8,
                      },
                      data=data.encode())
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
예제 #5
0
def refresh_signin_vcode(cookie, tokens, vcodetype):
    '''刷新验证码.

    vcodetype - 在调用check_login()时返回的vcodetype.
    '''
    url = ''.join([
        const.PASSPORT_BASE,
        'v2/?reggetcodestr',
        '&token=', tokens['token'],
        '&tpl=pp&apiver=v3',
        '&tt=', util.timestamp(),
        '&fr=ligin',
        '&vcodetype=', encoder.encode_uri(vcodetype),
    ])
    headers={
        'Cookie': cookie.header_output(),
        'Referer': const.REFERER,
    }
    logger.debug('refresh vcode url: %s' % url)
    req = net.urlopen(url, headers=headers)
    if req:
        try:
            data = req.data.decode('gbk')
            logger.debug('refresh vcode: %s' % data)
            return json.loads(data)
        except ValueError:
            logger.error(traceback.format_exc())
    return None
예제 #6
0
파일: pcs.py 프로젝트: stepheny/bcloud-core
def disable_share(cookie, tokens, shareid_list):
    """取消分享.

    shareid_list 是一个list, 每一项都是一个shareid
    """
    url = "".join([const.PAN_URL, "share/cancel?channel=chunlei&clienttype=0&web=1", "&bdstoken=", tokens["bdstoken"]])
    data = "shareid_list=" + encoder.encode_uri(json.dumps(shareid_list))
    req = net.urlopen(
        url, headers={"Cookie": cookie.header_output(), "Content-type": const.CONTENT_FORM_UTF8}, data=data.encode()
    )
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
예제 #7
0
파일: pcs.py 프로젝트: stepheny/bcloud-core
def enable_share(cookie, tokens, fid_list):
    """建立新的分享.

    fid_list - 是一个list, 里面的每一条都是一个文件的fs_id
    一次可以分享同一个目录下的多个文件/目录, 它们会会打包为一个分享链接,
    这个分享链接还有一个对应的shareid. 我们可以用uk与shareid来在百度网盘里
    面定位到这个分享内容.
    @return - 会返回分享链接和shareid.
    """
    url = "".join([const.PAN_URL, "share/set?channel=chunlei&clienttype=0&web=1", "&bdstoken=", tokens["bdstoken"]])
    data = encoder.encode_uri("fid_list={0}&schannel=0&channel_list=[]".format(fid_list))
    req = net.urlopen(
        url, headers={"Cookie": cookie.header_output(), "Content-type": const.CONTENT_FORM_UTF8}, data=data.encode()
    )
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
예제 #8
0
def disable_share(cookie, tokens, shareid_list):
    '''取消分享.

    shareid_list 是一个list, 每一项都是一个shareid
    '''
    url = ''.join([
        const.PAN_URL,
        'share/cancel?channel=chunlei&clienttype=0&web=1',
        '&bdstoken=',
        tokens['bdstoken'],
    ])
    data = 'shareid_list=' + encoder.encode_uri(json.dumps(shareid_list))
    req = net.urlopen(url,
                      headers={
                          'Cookie': cookie.header_output(),
                          'Content-type': const.CONTENT_FORM_UTF8,
                      },
                      data=data.encode())
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None