baidupcsapi icon indicating copy to clipboard operation
baidupcsapi copied to clipboard

首次登陆时获取的bdstoken错误

Open gaohuazuo opened this issue 8 years ago • 6 comments

在没有cookies的情况下, PCS('username', 'password').user['token'] == 'the fisrt two args should be string type:0,1!'

修改BaseClass._initiate可以解决此问题https://github.com/ly0/baidupcsapi/compare/master...gaohuazuo:patch-1

gaohuazuo avatar Sep 16 '16 15:09 gaohuazuo

这个可以解决 #34 的-6问题么?

ly0 avatar Sep 17 '16 02:09 ly0

可以解决首次登录时的-6问题, 但是cookies过期后有其他问题

Traceback (most recent call last):
  File "/usr/local/lib/python2.7/dist-packages/fuse.py", line 495, in _wrapper
    return func(*args, **kwargs) or 0
  File "/usr/local/lib/python2.7/dist-packages/fuse.py", line 693, in readdir
    fip.contents.fh):
  File "baidufuse.py", line 165, in readdir
    for file in foo['list']:
KeyError: 'list'

gaohuazuo avatar Sep 17 '16 03:09 gaohuazuo

你用的是baidu-fuse么,直接用这个库登录一下看看呢 ?

ly0 avatar Sep 17 '16 07:09 ly0

.username.cookies 没有保存domain, 重新登录之后导致冲突. 具体来说是self.session.cookies['BDUSS'] 会抛异常. https://github.com/gaohuazuo/baidupcsapi/commit/b3b34c27dd8809ab2f3e0526e7e7d39a6bc71573 https://github.com/gaohuazuo/baidupcsapi/commit/ba3a4dcf364bc13a5181c7cf8185ca43cd7afc2b

此外 BaseClass._request 出错后只是重新登录, 没有重试, 不知是算feature还是bug. 这种情况下baidu-fuse没有检查.

gaohuazuo avatar Sep 17 '16 10:09 gaohuazuo

重试确实是没有加的,应该放在上层程序里去判断

能否提交一个PR,我不大知道应该合并哪个分支。。。

ly0 avatar Sep 17 '16 11:09 ly0

没有提PR是因为 https://github.com/gaohuazuo/baidupcsapi/commit/eaac7a3d015548caa377565b37da273cf473f5dc 写得比较丑, 只能算是一个workaround.

gaohuazuo avatar Sep 18 '16 09:09 gaohuazuo