fix cython type error

This commit is contained in:
jxxghp
2025-03-23 21:39:37 +08:00
parent 740cf12c11
commit f9b0db623d
113 changed files with 812 additions and 779 deletions
+19 -19
View File
@@ -17,13 +17,13 @@ from schemas import MediaServerItem
class Emby:
_host: str = None
_playhost: str = None
_apikey: str = None
_host: Optional[str] = None
_playhost: Optional[str] = None
_apikey: Optional[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,
def __init__(self, host: Optional[str] = None, apikey: Optional[str] = None, play_host: Optional[str] = None,
sync_libraries: list = None, **kwargs):
if not host or not apikey:
logger.error("Emby服务器配置不完整!")
@@ -116,7 +116,7 @@ class Emby:
logger.error(f"连接Library/VirtualFolders/Query 出错:" + str(e))
return []
def __get_emby_librarys(self, username: str = None) -> List[dict]:
def __get_emby_librarys(self, username: Optional[str] = None) -> List[dict]:
"""
获取Emby媒体库列表
"""
@@ -139,7 +139,7 @@ class Emby:
logger.error(f"连接User/Views 出错:" + str(e))
return []
def get_librarys(self, username: str = None, hidden: bool = False) -> List[schemas.MediaServerLibrary]:
def get_librarys(self, username: Optional[str] = None, hidden: Optional[bool] = False) -> List[schemas.MediaServerLibrary]:
"""
获取媒体服务器所有媒体库列表
"""
@@ -171,7 +171,7 @@ class Emby:
)
return libraries
def get_user(self, user_name: str = None) -> Optional[Union[str, int]]:
def get_user(self, user_name: Optional[str] = None) -> Optional[Union[str, int]]:
"""
获得管理员用户
"""
@@ -342,8 +342,8 @@ class Emby:
def get_movies(self,
title: str,
year: str = None,
tmdb_id: int = None) -> Optional[List[schemas.MediaServerItem]]:
year: Optional[str] = None,
tmdb_id: Optional[int] = None) -> Optional[List[schemas.MediaServerItem]]:
"""
根据标题和年份,检查电影是否在Emby中存在,存在则返回列表
:param title: 标题
@@ -386,11 +386,11 @@ class Emby:
return []
def get_tv_episodes(self,
item_id: str = None,
title: str = None,
year: str = None,
tmdb_id: int = None,
season: int = None
item_id: Optional[str] = None,
title: Optional[str] = None,
year: Optional[str] = None,
tmdb_id: Optional[int] = None,
season: Optional[int] = None
) -> Tuple[Optional[str], Optional[Dict[int, List[int]]]]:
"""
根据标题和年份和季,返回Emby中的剧集列表
@@ -668,7 +668,7 @@ class Emby:
logger.error(f"连接/Users/{self.user}/Items/{itemid}出错:" + str(e))
return None
def get_items(self, parent: Union[str, int], start_index: int = 0,
def get_items(self, parent: Union[str, int], start_index: Optional[int] = 0,
limit: Optional[int] = -1) -> Generator[MediaServerItem | None | Any, Any, None]:
"""
获取媒体服务器项目列表,支持分页和不分页逻辑,默认不分页获取所有数据
@@ -1049,7 +1049,7 @@ class Emby:
logger.error(f"连接Emby出错:" + str(e))
return None
def post_data(self, url: str, data: str = None, headers: dict = None) -> Optional[Response]:
def post_data(self, url: str, data: Optional[str] = None, headers: dict = None) -> Optional[Response]:
"""
自定义URL从媒体服务器获取数据,其中[HOST]、[APIKEY]、[USER]会被替换成实际的值
:param url: 请求地址
@@ -1077,7 +1077,7 @@ class Emby:
return f"{self._playhost or self._host}web/index.html#!" \
f"/item?id={item_id}&context=home&serverId={self.serverid}"
def get_backdrop_url(self, item_id: str, image_tag: str, remote: bool = False) -> str:
def get_backdrop_url(self, item_id: str, image_tag: str, remote: Optional[bool] = False) -> str:
"""
获取Emby的Backdrop图片地址
:param: item_id: 在Emby中的ID
@@ -1106,7 +1106,7 @@ class Emby:
return ""
return "%sItems/%s/Images/Primary" % (self._host, item_id)
def get_resume(self, num: int = 12, username: str = None) -> Optional[List[schemas.MediaServerPlayItem]]:
def get_resume(self, num: Optional[int] = 12, username: Optional[str] = None) -> Optional[List[schemas.MediaServerPlayItem]]:
"""
获得继续观看
"""
@@ -1174,7 +1174,7 @@ class Emby:
logger.error(f"连接Users/Items/Resume出错:" + str(e))
return []
def get_latest(self, num: int = 20, username: str = None) -> Optional[List[schemas.MediaServerPlayItem]]:
def get_latest(self, num: Optional[int] = 20, username: Optional[str] = None) -> Optional[List[schemas.MediaServerPlayItem]]:
"""
获得最近更新
"""