#-*- coding:utf-8 -*-
'''
v0.1.0a
PanBox - parser.py
Author: QCXES, NTG, Yuan_Tuo
'''
import requests
import json
import re
import urllib.parse
import time
import lxml.etree

global DEBUG
DEBUG = True

def post(url: str, data, header, withCookie = False):
    requests.packages.urllib3.disable_warnings()
    ch = requests.post(url, data, headers = header, verify = False)
    if withCookie == True:
        cookie = ''
        for key, value in ch.cookies.items():
            cookie += key + '=' + value + ';'
            return ch.text, cookie
    return ch.text

def rget(url: str, header):
    requests.packages.urllib3.disable_warnings()
    return requests.get(url, headers = header).text

def head(url: str, header):
    ch = requests.post(url, headers = header)
    return json.loads(json.dumps(dict(ch.headers)))

def getSubstr(pstr: str, leftStr: str, rightStr: str):
    left = pstr.find(leftStr)
    right = pstr[left:].find(rightStr)
    return pstr[left + len(leftStr): right + left]

def strstr(pstr: str, fstr: str, before_fstr = False):
    find = pstr.find(fstr)
    if find == -1: return False
    if before_fstr == False: return pstr[find + len(fstr):]
    return pstr[:find]

def byteOrBytes(size):
    if size == 1: return 'Byte'
    return 'Bytes'

def formatSize(size: float, times = 0):
    if size > 1024:
        size = size / 1024
        return formatSize(size, times = times + 1)
    switch = {0: byteOrBytes(size),
            1 : 'KB',
            2 : 'MB',
            3 : 'GB',
            4 : 'TB',
            5 : 'EB',
            6 : 'ZB',
        }
    unit =  switch.get(times, '未知单位')
    fSize = '%.2f' % size
    if int(float(fSize)) == float(fSize):
        return str(int(float(fSize))) + unit
    return fSize + unit

def GetRoot(surl, randsk, BDUSS, STOKEN):
    url = 'https://pan.baidu.com/share/tplconfig?surl=' + surl + '&fields=sign,timestamp&channel=chunlei&web=1&app_id=250528&clienttype=0'
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';'
    }
    result = rget(url, header)
    result = json.loads(result)
    if DEBUG: print(json.dumps(result))
    sign = result['data']['sign']
    timestamp = result['data']['timestamp']
    return sign, timestamp

def getSign(surl: str, randsk, BDUSS, STOKEN):
    if randsk == 1: return 1
    url = 'https://pan.baidu.com/s/1' + surl
    header = {
		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
		'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';'
    }
    result = rget(url, header)
    result = lxml.etree.HTML(result)
    result = result.xpath('/html/body/script[10]')[0].text
    matches = re.search(r'locals.mset\((\{.*?\})\);', str(result))
    matches = matches.group(0)
    if matches != None:
        matches = matches[12:]
        matches = matches[:-2]
        result_decode = json.loads(matches)
        if DEBUG:
            return result_decode
    if DEBUG: print('getSign(): no match\nmatches = None')
    if strstr(result, 'Redirecting to') != False:
        #账号失效
        if DEBUG: print('账号已失效，请重新登录')
    else:
        if DEBUG: print('根目录yunData获取失败或百度已经升级，无法获取并解析yunData')
    return 1

def FileList(sign):
    if sign == 1: return 1
    if sign['file_list'] == None or sign['file_list'] == '': return 1
    return sign['file_list']

def GetDirRemote(dir :str, randsk :str, shareid :str, uk :str, BDUSS, STOKEN):
    url = 'https://pan.baidu.com/share/list?shareid=' + shareid + '&uk=' + uk + '&dir=' + urllib.parse.urlencode(dir)
    header = {
		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';',
        'Referer': 'https://pan.baidu.com/disk/home'
    }
    result = json.loads(rget(url, header))
    if DEBUG: print(result)
    return result

