mirror of
https://github.com/jxxghp/MoviePilot.git
synced 2026-02-13 07:25:53 +08:00
避免不必要的图片cookies查询
This commit is contained in:
@@ -147,6 +147,7 @@ async def proxy_img(
|
||||
imgurl: str,
|
||||
proxy: bool = False,
|
||||
cache: bool = False,
|
||||
use_cookies: bool = False,
|
||||
if_none_match: Annotated[str | None, Header()] = None,
|
||||
_: schemas.TokenPayload = Depends(verify_resource_token)
|
||||
) -> Response:
|
||||
@@ -157,7 +158,11 @@ async def proxy_img(
|
||||
hosts = [config.config.get("host") for config in MediaServerHelper().get_configs().values() if
|
||||
config and config.config and config.config.get("host")]
|
||||
allowed_domains = set(settings.SECURITY_IMAGE_DOMAINS) | set(hosts)
|
||||
cookies = MediaServerChain().get_image_cookies(server=None, image_url=imgurl)
|
||||
cookies = (
|
||||
MediaServerChain().get_image_cookies(server=None, image_url=imgurl)
|
||||
if use_cookies
|
||||
else None
|
||||
)
|
||||
return await fetch_image(url=imgurl, proxy=proxy, use_cache=cache, cookies=cookies,
|
||||
if_none_match=if_none_match, allowed_domains=allowed_domains)
|
||||
|
||||
|
||||
@@ -200,6 +200,7 @@ class TrimeMedia:
|
||||
],
|
||||
link=f"{self._playhost or self._api.host}/library/{library.guid}",
|
||||
server_type="trimemedia",
|
||||
use_cookies=True,
|
||||
)
|
||||
)
|
||||
return libraries
|
||||
@@ -498,6 +499,7 @@ class TrimeMedia:
|
||||
else 0
|
||||
),
|
||||
server_type="trimemedia",
|
||||
use_cookies=True,
|
||||
)
|
||||
|
||||
def get_items(
|
||||
|
||||
@@ -74,6 +74,8 @@ class MediaServerLibrary(BaseModel):
|
||||
link: Optional[str] = None
|
||||
# 服务器类型
|
||||
server_type: Optional[str] = None
|
||||
# 飞牛的图片需要Cookies
|
||||
use_cookies: Optional[bool] = None
|
||||
|
||||
|
||||
class MediaServerItemUserState(BaseModel):
|
||||
@@ -177,3 +179,5 @@ class MediaServerPlayItem(BaseModel):
|
||||
percent: Optional[float] = None
|
||||
BackdropImageTags: Optional[list] = Field(default_factory=list)
|
||||
server_type: Optional[str] = None
|
||||
# 飞牛的图片需要Cookies
|
||||
use_cookies: Optional[bool] = None
|
||||
|
||||
Reference in New Issue
Block a user