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

Bump spotifyaio to 0.8.10 #131827

Merged
merged 3 commits into from
Nov 28, 2024
Merged
Show file tree
Hide file tree
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
35 changes: 21 additions & 14 deletions homeassistant/components/spotify/browse_media.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,7 @@
SpotifyClient,
Track,
)
from spotifyaio.models import ItemType, SimplifiedEpisode
import yarl

from homeassistant.components.media_player import (
Expand Down Expand Up @@ -90,6 +91,16 @@ def _get_track_item_payload(
}


def _get_episode_item_payload(episode: SimplifiedEpisode) -> ItemPayload:
return {
"id": episode.episode_id,
"name": episode.name,
"type": MediaType.EPISODE,
"uri": episode.uri,
"thumbnail": fetch_image_url(episode.images),
}


class BrowsableMedia(StrEnum):
"""Enum of browsable media."""

Expand Down Expand Up @@ -345,10 +356,15 @@ async def build_item_response( # noqa: C901
if playlist := await spotify.get_playlist(media_content_id):
title = playlist.name
image = playlist.images[0].url if playlist.images else None
items = [
_get_track_item_payload(playlist_track.track)
for playlist_track in playlist.tracks.items
]
for playlist_item in playlist.tracks.items:
if playlist_item.track.type is ItemType.TRACK:
if TYPE_CHECKING:
assert isinstance(playlist_item.track, Track)
items.append(_get_track_item_payload(playlist_item.track))
elif playlist_item.track.type is ItemType.EPISODE:
if TYPE_CHECKING:
assert isinstance(playlist_item.track, SimplifiedEpisode)
items.append(_get_episode_item_payload(playlist_item.track))
elif media_content_type == MediaType.ALBUM:
if album := await spotify.get_album(media_content_id):
title = album.name
Expand All @@ -370,16 +386,7 @@ async def build_item_response( # noqa: C901
):
title = show.name
image = show.images[0].url if show.images else None
items = [
{
"id": episode.episode_id,
"name": episode.name,
"type": MediaType.EPISODE,
"uri": episode.uri,
"thumbnail": fetch_image_url(episode.images),
}
for episode in show_episodes
]
items = [_get_episode_item_payload(episode) for episode in show_episodes]

try:
media_class = CONTENT_TYPE_MEDIA_CLASS[media_content_type]
Expand Down
4 changes: 2 additions & 2 deletions homeassistant/components/spotify/manifest.json
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
"documentation": "https://www.home-assistant.io/integrations/spotify",
"integration_type": "service",
"iot_class": "cloud_polling",
"loggers": ["spotipy"],
"requirements": ["spotifyaio==0.8.8"],
"loggers": ["spotifyaio"],
"requirements": ["spotifyaio==0.8.10"],
"zeroconf": ["_spotify-connect._tcp.local."]
}
2 changes: 2 additions & 0 deletions homeassistant/components/spotify/media_player.py
Original file line number Diff line number Diff line change
Expand Up @@ -361,6 +361,8 @@ async def async_select_source(self, source: str) -> None:
"""Select playback device."""
for device in self.devices.data:
if device.name == source:
if TYPE_CHECKING:
assert device.device_id is not None
await self.coordinator.client.transfer_playback(device.device_id)
return

Expand Down
2 changes: 1 addition & 1 deletion requirements_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2719,7 +2719,7 @@ speak2mary==1.4.0
speedtest-cli==2.1.3

# homeassistant.components.spotify
spotifyaio==0.8.8
spotifyaio==0.8.10

# homeassistant.components.sql
sqlparse==0.5.0
Expand Down
2 changes: 1 addition & 1 deletion requirements_test_all.txt
Original file line number Diff line number Diff line change
Expand Up @@ -2171,7 +2171,7 @@ speak2mary==1.4.0
speedtest-cli==2.1.3

# homeassistant.components.spotify
spotifyaio==0.8.8
spotifyaio==0.8.10

# homeassistant.components.sql
sqlparse==0.5.0
Expand Down
Loading