PeterDing / BaiduPCS-Py

BaiduPCS API & App 百度网盘客户端 和 API
MIT License
678 stars 110 forks source link

建议增加 BaiduPCS-Py su 1这样的直接切换用户命令 #29

Closed ldj46118 closed 3 years ago

ldj46118 commented 3 years ago

建议增加 BaiduPCS-Py su 1这样的直接切换用户命令

WARNNING: Please to search the similar bugs, before you report a bug. Don't report a similar bug which existed. 注意:在你提交一份报告前,请先搜索是否存在类似的报告。请勿重复提交内容相同的报告。

Prerequisites / 报告前提 Before you report a bug, please let the bug to be reproduced at the latest verion of BaiduPCS-Py. 在你提交报告前,请在 BaiduPCS-Py 的最新版本上复现问题。

At sometimes, there are errors occured by an expired cookie. Before you commit the report, please to check whether cookies are expired. 有时一些错误是由于某个 cookie 超期导致的。在你提交报告前,请先检查你的 cookies 是否超期。

Describe the bug / 描述 bug A clear and concise description of what the bug is. 请清楚的描述你遇到的问题。

To Reproduce / 复现问题 Steps to reproduce the behavior:

  1. Do '...'
  2. Do '....'
  3. ...
  4. See error

按照下面的步骤可以复现问题:

  1. 做 '...'
  2. 做 '...'
  3. ...
  4. 问题出现

Screenshots / 问题截图 If applicable, add screenshots to help explain your problem.

Don't show BDUSS and cookies.

如果可能,请附加问题截图。

不要出现 BDUSScookies

Envrionment / 运行环境

Runing log / 运行日志 Please follow steps to paste the content of file ~/.baidupcs-py/running.log.

  1. Remove the file ~/.baidupcs-py/running.log if it exists.
  2. Run the command where the bug occurs with envrionment variable LOG_LEVEL=DEBUG. e.g. LOG_LEVEL=DEBUG BaiduPCS-Py upload /abc /
  3. Paste the content of file ~/.baidupcs-py/running.log after the bug occurs.

Don't show BDUSS and cookies.

请按照下面的步骤贴出运行日志 ~/.baidupcs-py/running.log 中的内容。

  1. 删除 ~/.baidupcs-py/running.log,如果存在。
  2. 在问题发生的命令前加入环境变量 LOG_LEVEL=DEBUG。 例如:LOG_LEVEL=DEBUG BaiduPCS-Py upload /abc /
  3. 在问题出现后,贴出 ~/.baidupcs-py/running.log 中的内容。

不要出现 BDUSScookies

Additional context / 补充内容 Add any other context about the problem here. 在这里增加补充内容。

PeterDing commented 3 years ago

谢谢提议。已经加入 v0.6.13 中。

AlexGuo1998 commented 3 years ago

@PeterDing 这里貌似改炸掉了…… https://github.com/PeterDing/BaiduPCS-Py/blob/e13b941ef9a8b19b225faf74cade61377a844c7a/baidupcs_py/app/app.py#L402-L415 412行的 assert 应该按 int(i) 而不是 user_index,因为交互式 su 的时候 user_index 可能为 None。 或者把直接把这一行移到 if user_index: 的分支去?

PeterDing commented 3 years ago

@AlexGuo1998 确实炸了 😂

已经在 v0.6.14 修复。

PeterDing commented 3 years ago

可以打印下面的 p 看看吗。我的帐号没有这个项目。

https://github.com/PeterDing/BaiduPCS-Py/blob/bead4ea8167d913689e5ae5d60b43cc8f9d86d7c/baidupcs_py/baidupcs/api.py#L404

AlexGuo1998 commented 3 years ago

可以打印下面的 p 看看吗。我的帐号没有这个项目。

https://github.com/PeterDing/BaiduPCS-Py/blob/bead4ea8167d913689e5ae5d60b43cc8f9d86d7c/baidupcs_py/baidupcs/api.py#L404

(话说是 #30 这个 issue 吗) 试了一下 v0.6.14 好像还是不行,在 baidupcs_py/commands/display.py:408 这里就挂掉了,还没跑到 api.py 这里去 如果需要的话我可以提供一下这个账号的 cookie,如何安全的发送给你呢?

AlexGuo1998 commented 3 years ago

我知道了,在 useradd 的时候会调用。是这个:

{
    'product_id': '16421998100313934912',
    'start_time': 1615737599,
    'end_time': 1616342399,
    'buy_time': '1613265962',
    'cluster': None,
    'detail_cluster': None,
    'product_name': None,
    'status': '0',
    'function_num': 0,
    'buy_description': '7天免费试用',
    'product_description': None
}
PeterDing commented 3 years ago

useradd 不会调用 display_user_infos,你应该用的是 userlistsu

你可以用 updateuser 更新发生错误的用户的信息,再使用 userlist, su 应该就不会出错了。

AlexGuo1998 commented 3 years ago

上面不是说看一下 user_productsp 的输出结果吗……user_products 应该是在更新用户信息/添加用户的时候触发的。

现在 su 确实没有问题了,谢谢。