def FileInfo(filename: str, size: float, md5: str, server_ctime: int):
    return ['文件名：' + filename, '文件大小：' + str(size) , '文件MD5：' + md5, '上传时间：' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(server_ctime))]

def getDLink(BDUSS: str, STOKEN: str, fs_id :str, timestamp: str, sign: str, randsk: str, share_id: str, uk: str, bdstoken: str, isnoualink: bool, app_id = 250528):
    if isnoualink: url = 'https://pan.baidu.com/api/sharedownload?app_id=' + app_id + '&channel=chunlei&clienttype=0&sign=' + sign + '&timestamp=' + timestamp + '&web=1&bdstoken=' + bdstoken #获取直链 50MB以内
    url = 'https://pan.baidu.com/api/sharedownload?app_id=' + app_id + '&channel=chunlei&clienttype=12&sign=' + sign + '&timestamp=' + timestamp + '&web=1' #获取下载链接
    #randsk投送时要去除'25'字眼
    data = 'encrypt=0&extra=' + urllib.parse.urlencode('{"sekey":"' + urllib.parse.quote(randsk).replace('25', '') + '"}') + '&fid_list=' + fs_id + '&primaryid=' + share_id + '&uk=' + uk + '&product=share&type=nolimit'
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';',
        'Referer': 'https://pan.baidu.com/disk/home'
    }
    result = json.loads(post(url, data, header))
    if DEBUG: print(result)
    return result
    
	# 没有 referer 就 112 ，然后没有 sekey 参数就 118    -20出现验证码
	#       参数                  类型         描述
	# list                      json array  文件信息列表
	# names                     json        如果查询共享目录，该字段为共享目录文件上传者的uk和账户名称
	# list[0]['category']       int	        文件类型
	# list[0]['dlink']          string      文件下载地址
	# list[0]['file_name']      string      文件名
	# list[0]['isdir']          int	        是否是目录
	# list[0]['server_ctime']   int	        文件的服务器创建时间
	# list[0]['server_mtime']   int         文件的服务修改时间
	# list[0]['size']           int         文件大小
	# list[0]['thumbs']                     缩略图地址
	# list[0]['height']         int         图片高度
	# list[0]['width']          int         图片宽度
	# list[0]['date_taken']     int         图片拍摄时间

def getRandsk(surl, Pwd):
    header = {'User-Agent': 'netdisk'}
    url = 'https://pan.baidu.com/share/wxlist?clienttype=25&shorturl=' + surl + '&pwd=' + Pwd
    result = head(url, header)
    if DEBUG: print(str(result))
    if strstr(str(result), 'BDCLND') == False: Randsk = False
    Randsk = getSubstr(str(result), 'BDCLND=', ';')
    if Randsk != False:
        if DEBUG: print(Randsk)
        return Randsk
    if DEBUG: print('获取Randsk失败')
    print('检测到当前链接异常，保存到网盘重新分享后可获得更好的体验~')
    header = head('https://pan.baidu.com/s/' + surl, '')
    Randsk = re.search(r'BDCLND=(.+?);', header)
    Randsk = Randsk.group(1)
    if Randsk != None:
        if DEBUG: print('老版本方法 getRandsk():' + Randsk)
        return Randsk
    if DEBUG: print(header)
    return ''

def GetList(Shorturl: str, Dir: str, IsRoot: bool, Password: str):
    Url = 'https://pan.baidu.com/share/wxlist?channel=weixin&version=2.2.2&clienttype=25&web=1'
    Root = '0'
    if IsRoot == True: Root = '1'
    Dir = urllib.parse.urlencode(Dir)
    Data = 'shorturl=' + Shorturl + '&dir=' + Dir + '&root=' + Root + '&pwd=' + Password + '&page=1&num=1000&order=time'
    header = {'User-Agent': 'netdisk', 'Referer': 'https://pan.baidu.com/disk/home'}
    result = json.loads(post(Url, Data, header))
    if DEBUG: print(result)
    return result

