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