Skip to content
This repository has been archived by the owner on Dec 17, 2019. It is now read-only.

Fix "Network error" after login #248

Closed
wants to merge 1 commit into from
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions bcloud/auth.py
Original file line number Diff line number Diff line change
Expand Up @@ -289,6 +289,7 @@ def get_bdstoken(cookie):
'''
url = const.PAN_REFERER
req = net.urlopen(url, headers={'Cookie': cookie.header_output()})
cookie.load_list(req.headers.get_all('Set-Cookie')) # SCRC
if req:
return parse_bdstoken(req.data.decode())
else:
Expand Down
6 changes: 3 additions & 3 deletions bcloud/pcs.py
Original file line number Diff line number Diff line change
Expand Up @@ -542,7 +542,7 @@ def list_dir(cookie, tokens, path, page=1, num=100):
])
req = net.urlopen(url, headers={
'Content-type': const.CONTENT_FORM_UTF8,
'Cookie': cookie.sub_output('BAIDUID', 'BDUSS', 'PANWEB', 'cflag'),
'Cookie': cookie.sub_output('BAIDUID', 'BDUSS', 'PANWEB', 'cflag', 'SCRC', 'STOKEN'),
})
if req:
content = req.data
Expand Down Expand Up @@ -717,7 +717,7 @@ def get_download_link(cookie, tokens, path):
dlink = metas['info'][0]['dlink']
url = '{0}&cflg={1}'.format(dlink, cookie.get('cflag').value)
req = net.urlopen_without_redirect(url, headers={
'Cookie': cookie.sub_output('BAIDUID', 'BDUSS', 'cflag'),
'Cookie': cookie.sub_output('BAIDUID', 'BDUSS', 'cflag', 'SCRC', 'STOKEN'),
'Accept': const.ACCEPT_HTML,
})
if not req:
Expand Down Expand Up @@ -907,7 +907,7 @@ def get_metas(cookie, tokens, filelist, dlink=True):
data = ('dlink=0&target=' +
encoder.encode_uri_component(json.dumps(filelist)))
req = net.urlopen(url, headers={
'Cookie': cookie.sub_output('BDUSS'),
'Cookie': cookie.sub_output('BDUSS', 'SCRC', 'STOKEN'),
'Content-type': const.CONTENT_FORM,
}, data=data.encode())
if req:
Expand Down