#Python段不需要
'''
def JSCode(value: str):
    value = value.replace('# *//.*#', '')
    value = value.replace('#/\*.*?\*/#s', '')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    value = value.replace('#([,;{])[ \t]*?\r?\n[ \t]*([^ \t])#', '$1 $2')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    value = value.replace('#([^ \t])[ \t]*?\r?\n[ \t]*?\}#', '$1 }')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    value = value.replace('#([,;{])\t+#', '$1 ')
    value = value.replace('#\t+\}#', ' }')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    return value
'''
def AccountStatus(BDUSS: str, STOKEN: str) -> list: #[errno,会员状态,用户名,登录状态,会员剩余时间]
    Url = 'https://pan.baidu.com/api/gettemplatevariable?channel=chunlei&web=1&app_id=250528&clienttype=0'
    Header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';'
    }
    Data = 'fields=[%22username%22,%22loginstate%22,%22is_vip%22,%22is_svip%22,%22is_evip%22]'
    Result = post(Url, Data, Header)
    Result = json.loads(Result)
    if DEBUG: print(Result)
    if Result['errno'] == 0:
        #正常
        Username = Result['result']['username']
        LoginStatus = Result['result']['loginstate']
        if Result['result']['is_vip']:
            VIPState = 1 #普通会员
        elif Result['result']['is_svip'] or Result['result']['is_evip']:
            VIPState = 2 #超级会员
        else:
            VIPState = 0
            return [0, VIPState, Username, LoginStatus, 0]
        time.sleep(10)
        Url = 'https://pan.baidu.com/rest/2.0/membership/user?channel=chunlei&web=1&app_id=250528&clienttype=0'
        Header = {
           'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
           'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';'
        }
        Data = 'method=query'
        Result = post(Url, Data, Header)
        print('Result = ' + Result)
        Result = json.loads(Result)
        if DEBUG: print('会员状态：\n' + Result)
        if Result['reminder']['svip'] != None:
            return [0, VIPState, Username, LoginStatus, Result['reminder']['svip']['leftseconds']]
    elif Result['errno'] == -6:
        #账号失效
        return [-6]
    return [Result['errno']] #未知错误

#Cookies & Urls for testing
#链接：https://pan.baidu.com/s/1WSBJ_XG0qpePRbt_92uDGg 
#提取码：pwmv
#BDUSS=<KEY>
#STOKEN=<KEY>

#print(getSign('WSBJ_XG0qpePRbt_92uDGg', 'NAiPGPkE8IUsnYzFd6Szpt9OD%2F3iOrtIco3TUZ7dyo0%3D','<KEY>','<KEY>'))
print(AccountStatus('<KEY>','<KEY>'))

#-*- coding:utf-8 -*-
'''
v0.1.0a
PanBox - parser.py
Author: QCXES, NTG, Yuan_Tuo
'''
import requests
import json
import re
import urllib.parse
import time
import lxml.etree

global DEBUG
DEBUG = True

def post(url: str, data, header, withCookie = False):
    requests.packages.urllib3.disable_warnings()
    ch = requests.post(url, data, headers = header, verify = False)
    if withCookie == True:
        cookie = ''
        for key, value in ch.cookies.items():
            cookie += key + '=' + value + ';'
            return ch.text, cookie
    return ch.text

def rget(url: str, header):
    requests.packages.urllib3.disable_warnings()
    return requests.get(url, headers = header).text

def head(url: str, header):
    ch = requests.post(url, headers = header)
    return json.loads(json.dumps(dict(ch.headers)))

def getSubstr(pstr: str, leftStr: str, rightStr: str):
    left = pstr.find(leftStr)
    right = pstr[left:].find(rightStr)
    return pstr[left + len(leftStr): right + left]

def strstr(pstr: str, fstr: str, before_fstr = False):
    find = pstr.find(fstr)
    if find == -1: return False
    if before_fstr == False: return pstr[find + len(fstr):]
    return pstr[:find]

def byteOrBytes(size):
    if size == 1: return 'Byte'
    return 'Bytes'

