Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Filter the NOT supported MIMEs in Assets list. Albums or favorite #15

Open
wants to merge 1 commit into
base: main
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 2 additions & 8 deletions custom_components/immich/hub.py
Original file line number Diff line number Diff line change
Expand Up @@ -99,12 +99,6 @@ async def download_asset(self, asset_id: str) -> bytes | None:
_LOGGER.error("Error from API: status=%d", response.status)
return None

if response.content_type not in _ALLOWED_MIME_TYPES:
_LOGGER.error(
"MIME type is not supported: %s", response.content_type
)
return None

return await response.read()
except aiohttp.ClientError as exception:
_LOGGER.error("Error connecting to the API: %s", exception)
Expand All @@ -128,7 +122,7 @@ async def list_favorite_images(self) -> list[dict]:
assets: list[dict] = favorites["assets"]["items"]

filtered_assets: list[dict] = [
asset for asset in assets if asset["type"] == "IMAGE"
asset for asset in assets if (asset["type"] == "IMAGE") and (asset["originalMimeType"] in _ALLOWED_MIME_TYPES)
]

return filtered_assets
Expand Down Expand Up @@ -173,7 +167,7 @@ async def list_album_images(self, album_id: str) -> list[dict]:
assets: list[dict] = album_info["assets"]

filtered_assets: list[dict] = [
asset for asset in assets if asset["type"] == "IMAGE"
asset for asset in assets if (asset["type"] == "IMAGE") and (asset["originalMimeType"] in _ALLOWED_MIME_TYPES)
]

return filtered_assets
Expand Down