コード例 #1
0
ファイル: pcs.py プロジェクト: lubing521/bcloud
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=' + json.dumps(fid_list) + 
            '&schannel=0&channel_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
コード例 #2
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=' + json.dumps(fid_list) +
                              '&schannel=0&channel_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
コード例 #3
0
ファイル: pcs.py プロジェクト: BuddhismZhang/bcloud
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
コード例 #4
0
ファイル: pcs.py プロジェクト: BuddhismZhang/bcloud
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=" + json.dumps(fid_list) + "&schannel=0&channel_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
ファイル: pcs.py プロジェクト: blueyi/bcloud
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
コード例 #6
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