def enable_private_share(cookie, tokens, fid_list, passwd, period=0): '''建立新的私密分享. 密码是在本地生成的, 然后上传到服务器. ''' url = ''.join([ const.PAN_URL, 'share/set?channel=chunlei&clienttype=0&web=1&app_id=250528', '&bdstoken=', tokens['bdstoken'], ]) data = encoder.encode_uri(''.join([ 'schannel=4&channel_list=[]', '&fid_list=', json.dumps(fid_list), '&period=', str(period), '&pwd=', passwd, ])) 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
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
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
def enable_share(cookie, tokens, fid_list, period=0): '''建立新的分享. fid_list - 是一个list, 里面的每一条都是一个文件的fs_id 一次可以分享同一个目录下的多个文件/目录, 它们会会打包为一个分享链接, 这个分享链接还有一个对应的shareid. 我们可以用uk与shareid来在百度网盘里 面定位到这个分享内容. period - 分享有效期,0表示永远有效,1表示一天,7表示七天. @return - 会返回分享链接和shareid. ''' url = ''.join([ const.PAN_URL, 'share/set?channel=chunlei&clienttype=0&web=1&app_id=250528', '&bdstoken=', tokens['bdstoken'], ]) data = encoder.encode_uri(''.join([ 'schannel=0&channel_list=[]', '&fid_list=', json.dumps(fid_list), '&period=', str(period), ])) 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
def disable_share(cookie, tokens, shareid_list): '''取消分享. shareid_list 是一个list, 每一项都是一个shareid ''' url = ''.join([ const.PAN_URL, 'share/cancel?channel=chunlei&clienttype=', const.PC_CLIENT_TYPE, '&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
def enable_private_share(cookie, tokens, fid_list, passwd='smfx'): '''建立新的私密分享. 密码是在本地生成的, 然后上传到服务器. ''' url = ''.join([ const.PAN_URL, 'share/set?channel=chunlei&clienttype=0&web=1', '&bdstoken=', tokens['bdstoken'], '&channel=chunlei&clienttype=0&web=1', '&appid=250528', ]) data = encoder.encode_uri(''.join([ 'fid_list=', str(fid_list), '&schannel=4&channel_list=[]', '&pwd=', passwd, ])) 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
def enable_private_share(cookie, tokens, fid_list): '''建立新的私密分享. 密码是在本地生成的, 然后上传到服务器. ''' 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
def disable_share(cookie, tokens, shareid_list): print( '/usr/local/lib/python3.4/dist-packages/bcloud/pcs.py:disable_share 216' ) '''取消分享. 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
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
def get_Location(): '''获得网页位置''' if len(location) <= 50: return ','.join([encoder.encode_uri(location), 'undefined']) else: return ','.join([encoder.encode_uri(location[:50]), 'undefined'])