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