From 999ee393262cc6db3a923e793eb5bf78340a9bb1 Mon Sep 17 00:00:00 2001 From: DDSRem <73049927+DDSRem@users.noreply.github.com> Date: Wed, 1 Jan 2025 19:25:25 +0800 Subject: [PATCH] fix: quark and uc cookies are incomplete --- glue_python/quark_cookie/quark_cookie.py | 12 ++++++++++++ glue_python/uc_cookie/uc_cookie.py | 12 ++++++++++++ 2 files changed, 24 insertions(+) diff --git a/glue_python/quark_cookie/quark_cookie.py b/glue_python/quark_cookie/quark_cookie.py index 14c8279..c1baded 100644 --- a/glue_python/quark_cookie/quark_cookie.py +++ b/glue_python/quark_cookie/quark_cookie.py @@ -51,6 +51,18 @@ def poll_qrcode_status(_token, stop, log_print): _re = requests.get(f'https://pan.quark.cn/account/info?st={service_ticket}&lw=scan', timeout=10) if _re.status_code == 200: quark_cookie = cookiejar_to_string(_re.cookies) + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch", # noqa: E501 + "Referer": "https://pan.quark.cn", + "Cookie": quark_cookie + } + _re = requests.get('https://drive-pc.quark.cn/1/clouddrive/config?pr=ucpro&fr=pc&uc_param_str=', headers=headers, timeout=10) # noqa: E501 + if _re.status_code == 200: + quark_cookie += '; ' + cookiejar_to_string(_re.cookies) + else: + logging.error('获取 __puus 失败!') + LAST_STATUS = 2 + break if sys.platform.startswith('win32'): with open('quark_cookie.txt', 'w', encoding='utf-8') as f: f.write(quark_cookie) diff --git a/glue_python/uc_cookie/uc_cookie.py b/glue_python/uc_cookie/uc_cookie.py index 73097b9..f86b7fb 100644 --- a/glue_python/uc_cookie/uc_cookie.py +++ b/glue_python/uc_cookie/uc_cookie.py @@ -58,6 +58,18 @@ def poll_qrcode_status(stop, _token, log_print): _re = requests.get(f'https://drive.uc.cn/account/info?st={service_ticket}', timeout=10) if _re.status_code == 200: uc_cookie = cookiejar_to_string(_re.cookies) + headers = { + "User-Agent": "Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) quark-cloud-drive/2.5.20 Chrome/100.0.4896.160 Electron/18.3.5.4-b478491100 Safari/537.36 Channel/pckk_other_ch", # noqa: E501 + "Referer": "https://drive.uc.cn", + "Cookie": uc_cookie + } + _re = requests.get('https://pc-api.uc.cn/1/clouddrive/file/sort?pr=UCBrowser&fr=pc&pdir_fid=0&_page=1&_size=50&_fetch_total=1&_fetch_sub_dirs=0&_sort=file_type:asc,updated_at:desc', headers=headers, timeout=10) # noqa: E501 + if _re.status_code == 200: + uc_cookie += '; ' + cookiejar_to_string(_re.cookies) + else: + logging.error('获取 __puus 失败!') + LAST_STATUS = 2 + break if sys.platform.startswith('win32'): with open('uc_cookie.txt', 'w', encoding='utf-8') as f: f.write(uc_cookie)