Use the MIME type as the Google Photos media content type (#195930)

Co-authored-by: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
Paulus Schoutsen
2026-12-02 08:58:35 +01:00
committed by GitHub
co-authored by Claude Opus 5.5
parent 82a96b53d0
commit 3764f36c36
2 changed files with 8 additions and 5 deletions
@@ -276,7 +276,9 @@ def _build_media_item(
domain=DOMAIN,
identifier=identifier.as_string(),
media_class=MediaClass.IMAGE if not is_video else MediaClass.VIDEO,
media_content_type=MediaType.IMAGE if not is_video else MediaType.VIDEO,
# Media pickers filter on MIME types, such as image/*.
media_content_type=media_item.mime_type
or (MediaType.IMAGE if not is_video else MediaType.VIDEO),
title=media_item.filename,
can_play=is_video,
can_expand=False,
@@ -75,8 +75,8 @@ async def test_no_read_scopes(
(
"list_mediaitems.json",
[
(f"{CONFIG_ENTRY_ID}/p/id1", "example1.jpg"),
(f"{CONFIG_ENTRY_ID}/p/id2", "example2.mp4"),
(f"{CONFIG_ENTRY_ID}/p/id1", "example1.jpg", "image/jpeg"),
(f"{CONFIG_ENTRY_ID}/p/id2", "example2.mp4", "video/mp4"),
],
[
("http://img.example.com/id1=h2160", "image/jpeg"),
@@ -89,7 +89,7 @@ async def test_browse_albums(
hass: HomeAssistant,
album_path: str,
expected_album_title: str,
expected_results: list[tuple[str, str]],
expected_results: list[tuple[str, str, str]],
expected_medias: list[tuple[str, str]],
) -> None:
"""Test a media source with no eligible camera devices."""
@@ -114,7 +114,8 @@ async def test_browse_albums(
assert browse.identifier == album_path
assert browse.title == "Account Name"
assert [
(child.identifier, child.title) for child in browse.children
(child.identifier, child.title, child.media_content_type)
for child in browse.children
] == expected_results
media = [