mirror of
https://github.com/home-assistant/core.git
synced 2025-07-22 20:57:21 +00:00
Kodi: Mark MJPEG cameras using PNGs as incompatible (#67257)
This commit is contained in:
parent
34d38c7ada
commit
442e2eecd5
@ -186,6 +186,15 @@ async def item_payload(item, get_thumbnail_url=None):
|
||||
)
|
||||
|
||||
|
||||
def media_source_content_filter(item: BrowseMedia) -> bool:
|
||||
"""Content filter for media sources."""
|
||||
# Filter out cameras using PNG over MJPEG. They don't work in Kodi.
|
||||
return not (
|
||||
item.media_content_id.startswith("media-source://camera/")
|
||||
and item.media_content_type == "image/png"
|
||||
)
|
||||
|
||||
|
||||
async def library_payload(hass):
|
||||
"""
|
||||
Create response payload to describe contents of a specific library.
|
||||
@ -228,7 +237,9 @@ async def library_payload(hass):
|
||||
child.thumbnail = "https://brands.home-assistant.io/_/kodi/logo.png"
|
||||
|
||||
with contextlib.suppress(media_source.BrowseError):
|
||||
item = await media_source.async_browse_media(hass, None)
|
||||
item = await media_source.async_browse_media(
|
||||
hass, None, content_filter=media_source_content_filter
|
||||
)
|
||||
# If domain is None, it's overview of available sources
|
||||
if item.domain is None:
|
||||
library_info.children.extend(item.children)
|
||||
|
@ -77,7 +77,12 @@ from homeassistant.helpers.network import is_internal_request
|
||||
from homeassistant.helpers.typing import ConfigType, DiscoveryInfoType
|
||||
import homeassistant.util.dt as dt_util
|
||||
|
||||
from .browse_media import build_item_response, get_media_info, library_payload
|
||||
from .browse_media import (
|
||||
build_item_response,
|
||||
get_media_info,
|
||||
library_payload,
|
||||
media_source_content_filter,
|
||||
)
|
||||
from .const import (
|
||||
CONF_WS_PORT,
|
||||
DATA_CONNECTION,
|
||||
@ -916,7 +921,9 @@ class KodiEntity(MediaPlayerEntity):
|
||||
return await library_payload(self.hass)
|
||||
|
||||
if media_source.is_media_source_id(media_content_id):
|
||||
return await media_source.async_browse_media(self.hass, media_content_id)
|
||||
return await media_source.async_browse_media(
|
||||
self.hass, media_content_id, content_filter=media_source_content_filter
|
||||
)
|
||||
|
||||
payload = {
|
||||
"search_type": media_content_type,
|
||||
|
Loading…
x
Reference in New Issue
Block a user