fix personmeta

This commit is contained in:
jxxghp
2023-10-01 11:52:25 +08:00
parent 2f069afc77
commit fcbfb63645
7 changed files with 251 additions and 69 deletions

View File

@ -1,5 +1,5 @@
from pathlib import Path
from typing import Optional, Tuple, Union, Any, List
from typing import Optional, Tuple, Union, Any, List, Generator
from app import schemas
from app.core.context import MediaInfo
@ -122,7 +122,7 @@ class EmbyModule(_ModuleBase):
media_statistic.user_count = self.emby.get_user_count()
return [media_statistic]
def mediaserver_librarys(self, server: str) -> List[schemas.MediaServerLibrary]:
def mediaserver_librarys(self, server: str) -> Optional[List[schemas.MediaServerLibrary]]:
"""
媒体库列表
"""
@ -130,7 +130,7 @@ class EmbyModule(_ModuleBase):
return None
return self.emby.get_librarys()
def mediaserver_items(self, server: str, library_id: str) -> Optional[List[schemas.MediaServerItem]]:
def mediaserver_items(self, server: str, library_id: str) -> Optional[Generator]:
"""
媒体库项目列表
"""

View File

@ -880,7 +880,7 @@ class Emby(metaclass=Singleton):
logger.error(f"连接Emby出错" + str(e))
return None
def post_data(self, url: str, data: str = None):
def post_data(self, url: str, data: str = None) -> Optional[Response]:
"""
自定义URL从媒体服务器获取数据其中[HOST]、[APIKEY]、[USER]会被替换成实际的值
:param url: 请求地址
@ -892,7 +892,11 @@ class Emby(metaclass=Singleton):
.replace("[APIKEY]", self._apikey) \
.replace("[USER]", self.user)
try:
return RequestUtils(content_type="application/json").post_res(url=url, data=data)
return RequestUtils(
headers={
"Content-Type": "application/json"
}
).post_res(url=url, data=data)
except Exception as e:
logger.error(f"连接Emby出错" + str(e))
return None

View File

@ -1,5 +1,5 @@
from pathlib import Path
from typing import Optional, Tuple, Union, Any, List
from typing import Optional, Tuple, Union, Any, List, Generator
from app import schemas
from app.core.context import MediaInfo
@ -109,7 +109,7 @@ class JellyfinModule(_ModuleBase):
"""
media_statistic = self.jellyfin.get_medias_count()
media_statistic.user_count = self.jellyfin.get_user_count()
return media_statistic
return [media_statistic]
def mediaserver_librarys(self, server: str) -> Optional[List[schemas.MediaServerLibrary]]:
"""
@ -128,7 +128,7 @@ class JellyfinModule(_ModuleBase):
path=library.get("path")
) for library in librarys]
def mediaserver_items(self, server: str, library_id: str) -> Optional[List[schemas.MediaServerItem]]:
def mediaserver_items(self, server: str, library_id: str) -> Optional[Generator]:
"""
媒体库项目列表
"""

View File

@ -561,7 +561,7 @@ class Jellyfin(metaclass=Singleton):
.replace("[APIKEY]", self._apikey) \
.replace("[USER]", self.user)
try:
return RequestUtils().get_res(url=url)
return RequestUtils(accept_type="application/json").get_res(url=url)
except Exception as e:
logger.error(f"连接Jellyfin出错" + str(e))
return None
@ -578,7 +578,11 @@ class Jellyfin(metaclass=Singleton):
.replace("[APIKEY]", self._apikey) \
.replace("[USER]", self.user)
try:
return RequestUtils().post_res(url=url, data=data)
return RequestUtils(
headers={
"Content-Type": "application/json"
}
).post_res(url=url, data=data)
except Exception as e:
logger.error(f"连接Jellyfin出错" + str(e))
return None

View File

@ -1,5 +1,5 @@
from pathlib import Path
from typing import Optional, Tuple, Union, Any, List
from typing import Optional, Tuple, Union, Any, List, Generator
from app import schemas
from app.core.context import MediaInfo
@ -122,7 +122,7 @@ class PlexModule(_ModuleBase):
return None
return self.plex.get_librarys()
def mediaserver_items(self, server: str, library_id: str) -> Optional[List[schemas.MediaServerItem]]:
def mediaserver_items(self, server: str, library_id: str) -> Optional[Generator]:
"""
媒体库项目列表
"""