fix 全局变量定义

This commit is contained in:
jxxghp
2024-09-09 22:17:49 +08:00
parent f18b9793b4
commit c3ef3dd7d1
14 changed files with 88 additions and 87 deletions

View File

@@ -22,7 +22,7 @@ class EmbyModule(_ModuleBase, _MediaServerBase):
return
for server in mediaservers:
if server.type == "emby" and server.enabled:
self._servers[server.name] = Emby(**server.config)
self._servers[server.name] = Emby(**server.config, sync_libraries=server.sync_libraries)
@staticmethod
def get_name() -> str:

View File

@@ -18,9 +18,11 @@ class Emby:
_host: str = None
_playhost: str = None
_apikey: str = None
_sync_libraries: List[str] = []
user: Optional[Union[str, int]] = None
def __init__(self, host: str = None, apikey: str = None, play_host: str = None, **kwargs):
def __init__(self, host: str = None, apikey: str = None, play_host: str = None,
sync_libraries: list = None, **kwargs):
if not host or not apikey:
logger.error("Emby服务器配置不完整")
return
@@ -34,6 +36,7 @@ class Emby:
self.user = self.get_user(settings.SUPERUSER)
self.folders = self.get_emby_folders()
self.serverid = self.get_server_id()
self._sync_libraries = sync_libraries or []
def is_inactive(self) -> bool:
"""
@@ -132,9 +135,8 @@ class Emby:
if not self._host or not self._apikey:
return []
libraries = []
black_list = (settings.MEDIASERVER_SYNC_BLACKLIST or '').split(",")
for library in self.__get_emby_librarys(username) or []:
if library.get("Name") in black_list:
if self._sync_libraries and library.get("Id") not in self._sync_libraries:
continue
match library.get("CollectionType"):
case "movies":
@@ -1137,9 +1139,8 @@ class Emby:
if not self._host or not self._apikey:
return []
library_folders = []
black_list = (settings.MEDIASERVER_SYNC_BLACKLIST or '').split(",")
for library in self.get_emby_virtual_folders() or []:
if library.get("Name") in black_list:
if self._sync_libraries and library.get("Id") not in self._sync_libraries:
continue
library_folders += [folder for folder in library.get("Path")]
return library_folders