请问如何独立使用MeDownloader来进行下载
nikerck opened this issue · 6 comments
nikerck commented
PeterDing commented
上面代码应该没问题。你遇到什么问题?
nikerck commented
上面代码应该没问题。你遇到什么问题?
python调用完后一闪而过,它并不会进行下载,我找不到原因,返回值为none。
PeterDing commented
你需要等待下载线程完成,在最后加上:
MeDownloader._exit_executor()
nikerck commented
你需要等待下载线程完成,在最后加上:
MeDownloader._exit_executor()
调用以后3秒左右就结束线程,他并没有去下载,也没有发送报错信息
from baidupcs_py.baidupcs import BaiduPCSApi
from baidupcs_py.common.downloader import MeDownloader
cookies = ' '
bduss = ''
remotedir1 = '/mirrai/KEIL5-51.7z' # 75mb
remotedir = '/软考中级 软件设计师/软件设计师笔记.pdf' # 400多kb
api = BaiduPCSApi(bduss,cookies)
url = api.download_link(remotedir)
headers = {
"Cookie": f"BDUSS={bduss};",
"User-Agent": "softxm;netdisk",
"Connection": "Keep-Alive",
}
MeDownloader("GET",url,headers=headers,max_workers=3).download("C:\\Users\\admin\\Desktop\\noneBot2",None)
MeDownloader._exit_executor()
是否因为我的单独调用而却缺失某些关键参数导致?例如task_id
PeterDing commented
cookies
是 Dict
,可以不传。你试试下面的代码。我测试没问题。
from pathlib import Path
from baidupcs_py.baidupcs import BaiduPCSApi
from baidupcs_py.common.downloader import MeDownloader
bduss = ""
remotedir = "/some.file"
api = BaiduPCSApi(bduss)
url = api.download_link(remotedir)
headers = {
"Cookie": f"BDUSS={bduss};",
"User-Agent": "softxm;netdisk",
"Connection": "Keep-Alive",
}
MeDownloader("GET", url, headers=headers, max_workers=3).download(Path("out"), None)
MeDownloader._exit_executor()
nikerck commented
按照你的代码进行修改,已经可以了。非常感谢