From 5cf4ab2fc19ad22e9fc9b8d3f01b3e00bee6d031 Mon Sep 17 00:00:00 2001 From: Jerry Yan <792602257@qq.com> Date: Mon, 6 Jul 2020 12:03:47 +0800 Subject: [PATCH] =?UTF-8?q?=E6=9B=B4=E6=8D=A2=E7=99=BB=E5=BD=95=E7=B1=BB?= =?UTF-8?q?=E5=9E=8B?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- Common.py | 17 +++++++++++++---- 1 file changed, 13 insertions(+), 4 deletions(-) diff --git a/Common.py b/Common.py index 0be2d45..e825ec1 100644 --- a/Common.py +++ b/Common.py @@ -299,12 +299,21 @@ def appendError(obj): def loginBilibili(force=False): if config["dlO"] is False or forceNotUpload is False: global loginTime + global b if getTimeDelta(datetime.now(), loginTime) < 86400 * 10 and not force: return False - res = b.login(config["b_u"], config["b_p"]) - loginTime = datetime.now() - appendOperation("登陆账号,结果为:[{}]".format(res)) - return res + if os.path.exists('cookie'): + try: + with open('cookie', 'r', encoding='utf8') as f: + _cookie = f.read(4096) + b = Bilibili(_cookie) + loginTime = datetime.now() + appendOperation("Cookie 登录") + return True + except Exception as e: + appendError(e) + appendOperation("Cookie 登录失败") + return False else: appendOperation("设置了不上传,所以不会登陆")