def formatSize(size: float, times = 0):
    if size > 1024:
        size = size / 1024
        return formatSize(size, times = times + 1)
    switch = {0: byteOrBytes(size),
            1 : 'KB',
            2 : 'MB',
            3 : 'GB',
            4 : 'TB',
            5 : 'EB',
            6 : 'ZB',
        }
    unit =  switch.get(times, '未知单位')
    fSize = '%.2f' % size
    if int(float(fSize)) == float(fSize):
        return str(int(float(fSize))) + unit
    return fSize + unit

def GetRoot(surl, randsk, BDUSS, STOKEN):
    url = 'https://pan.baidu.com/share/tplconfig?surl=' + surl + '&fields=sign,timestamp&channel=chunlei&web=1&app_id=250528&clienttype=0'
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';'
    }
    result = rget(url, header)
    result = json.loads(result)
    if DEBUG: print(json.dumps(result))
    sign = result['data']['sign']
    timestamp = result['data']['timestamp']
    return sign, timestamp

def getSign(surl: str, randsk, BDUSS, STOKEN):
    if randsk == 1: return 1
    url = 'https://pan.baidu.com/s/1' + surl
    header = {
		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
		'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';'
    }
    result = rget(url, header)
    result = lxml.etree.HTML(result)
    result = result.xpath('/html/body/script[10]')[0].text
    matches = re.search(r'locals.mset\((\{.*?\})\);', str(result))
    matches = matches.group(0)
    if matches != None:
        matches = matches[12:]
        matches = matches[:-2]
        result_decode = json.loads(matches)
        if DEBUG:
            return result_decode
    if DEBUG: print('getSign(): no match\nmatches = None')
    if strstr(result, 'Redirecting to') != False:
        #账号失效
        if DEBUG: print('账号已失效，请重新登录')
    else:
        if DEBUG: print('根目录yunData获取失败或百度已经升级，无法获取并解析yunData')
    return 1

def FileList(sign):
    if sign == 1: return 1
    if sign['file_list'] == None or sign['file_list'] == '': return 1
    return sign['file_list']

def GetDirRemote(dir :str, randsk :str, shareid :str, uk :str, BDUSS, STOKEN):
    url = 'https://pan.baidu.com/share/list?shareid=' + shareid + '&uk=' + uk + '&dir=' + urllib.parse.urlencode(dir)
    header = {
		'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';',
        'Referer': 'https://pan.baidu.com/disk/home'
    }
    result = json.loads(rget(url, header))
    if DEBUG: print(result)
    return result

def FileInfo(filename: str, size: float, md5: str, server_ctime: int):
    return ['文件名：' + filename, '文件大小：' + str(size) , '文件MD5：' + md5, '上传时间：' + time.strftime('%Y-%m-%d %H:%M:%S', time.localtime(server_ctime))]

def getDLink(BDUSS: str, STOKEN: str, fs_id :str, timestamp: str, sign: str, randsk: str, share_id: str, uk: str, bdstoken: str, isnoualink: bool, app_id = 250528):
    if isnoualink: url = 'https://pan.baidu.com/api/sharedownload?app_id=' + app_id + '&channel=chunlei&clienttype=0&sign=' + sign + '&timestamp=' + timestamp + '&web=1&bdstoken=' + bdstoken #获取直链 50MB以内
    url = 'https://pan.baidu.com/api/sharedownload?app_id=' + app_id + '&channel=chunlei&clienttype=12&sign=' + sign + '&timestamp=' + timestamp + '&web=1' #获取下载链接
    #randsk投送时要去除'25'字眼
    data = 'encrypt=0&extra=' + urllib.parse.urlencode('{"sekey":"' + urllib.parse.quote(randsk).replace('25', '') + '"}') + '&fid_list=' + fs_id + '&primaryid=' + share_id + '&uk=' + uk + '&product=share&type=nolimit'
    header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';BDCLND=' + randsk + ';',
        'Referer': 'https://pan.baidu.com/disk/home'
    }
    result = json.loads(post(url, data, header))
    if DEBUG: print(result)
    return result
    
	# 没有 referer 就 112 ，然后没有 sekey 参数就 118    -20出现验证码
	#       参数                  类型         描述
	# list                      json array  文件信息列表
	# names                     json        如果查询共享目录，该字段为共享目录文件上传者的uk和账户名称
	# list[0]['category']       int	        文件类型
	# list[0]['dlink']          string      文件下载地址
	# list[0]['file_name']      string      文件名
	# list[0]['isdir']          int	        是否是目录
	# list[0]['server_ctime']   int	        文件的服务器创建时间
	# list[0]['server_mtime']   int         文件的服务修改时间
	# list[0]['size']           int         文件大小
	# list[0]['thumbs']                     缩略图地址
	# list[0]['height']         int         图片高度
	# list[0]['width']          int         图片宽度
	# list[0]['date_taken']     int         图片拍摄时间

