mirror of
https://github.com/home-assistant/core.git
synced 2025-07-21 12:17:07 +00:00
Don't use multi-line conditionals in immich (#146062)
This commit is contained in:
parent
397ed87f2d
commit
eefe1e6f0f
@ -153,49 +153,40 @@ class ImmichMediaSource(MediaSource):
|
|||||||
except ImmichError:
|
except ImmichError:
|
||||||
return []
|
return []
|
||||||
|
|
||||||
ret = [
|
ret: list[BrowseMediaSource] = []
|
||||||
BrowseMediaSource(
|
for asset in album_info.assets:
|
||||||
domain=DOMAIN,
|
if not (mime_type := asset.original_mime_type) or not mime_type.startswith(
|
||||||
identifier=(
|
("image/", "video/")
|
||||||
f"{identifier.unique_id}|albums|"
|
):
|
||||||
f"{identifier.collection_id}|"
|
continue
|
||||||
f"{asset.asset_id}|"
|
|
||||||
f"{asset.original_file_name}|"
|
|
||||||
f"{mime_type}"
|
|
||||||
),
|
|
||||||
media_class=MediaClass.IMAGE,
|
|
||||||
media_content_type=mime_type,
|
|
||||||
title=asset.original_file_name,
|
|
||||||
can_play=False,
|
|
||||||
can_expand=False,
|
|
||||||
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/{mime_type}",
|
|
||||||
)
|
|
||||||
for asset in album_info.assets
|
|
||||||
if (mime_type := asset.original_mime_type)
|
|
||||||
and mime_type.startswith("image/")
|
|
||||||
]
|
|
||||||
|
|
||||||
ret.extend(
|
if mime_type.startswith("image/"):
|
||||||
BrowseMediaSource(
|
media_class = MediaClass.IMAGE
|
||||||
domain=DOMAIN,
|
can_play = False
|
||||||
identifier=(
|
thumb_mime_type = mime_type
|
||||||
f"{identifier.unique_id}|albums|"
|
else:
|
||||||
f"{identifier.collection_id}|"
|
media_class = MediaClass.VIDEO
|
||||||
f"{asset.asset_id}|"
|
can_play = True
|
||||||
f"{asset.original_file_name}|"
|
thumb_mime_type = "image/jpeg"
|
||||||
f"{mime_type}"
|
|
||||||
),
|
ret.append(
|
||||||
media_class=MediaClass.VIDEO,
|
BrowseMediaSource(
|
||||||
media_content_type=mime_type,
|
domain=DOMAIN,
|
||||||
title=asset.original_file_name,
|
identifier=(
|
||||||
can_play=True,
|
f"{identifier.unique_id}|albums|"
|
||||||
can_expand=False,
|
f"{identifier.collection_id}|"
|
||||||
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/image/jpeg",
|
f"{asset.asset_id}|"
|
||||||
|
f"{asset.original_file_name}|"
|
||||||
|
f"{mime_type}"
|
||||||
|
),
|
||||||
|
media_class=media_class,
|
||||||
|
media_content_type=mime_type,
|
||||||
|
title=asset.original_file_name,
|
||||||
|
can_play=can_play,
|
||||||
|
can_expand=False,
|
||||||
|
thumbnail=f"/immich/{identifier.unique_id}/{asset.asset_id}/thumbnail/{thumb_mime_type}",
|
||||||
|
)
|
||||||
)
|
)
|
||||||
for asset in album_info.assets
|
|
||||||
if (mime_type := asset.original_mime_type)
|
|
||||||
and mime_type.startswith("video/")
|
|
||||||
)
|
|
||||||
|
|
||||||
return ret
|
return ret
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user