mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-05-11 09:59:51 +08:00
fix 适配新版飞牛影视
This commit is contained in:
@@ -382,3 +382,27 @@ class TrimeMediaModule(_ModuleBase, _MediaServerBase[TrimeMedia]):
|
||||
if not server_obj:
|
||||
return []
|
||||
return server_obj.get_latest_backdrops(num=count, remote=remote) or []
|
||||
|
||||
def mediaserver_image_cookies(
|
||||
self,
|
||||
server: Optional[str] = None,
|
||||
image_url: Optional[str] = None,
|
||||
**kwargs,
|
||||
) -> Optional[str | dict]:
|
||||
"""
|
||||
获取飞牛影视服务器的图片Cookies
|
||||
|
||||
:param server: 媒体服务器名称
|
||||
:param image_url: 图片网址
|
||||
"""
|
||||
if not image_url:
|
||||
return None
|
||||
if server:
|
||||
server_obj = self.get_instance(server)
|
||||
if not server_obj:
|
||||
return None
|
||||
return server_obj.get_image_cookies(image_url)
|
||||
else:
|
||||
for server_obj in self.get_instances().values():
|
||||
if cookies := server_obj.get_image_cookies(image_url):
|
||||
return cookies
|
||||
|
||||
@@ -190,7 +190,7 @@ class Api:
|
||||
"""
|
||||
用户列表(仅管理员有权访问)
|
||||
"""
|
||||
if (res := self.request("/memory/user/list")) and res.success:
|
||||
if (res := self.request("/manager/user/list")) and res.success:
|
||||
if not res.data:
|
||||
return []
|
||||
return [
|
||||
|
||||
@@ -5,6 +5,7 @@ import app.modules.trimemedia.api as fnapi
|
||||
from app import schemas
|
||||
from app.log import logger
|
||||
from app.schemas import MediaType
|
||||
from app.utils.security import SecurityUtils
|
||||
from app.utils.url import UrlUtils
|
||||
|
||||
|
||||
@@ -20,6 +21,7 @@ class TrimeMedia:
|
||||
_sync_libraries: List[str] = []
|
||||
|
||||
_api: Optional[fnapi.Api] = None
|
||||
_version: Optional[fnapi.Version] = None
|
||||
|
||||
def __init__(
|
||||
self,
|
||||
@@ -55,6 +57,13 @@ class TrimeMedia:
|
||||
"""
|
||||
return self._api
|
||||
|
||||
@property
|
||||
def version(self) -> Optional[fnapi.Version]:
|
||||
"""
|
||||
获得飞牛API的版本
|
||||
"""
|
||||
return self._version
|
||||
|
||||
class _ApiCreateResult:
|
||||
api: fnapi.Api
|
||||
version: fnapi.Version
|
||||
@@ -123,7 +132,9 @@ class TrimeMedia:
|
||||
self.disconnect()
|
||||
if result := self.__create_api(self._host):
|
||||
self._api = result.api
|
||||
self._version = result.version
|
||||
# 版本号:0.8.53, 服务版本:0.8.23
|
||||
# 版本号:0.8.56, 服务版本:0.8.23 接口/memory/user/list改为/manager/user/list
|
||||
logger.debug(
|
||||
f"版本号:{result.version.frontend}, 服务版本:{result.version.backend}"
|
||||
)
|
||||
@@ -603,6 +614,7 @@ class TrimeMedia:
|
||||
if (item_details := self._api.item(item.guid)) is None:
|
||||
continue
|
||||
if remote:
|
||||
# FIXME 新版飞牛的壁纸无法直接在浏览器中访问
|
||||
img_host = self._playhost or self._api.host
|
||||
else:
|
||||
img_host = self._api.host
|
||||
@@ -631,3 +643,13 @@ class TrimeMedia:
|
||||
)
|
||||
else False
|
||||
)
|
||||
|
||||
def get_image_cookies(self, image_url: str):
|
||||
"""
|
||||
获得指定图片的Cookies
|
||||
"""
|
||||
if not image_url or not SecurityUtils.is_safe_url(
|
||||
image_url, [self._api.host], strict=True
|
||||
):
|
||||
return None
|
||||
return {"Trim-MC-token": self._api.token}
|
||||
|
||||
Reference in New Issue
Block a user