def getRandsk(surl, Pwd):
    header = {'User-Agent': 'netdisk'}
    url = 'https://pan.baidu.com/share/wxlist?clienttype=25&shorturl=' + surl + '&pwd=' + Pwd
    result = head(url, header)
    if DEBUG: print(str(result))
    if strstr(str(result), 'BDCLND') == False: Randsk = False
    Randsk = getSubstr(str(result), 'BDCLND=', ';')
    if Randsk != False:
        if DEBUG: print(Randsk)
        return Randsk
    if DEBUG: print('获取Randsk失败')
    print('检测到当前链接异常，保存到网盘重新分享后可获得更好的体验~')
    header = head('https://pan.baidu.com/s/' + surl, '')
    Randsk = re.search(r'BDCLND=(.+?);', header)
    Randsk = Randsk.group(1)
    if Randsk != None:
        if DEBUG: print('老版本方法 getRandsk():' + Randsk)
        return Randsk
    if DEBUG: print(header)
    return ''

def GetList(Shorturl: str, Dir: str, IsRoot: bool, Password: str):
    Url = 'https://pan.baidu.com/share/wxlist?channel=weixin&version=2.2.2&clienttype=25&web=1'
    Root = '0'
    if IsRoot == True: Root = '1'
    Dir = urllib.parse.urlencode(Dir)
    Data = 'shorturl=' + Shorturl + '&dir=' + Dir + '&root=' + Root + '&pwd=' + Password + '&page=1&num=1000&order=time'
    header = {'User-Agent': 'netdisk', 'Referer': 'https://pan.baidu.com/disk/home'}
    result = json.loads(post(Url, Data, header))
    if DEBUG: print(result)
    return result

#Python段不需要
'''
def JSCode(value: str):
    value = value.replace('# *//.*#', '')
    value = value.replace('#/\*.*?\*/#s', '')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    value = value.replace('#([,;{])[ \t]*?\r?\n[ \t]*([^ \t])#', '$1 $2')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    value = value.replace('#([^ \t])[ \t]*?\r?\n[ \t]*?\}#', '$1 }')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    value = value.replace('#([,;{])\t+#', '$1 ')
    value = value.replace('#\t+\}#', ' }')
    value = value.replace('#(\r?\n|\t| ){2,}#', '$1')
    return value
'''
def AccountStatus(BDUSS: str, STOKEN: str) -> list: #[errno,会员状态,用户名,登录状态,会员剩余时间]
    Url = 'https://pan.baidu.com/api/gettemplatevariable?channel=chunlei&web=1&app_id=250528&clienttype=0'
    Header = {
        'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
        'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';'
    }
    Data = 'fields=[%22username%22,%22loginstate%22,%22is_vip%22,%22is_svip%22,%22is_evip%22]'
    Result = post(Url, Data, Header)
    Result = json.loads(Result)
    if DEBUG: print(Result)
    if Result['errno'] == 0:
        #正常
        Username = Result['result']['username']
        LoginStatus = Result['result']['loginstate']
        if Result['result']['is_vip']:
            VIPState = 1 #普通会员
        elif Result['result']['is_svip'] or Result['result']['is_evip']:
            VIPState = 2 #超级会员
        else:
            VIPState = 0
            return [0, VIPState, Username, LoginStatus, 0]
        time.sleep(10)
        Url = 'https://pan.baidu.com/rest/2.0/membership/user?channel=chunlei&web=1&app_id=250528&clienttype=0'
        Header = {
           'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/114.514.1919.810 Safari/537.36',
           'Cookie': 'BDUSS=' + BDUSS + ';STOKEN=' + STOKEN + ';'
        }
        Data = 'method=query'
        Result = post(Url, Data, Header)
        print('Result = ' + Result)
        Result = json.loads(Result)
        if DEBUG: print('会员状态：\n' + Result)
        if Result['reminder']['svip'] != None:
            return [0, VIPState, Username, LoginStatus, Result['reminder']['svip']['leftseconds']]
    elif Result['errno'] == -6:
        #账号失效
        return [-6]
    return [Result['errno']] #未知错误

