mirror of
https://github.com/home-assistant/core.git
synced 2025-04-24 09:17:53 +00:00
Some media source things (#64954)
Co-authored-by: Franck Nijhof <git@frenck.dev>
This commit is contained in:
parent
0a223f2f62
commit
07c239643a
@ -7,10 +7,9 @@ from typing import Any, cast
|
||||
|
||||
from homeassistant.components.media_player import BrowseMedia
|
||||
from homeassistant.components.media_player.const import (
|
||||
MEDIA_CLASS_CHANNEL,
|
||||
MEDIA_CLASS_DIRECTORY,
|
||||
MEDIA_TYPE_CHANNEL,
|
||||
MEDIA_TYPE_CHANNELS,
|
||||
MEDIA_CLASS_APP,
|
||||
MEDIA_TYPE_APP,
|
||||
MEDIA_TYPE_APPS,
|
||||
)
|
||||
from homeassistant.core import HomeAssistant, callback
|
||||
|
||||
@ -58,19 +57,20 @@ class MediaSourceItem:
|
||||
base = BrowseMediaSource(
|
||||
domain=None,
|
||||
identifier=None,
|
||||
media_class=MEDIA_CLASS_DIRECTORY,
|
||||
media_content_type=MEDIA_TYPE_CHANNELS,
|
||||
media_class=MEDIA_CLASS_APP,
|
||||
media_content_type=MEDIA_TYPE_APPS,
|
||||
title="Media Sources",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
children_media_class=MEDIA_CLASS_CHANNEL,
|
||||
children_media_class=MEDIA_CLASS_APP,
|
||||
)
|
||||
base.children = [
|
||||
BrowseMediaSource(
|
||||
domain=source.domain,
|
||||
identifier=None,
|
||||
media_class=MEDIA_CLASS_CHANNEL,
|
||||
media_content_type=MEDIA_TYPE_CHANNEL,
|
||||
media_class=MEDIA_CLASS_APP,
|
||||
media_content_type=MEDIA_TYPE_APP,
|
||||
thumbnail=f"https://brands.home-assistant.io/_/{source.domain}/logo.png",
|
||||
title=source.name,
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
|
@ -263,7 +263,7 @@ async def root_payload(
|
||||
media_class=MEDIA_CLASS_DIRECTORY,
|
||||
media_content_id="",
|
||||
media_content_type="spotify",
|
||||
thumbnail="https://brands.home-assistant.io/spotify/icon.png",
|
||||
thumbnail="https://brands.home-assistant.io/spotify/logo.png",
|
||||
can_play=False,
|
||||
can_expand=True,
|
||||
)
|
||||
|
@ -64,6 +64,7 @@ async def async_browse_media(
|
||||
return await async_browse_media_internal(
|
||||
hass,
|
||||
info[DATA_SPOTIFY_CLIENT],
|
||||
info[DATA_SPOTIFY_SESSION],
|
||||
info[DATA_SPOTIFY_ME],
|
||||
media_content_type,
|
||||
media_content_id,
|
||||
|
@ -524,13 +524,19 @@ class SpotifyMediaPlayer(MediaPlayerEntity):
|
||||
raise NotImplementedError
|
||||
|
||||
return await async_browse_media_internal(
|
||||
self.hass, self._spotify, self._me, media_content_type, media_content_id
|
||||
self.hass,
|
||||
self._spotify,
|
||||
self._session,
|
||||
self._me,
|
||||
media_content_type,
|
||||
media_content_id,
|
||||
)
|
||||
|
||||
|
||||
async def async_browse_media_internal(
|
||||
hass,
|
||||
spotify,
|
||||
session,
|
||||
current_user,
|
||||
media_content_type,
|
||||
media_content_id,
|
||||
@ -543,6 +549,8 @@ async def async_browse_media_internal(
|
||||
partial(library_payload, can_play_artist=can_play_artist)
|
||||
)
|
||||
|
||||
await session.async_ensure_token_valid()
|
||||
|
||||
# Strip prefix
|
||||
media_content_type = media_content_type[len(MEDIA_PLAYER_PREFIX) :]
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user