示例#1
0
文件: pcs.py 项目: blueyi/bcloud
def list_share(cookie, tokens, path='/', page=1, num=100):
    '''获取用户已经共享的文件的信息

    path - 哪个目录的信息, 默认为根目录.
    page - 页数, 默认为第一页.
    num - 一次性获取的共享文件的数量, 默认为100个.
    '''
    url = ''.join([
        const.PAN_URL,
        'share/record?channel=chunlei&clienttype=0&web=1',
        '&num=', str(num),
        '&t=', util.timestamp(),
        '&page=', str(page),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(), 
        '&order=tme&desc=1',
        '&_=', util.timestamp(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={
        'Cookie': cookie.header_output(),
        'Referer': const.SHARE_REFERER,
        })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#2
0
文件: pcs.py 项目: blueyi/bcloud
def list_trash(cookie, tokens, path='/', page=1, num=100):
    '''获取回收站的信息.

    path - 目录的绝对路径, 默认是根目录
    page - 页码, 默认是第一页
    num - 每页有多少个文件, 默认是100个.
    回收站里面的文件会被保存10天, 10天后会自动被清空.
    回收站里面的文件不占用用户的存储空间.
    '''
    url = ''.join([
        const.PAN_API_URL,
        'recycle/list?channel=chunlei&clienttype=0&web=1',
        '&num=', str(num),
        '&t=', util.timestamp(),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(),
        '&order=time&desc=1',
        '&_=', util.timestamp(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#3
0
def list_trash(cookie, tokens, path="/", page=1, num=100):
    """获取回收站的信息.

    path - 目录的绝对路径, 默认是根目录
    page - 页码, 默认是第一页
    num - 每页有多少个文件, 默认是100个.
    回收站里面的文件会被保存10天, 10天后会自动被清空.
    回收站里面的文件不占用用户的存储空间.
    """
    url = "".join(
        [
            const.PAN_API_URL,
            "recycle/list?channel=chunlei&clienttype=0&web=1",
            "&num=",
            str(num),
            "&t=",
            util.timestamp(),
            "&dir=",
            encoder.encode_uri_component(path),
            "&t=",
            util.latency(),
            "&order=time&desc=1",
            "&_=",
            util.timestamp(),
            "&bdstoken=",
            tokens["bdstoken"],
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#4
0
文件: pcs.py 项目: lubing521/bcloud
def list_share_path(cookie, tokens, uk, path, share_id, page):
    '''列举出用户共享的某一个目录中的文件信息

    uk       - user key
    path     - 共享目录
    share_id - 共享文件的ID值
    '''
    url = ''.join([
        const.PAN_URL,
        'share/list?channel=chunlei&clienttype=0&web=1&num=100',
        '&t=', util.timestamp(),
        '&page=', str(page),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(),
        '&shareid=', share_id,
        '&order=time&desc=1',
        '&uk=', uk,
        '&_=', util.timestamp(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={
        'Cookie': cookie.header_output(),
        'Referer': const.SHARE_REFERER,
        })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#5
0
def search(cookie, tokens, key, path="/"):
    """搜索全部文件, 根据文件名.

    key - 搜索的关键词
    path - 如果指定目录名的话, 只搜索本目录及其子目录里的文件名.
    """
    url = "".join(
        [
            const.PAN_API_URL,
            "search?channel=chunlei&clienttype=0&web=1",
            "&dir=",
            path,
            "&key=",
            key,
            "&recursion",
            "&timeStamp=",
            util.latency(),
            "&bdstoken=",
            tokens["bdstoken"],
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#6
0
def search(cookie, tokens, key, path='/'):
    '''搜索全部文件, 根据文件名.

    key - 搜索的关键词
    path - 如果指定目录名的话, 只搜索本目录及其子目录里的文件名.
    '''
    url = ''.join([
        const.PAN_API_URL,
        'search?channel=chunlei&clienttype=0&web=1',
        '&dir=',
        path,
        '&key=',
        key,
        '&recursion',
        '&timeStamp=',
        util.latency(),
        '&bdstoken=',
        tokens['bdstoken'],
    ])
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#7
0
def list_dir(cookie, tokens, path, page=1, num=100):
    '''得到一个目录中的所有文件的信息(最多100条记录).'''
    timestamp = util.timestamp()
    url = ''.join([
        const.PAN_API_URL,
        'list?channel=chunlei&clienttype=0&web=1',
        '&num=',
        str(num),
        '&t=',
        timestamp,
        '&page=',
        str(page),
        '&dir=',
        encoder.encode_uri_component(path),
        '&t=',
        util.latency(),
        '&order=time&desc=1',
        '&_=',
        timestamp,
        '&bdstoken=',
        tokens['bdstoken'],
    ])
    req = net.urlopen(url,
                      headers={
                          'Content-type':
                          const.CONTENT_FORM_UTF8,
                          'Cookie':
                          cookie.sub_output('BAIDUID', 'BDUSS', 'PANWEB',
                                            'cflag'),
                      })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#8
0
def list_trash(cookie, tokens, path='/', page=1, num=100):
    '''获取回收站的信息.

    path - 目录的绝对路径, 默认是根目录
    page - 页码, 默认是第一页
    num - 每页有多少个文件, 默认是100个.
    回收站里面的文件会被保存10天, 10天后会自动被清空.
    回收站里面的文件不占用用户的存储空间.
    '''
    url = ''.join([
        const.PAN_API_URL,
        'recycle/list?channel=chunlei&clienttype=0&web=1',
        '&num=',
        str(num),
        '&t=',
        util.timestamp(),
        '&dir=',
        encoder.encode_uri_component(path),
        '&t=',
        util.latency(),
        '&order=time&desc=1',
        '&_=',
        util.timestamp(),
        '&bdstoken=',
        tokens['bdstoken'],
    ])
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#9
0
def list_share_path(cookie, tokens, uk, path, share_id, page):
    '''列举出用户共享的某一个目录中的文件信息

    uk       - user key
    path     - 共享目录
    share_id - 共享文件的ID值
    '''
    url = ''.join([
        const.PAN_URL,
        'share/list?channel=chunlei&clienttype=0&web=1&num=100',
        '&t=', util.timestamp(),
        '&page=', str(page),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(),
        '&shareid=', share_id,
        '&order=time&desc=1',
        '&uk=', uk,
        '&_=', util.timestamp(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={
        'Cookie': cookie.header_output(),
        'Referer': const.SHARE_REFERER,
        })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#10
0
文件: pcs.py 项目: blueyi/bcloud
def search(cookie, tokens, key, path='/'):
    '''搜索全部文件, 根据文件名.

    key - 搜索的关键词
    path - 如果指定目录名的话, 只搜索本目录及其子目录里的文件名.
    '''
    url = ''.join([
        const.PAN_API_URL,
        'search?channel=chunlei&clienttype=0&web=1',
        '&dir=', path,
        '&key=', key,
        '&recursion',
        '&timeStamp=', util.latency(),
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#11
0
文件: pcs.py 项目: blueyi/bcloud
def list_dir(cookie, tokens, path, page=1, num=100):
    '''得到一个目录中的所有文件的信息.'''
    timestamp = util.timestamp()
    url = ''.join([
        const.PAN_API_URL,
        'list?channel=chunlei&clienttype=0&web=1',
        '&num=', str(num),
        '&t=', timestamp,
        '&page=', str(page),
        '&dir=', encoder.encode_uri_component(path),
        '&t=', util.latency(),
        '&order=time&desc=1',
        '&_=', timestamp,
        '&bdstoken=', tokens['bdstoken'],
        ])
    req = net.urlopen(url, headers={
        'Content-type': const.CONTENT_FORM_UTF8,
        'Cookie': cookie.sub_output('BAIDUID', 'BDUSS', 'PANWEB', 'cflag'),
        })
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#12
0
def list_share_path(cookie, tokens, uk, path, share_id, page):
    """列举出用户共享的某一个目录中的文件信息

    uk       - user key
    path     - 共享目录
    share_id - 共享文件的ID值
    """
    url = "".join(
        [
            const.PAN_URL,
            "share/list?channel=chunlei&clienttype=0&web=1&num=100",
            "&t=",
            util.timestamp(),
            "&page=",
            str(page),
            "&dir=",
            encoder.encode_uri_component(path),
            "&t=",
            util.latency(),
            "&shareid=",
            share_id,
            "&order=time&desc=1",
            "&uk=",
            uk,
            "&_=",
            util.timestamp(),
            "&bdstoken=",
            tokens["bdstoken"],
        ]
    )
    req = net.urlopen(url, headers={"Cookie": cookie.header_output(), "Referer": const.SHARE_REFERER})
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None
示例#13
0
def list_dir(cookie, tokens, path, page=1, num=100):
    """得到一个目录中的所有文件的信息(最多100条记录)."""
    timestamp = util.timestamp()
    url = "".join(
        [
            const.PAN_API_URL,
            "list?channel=chunlei&clienttype=0&web=1",
            "&num=",
            str(num),
            "&t=",
            timestamp,
            "&page=",
            str(page),
            "&dir=",
            encoder.encode_uri_component(path),
            "&t=",
            util.latency(),
            "&order=time&desc=1",
            "&_=",
            timestamp,
            "&bdstoken=",
            tokens["bdstoken"],
        ]
    )
    req = net.urlopen(
        url,
        headers={
            "Content-type": const.CONTENT_FORM_UTF8,
            "Cookie": cookie.sub_output("BAIDUID", "BDUSS", "PANWEB", "cflag"),
        },
    )
    if req:
        content = req.data
        return json.loads(content.decode())
    else:
        return None