#Cookies & Urls for testing
#链接：https://pan.baidu.com/s/1WSBJ_XG0qpePRbt_92uDGg 
#提取码：pwmv
#BDUSS=<KEY>
#STOKEN=<KEY>

#print(getSign('WSBJ_XG0qpePRbt_92uDGg', 'NAiPGPkE8IUsnYzFd6Szpt9OD%2F3iOrtIco3TUZ7dyo0%3D','<KEY>','<KEY>'))
print(AccountStatus('<KEY>','<KEY>'))

#-*- coding:utf-8 -*- v0.1.0a PanBox - parser.py Author: QCXES, NTG, Yuan_Tuo #账号失效 #获取直链 50MB以内 #获取下载链接 #randsk投送时要去除'25'字眼 # 没有 referer 就 112 ，然后没有 sekey 参数就 118    -20出现验证码 #       参数                  类型         描述 # list                      json array  文件信息列表 # names                     json        如果查询共享目录，该字段为共享目录文件上传者的uk和账户名称 # list[0]['category']       int	        文件类型 # list[0]['dlink']          string      文件下载地址 # list[0]['file_name']      string      文件名 # list[0]['isdir']          int	        是否是目录 # list[0]['server_ctime']   int	        文件的服务器创建时间 # list[0]['server_mtime']   int         文件的服务修改时间 # list[0]['size']           int         文件大小 # list[0]['thumbs']                     缩略图地址 # list[0]['height']         int         图片高度 # list[0]['width']          int         图片宽度 # list[0]['date_taken']     int         图片拍摄时间 #Python段不需要 def JSCode(value: str):     value = value.replace('# *//.*#', '')     value = value.replace('#/\*.*?\*/#s', '')     value = value.replace('#(\r?\n|\t| ){2,}#', '$1')     value = value.replace('#([,;{])[ \t]*?\r?\n[ \t]*([^ \t])#', '$1 $2')     value = value.replace('#(\r?\n|\t| ){2,}#', '$1')     value = value.replace('#([^ \t])[ \t]*?\r?\n[ \t]*?\}#', '$1 }')     value = value.replace('#(\r?\n|\t| ){2,}#', '$1')     value = value.replace('#([,;{])\t+#', '$1 ')     value = value.replace('#\t+\}#', ' }')     value = value.replace('#(\r?\n|\t| ){2,}#', '$1')     return value #[errno,会员状态,用户名,登录状态,会员剩余时间] #正常 #普通会员 #超级会员 #账号失效 #未知错误 #Cookies & Urls for testing #链接：https://pan.baidu.com/s/1WSBJ_XG0qpePRbt_92uDGg #提取码：pwmv #BDUSS=<KEY> #STOKEN=<KEY> #print(getSign('WSBJ_XG0qpePRbt_92uDGg', 'NAiPGPkE8IUsnYzFd6Szpt9OD%2F3iOrtIco3TUZ7dyo0%3D','<KEY>','<KEY>'))