mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-03-31 17:32:30 +08:00
fix:115支持Cookie
This commit is contained in:
@@ -143,7 +143,7 @@ class FileManagerModule(_ModuleBase):
|
||||
return
|
||||
storage_oper.set_config(conf)
|
||||
|
||||
def generate_qrcode(self, storage: str) -> Optional[Dict[str, str]]:
|
||||
def generate_qrcode(self, storage: str) -> Optional[Tuple[dict, str]]:
|
||||
"""
|
||||
生成二维码
|
||||
"""
|
||||
|
||||
@@ -1,6 +1,6 @@
|
||||
from abc import ABCMeta, abstractmethod
|
||||
from pathlib import Path
|
||||
from typing import Optional, List, Union, Dict
|
||||
from typing import Optional, List, Union, Dict, Tuple
|
||||
|
||||
from app import schemas
|
||||
from app.helper.storage import StorageHelper
|
||||
@@ -16,7 +16,7 @@ class StorageBase(metaclass=ABCMeta):
|
||||
def __init__(self):
|
||||
self.storagehelper = StorageHelper()
|
||||
|
||||
def generate_qrcode(self, *args, **kwargs) -> Optional[Dict[str, str]]:
|
||||
def generate_qrcode(self, *args, **kwargs) -> Optional[Tuple[dict, str]]:
|
||||
pass
|
||||
|
||||
def check_login(self, *args, **kwargs) -> Optional[Dict[str, str]]:
|
||||
|
||||
@@ -35,11 +35,10 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
||||
"""
|
||||
try:
|
||||
if not self.client or not self.client.cookies or force:
|
||||
self.client = P115Client(self.__credential,
|
||||
check_for_relogin=True, app="alipaymini", console_qrcode=False)
|
||||
self.client = P115Client(self.__credential, app="alipaymini")
|
||||
self.fs = P115FileSystem(self.client)
|
||||
except Exception as err:
|
||||
logger.error(f"115连接失败,请重新扫码登录:{str(err)}")
|
||||
logger.error(f"115连接失败,请重新登录:{str(err)}")
|
||||
self.__clear_credential()
|
||||
return False
|
||||
return True
|
||||
@@ -54,8 +53,7 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
||||
return None
|
||||
if not conf.config:
|
||||
return None
|
||||
# 将dict转换为cookie字符串格式
|
||||
return "; ".join([f"{k}={v}" for k, v in conf.config.items()])
|
||||
return conf.config.get("cookie")
|
||||
|
||||
def __save_credential(self, credential: dict):
|
||||
"""
|
||||
@@ -73,15 +71,14 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
||||
"""
|
||||
生成二维码
|
||||
"""
|
||||
if not self.__init_cloud():
|
||||
return None
|
||||
self.__init_cloud()
|
||||
try:
|
||||
resp = self.client.login_qrcode_token()
|
||||
self.session_info = resp["data"]
|
||||
qrcode_content = self.session_info.pop("qrcode")
|
||||
if not qrcode_content:
|
||||
logger.warn("115生成二维码失败:未获取到二维码数据!")
|
||||
return None
|
||||
return {}, ""
|
||||
return {
|
||||
"codeContent": qrcode_content
|
||||
}, ""
|
||||
@@ -114,7 +111,10 @@ class U115Pan(StorageBase, metaclass=Singleton):
|
||||
app="alipaymini")
|
||||
if resp:
|
||||
# 保存认证信息
|
||||
self.__save_credential(resp["data"]["cookie"])
|
||||
cookie_dict = resp["data"]["cookie"]
|
||||
cookie_str = "; ".join([f"{k}={v}" for k, v in cookie_dict.items()])
|
||||
cookie_dict.update({"cookie": cookie_str})
|
||||
self.__save_credential(cookie_dict)
|
||||
self.__init_cloud(force=True)
|
||||
result = {
|
||||
"status": 2,
|
||||
|
||||
Reference in New Issue
Block a user