mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-07-07 07:41:28 +08:00
fix storage api
This commit is contained in:
@@ -108,6 +108,28 @@ class FileManagerModule(_ModuleBase):
|
||||
)
|
||||
return str(path)
|
||||
|
||||
pass
|
||||
|
||||
def generate_qrcode(self, storage: str) -> Optional[Dict[str, str]]:
|
||||
"""
|
||||
生成二维码
|
||||
"""
|
||||
storage_oper = self.__get_storage_oper(storage, "generate_qrcode")
|
||||
if not storage_oper:
|
||||
logger.error(f"不支持 {storage} 的二维码生成")
|
||||
return None
|
||||
return storage_oper.generate_qrcode()
|
||||
|
||||
def check_login(self, storage: str, **kwargs) -> Optional[Dict[str, str]]:
|
||||
"""
|
||||
登录确认
|
||||
"""
|
||||
storage_oper = self.__get_storage_oper(storage, "check_login")
|
||||
if not storage_oper:
|
||||
logger.error(f"不支持 {storage} 的登录确认")
|
||||
return None
|
||||
return storage_oper.check_login(**kwargs)
|
||||
|
||||
def list_files(self, fileitem: FileItem) -> Optional[List[FileItem]]:
|
||||
"""
|
||||
浏览文件
|
||||
@@ -269,12 +291,14 @@ class FileManagerModule(_ModuleBase):
|
||||
need_scrape=need_scrape,
|
||||
need_rename=need_rename)
|
||||
|
||||
def __get_storage_oper(self, _storage: str) -> Optional[StorageBase]:
|
||||
def __get_storage_oper(self, _storage: str, _func: str = None) -> Optional[StorageBase]:
|
||||
"""
|
||||
获取存储操作对象
|
||||
"""
|
||||
for storage_schema in self._storage_schemas:
|
||||
if storage_schema.schema and storage_schema.schema.value == _storage:
|
||||
if storage_schema.schema \
|
||||
and storage_schema.schema.value == _storage \
|
||||
and (not _func or hasattr(storage_schema, _func)):
|
||||
return storage_schema()
|
||||
return None
|
||||
|
||||
|
||||
@@ -16,6 +16,12 @@ class StorageBase(metaclass=ABCMeta):
|
||||
def __init__(self):
|
||||
self.storagehelper = StorageHelper()
|
||||
|
||||
def generate_qrcode(self, *args, **kwargs) -> Optional[Dict[str, str]]:
|
||||
pass
|
||||
|
||||
def check_login(self, *args, **kwargs) -> Optional[Dict[str, str]]:
|
||||
pass
|
||||
|
||||
def get_config(self) -> Optional[schemas.StorageConf]:
|
||||
"""
|
||||
获取配置
|
||||
@@ -46,7 +52,7 @@ class StorageBase(metaclass=ABCMeta):
|
||||
检查存储是否可用
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def list(self, fileitm: schemas.FileItem) -> Optional[List[schemas.FileItem]]:
|
||||
"""
|
||||
@@ -102,7 +108,7 @@ class StorageBase(metaclass=ABCMeta):
|
||||
上传文件
|
||||
"""
|
||||
pass
|
||||
|
||||
|
||||
@abstractmethod
|
||||
def detail(self, fileitm: schemas.FileItem) -> Optional[schemas.FileItem]:
|
||||
"""
|
||||
@@ -168,4 +174,3 @@ class StorageBase(metaclass=ABCMeta):
|
||||
__snapshot_file(fileitem)
|
||||
|
||||
return files_info
|
||||
|
||||
Reference in New Issue
Block a user