Bump spotifyaio to 0.8.10 (#131827)

pull/132195/head
Joost Lekkerkerker 2024-11-28 13:45:10 +01:00 committed by Franck Nijhof
parent e08b71086f
commit be25b9d4d0
No known key found for this signature in database
GPG Key ID: D62583BA8AB11CA3
8 changed files with 566 additions and 18 deletions

View File

@ -14,6 +14,7 @@ from spotifyaio import (
SpotifyClient,
Track,
)
from spotifyaio.models import ItemType, SimplifiedEpisode
import yarl
from homeassistant.components.media_player import (
@ -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."""
@ -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
@ -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]

View File

@ -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."]
}

View File

@ -361,6 +361,8 @@ class SpotifyMediaPlayer(SpotifyEntity, MediaPlayerEntity):
"""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

View File

@ -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

View File

@ -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

View File

@ -514,6 +514,472 @@
"uri": "spotify:track:2E2znCPaS8anQe21GLxcvJ",
"is_local": false
}
},
{
"added_at": "2024-11-28T11:20:58Z",
"added_by": {
"external_urls": {
"spotify": "https://open.spotify.com/user/1112264649"
},
"href": "https://api.spotify.com/v1/users/1112264649",
"id": "1112264649",
"type": "user",
"uri": "spotify:user:1112264649"
},
"is_local": false,
"primary_color": null,
"track": {
"explicit": false,
"audio_preview_url": "https://podz-content.spotifycdn.com/audio/clips/06lRxUmh8UNVTByuyxLYqh/clip_132296_192296.mp3",
"description": "Patreon: https://www.patreon.com/safetythirdMerch: https://safetythird.shopYouTube: https://www.youtube.com/@safetythird/Advertising Inquiries: https://redcircle.com/brandsPrivacy & Opt-Out: https://redcircle.com/privacy",
"duration_ms": 3690161,
"episode": true,
"external_urls": {
"spotify": "https://open.spotify.com/episode/3o0RYoo5iOMKSmEbunsbvW"
},
"href": "https://api.spotify.com/v1/episodes/3o0RYoo5iOMKSmEbunsbvW",
"html_description": "<p>Patreon: https://www.patreon.com/safetythird</p><p>Merch: https://safetythird.shop</p><p>YouTube: https://www.youtube.com/&#64;safetythird/</p><br /><br />Advertising Inquiries: <a href=\"https://redcircle.com/brands\" rel=\"nofollow\">https://redcircle.com/brands</a><br /><br />Privacy &amp; Opt-Out: <a href=\"https://redcircle.com/privacy\" rel=\"nofollow\">https://redcircle.com/privacy</a>",
"id": "3o0RYoo5iOMKSmEbunsbvW",
"images": [
{
"height": 640,
"url": "https://i.scdn.co/image/ab6765630000ba8ac7bedd27a4413b1abf926d8a",
"width": 640
},
{
"height": 300,
"url": "https://i.scdn.co/image/ab67656300005f1fc7bedd27a4413b1abf926d8a",
"width": 300
},
{
"height": 64,
"url": "https://i.scdn.co/image/ab6765630000f68dc7bedd27a4413b1abf926d8a",
"width": 64
}
],
"is_externally_hosted": false,
"language": "en-US",
"languages": ["en-US"],
"name": "My Squirrel Has Brain Damage - Safety Third 119",
"release_date": "2024-07-26",
"release_date_precision": "day",
"available_markets": [
"AR",
"AU",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HK",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MY",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SG",
"SK",
"ES",
"SE",
"CH",
"TW",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"JP",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"ME",
"MK",
"RS",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"FJ",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"KI",
"LS",
"LR",
"MW",
"MV",
"ML",
"MH",
"FM",
"NA",
"NR",
"NE",
"PW",
"PG",
"PR",
"WS",
"SM",
"ST",
"SN",
"SC",
"SL",
"SB",
"KN",
"LC",
"VC",
"SR",
"TL",
"TO",
"TT",
"TV",
"VU",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
"XK"
],
"show": {
"available_markets": [
"AR",
"AU",
"AT",
"BE",
"BO",
"BR",
"BG",
"CA",
"CL",
"CO",
"CR",
"CY",
"CZ",
"DK",
"DO",
"DE",
"EC",
"EE",
"SV",
"FI",
"FR",
"GR",
"GT",
"HN",
"HK",
"HU",
"IS",
"IE",
"IT",
"LV",
"LT",
"LU",
"MY",
"MT",
"MX",
"NL",
"NZ",
"NI",
"NO",
"PA",
"PY",
"PE",
"PH",
"PL",
"PT",
"SG",
"SK",
"ES",
"SE",
"CH",
"TW",
"TR",
"UY",
"US",
"GB",
"AD",
"LI",
"MC",
"ID",
"JP",
"TH",
"VN",
"RO",
"IL",
"ZA",
"SA",
"AE",
"BH",
"QA",
"OM",
"KW",
"EG",
"MA",
"DZ",
"TN",
"LB",
"JO",
"PS",
"IN",
"BY",
"KZ",
"MD",
"UA",
"AL",
"BA",
"HR",
"ME",
"MK",
"RS",
"SI",
"KR",
"BD",
"PK",
"LK",
"GH",
"KE",
"NG",
"TZ",
"UG",
"AG",
"AM",
"BS",
"BB",
"BZ",
"BT",
"BW",
"BF",
"CV",
"CW",
"DM",
"FJ",
"GM",
"GE",
"GD",
"GW",
"GY",
"HT",
"JM",
"KI",
"LS",
"LR",
"MW",
"MV",
"ML",
"MH",
"FM",
"NA",
"NR",
"NE",
"PW",
"PG",
"PR",
"WS",
"SM",
"ST",
"SN",
"SC",
"SL",
"SB",
"KN",
"LC",
"VC",
"SR",
"TL",
"TO",
"TT",
"TV",
"VU",
"AZ",
"BN",
"BI",
"KH",
"CM",
"TD",
"KM",
"GQ",
"SZ",
"GA",
"GN",
"KG",
"LA",
"MO",
"MR",
"MN",
"NP",
"RW",
"TG",
"UZ",
"ZW",
"BJ",
"MG",
"MU",
"MZ",
"AO",
"CI",
"DJ",
"ZM",
"CD",
"CG",
"IQ",
"LY",
"TJ",
"VE",
"ET",
"XK"
],
"copyrights": [],
"description": "Safety Third is a weekly show hosted by William Osman, NileRed, The Backyard Scientist, Allen Pan, and a couple other YouTube \"Scientists\". Sometimes we have guests, sometimes it's just us, but always: safety is our number three priority.",
"explicit": true,
"external_urls": {
"spotify": "https://open.spotify.com/show/1Y9ExMgMxoBVrgrfU7u0nD"
},
"href": "https://api.spotify.com/v1/shows/1Y9ExMgMxoBVrgrfU7u0nD",
"html_description": "<p>Safety Third is a weekly show hosted by William Osman, NileRed, The Backyard Scientist, Allen Pan, and a couple other YouTube &#34;Scientists&#34;. Sometimes we have guests, sometimes it&#39;s just us, but always: safety is our number three priority.</p>",
"id": "1Y9ExMgMxoBVrgrfU7u0nD",
"images": [
{
"height": 640,
"url": "https://i.scdn.co/image/ab6765630000ba8ac7bedd27a4413b1abf926d8a",
"width": 640
},
{
"height": 300,
"url": "https://i.scdn.co/image/ab67656300005f1fc7bedd27a4413b1abf926d8a",
"width": 300
},
{
"height": 64,
"url": "https://i.scdn.co/image/ab6765630000f68dc7bedd27a4413b1abf926d8a",
"width": 64
}
],
"is_externally_hosted": false,
"languages": ["en-US"],
"media_type": "audio",
"name": "Safety Third",
"publisher": "Safety Third ",
"total_episodes": 120,
"type": "show",
"uri": "spotify:show:1Y9ExMgMxoBVrgrfU7u0nD"
},
"track": false,
"type": "episode",
"uri": "spotify:episode:3o0RYoo5iOMKSmEbunsbvW"
},
"video_thumbnail": {
"url": null
}
}
]
}

View File

@ -409,6 +409,69 @@
'uri': 'spotify:track:2E2znCPaS8anQe21GLxcvJ',
}),
}),
dict({
'track': dict({
'description': 'Patreon: https://www.patreon.com/safetythirdMerch: https://safetythird.shopYouTube: https://www.youtube.com/@safetythird/Advertising Inquiries: https://redcircle.com/brandsPrivacy & Opt-Out: https://redcircle.com/privacy',
'duration_ms': 3690161,
'episode_id': '3o0RYoo5iOMKSmEbunsbvW',
'explicit': False,
'external_urls': dict({
'spotify': 'https://open.spotify.com/episode/3o0RYoo5iOMKSmEbunsbvW',
}),
'href': 'https://api.spotify.com/v1/episodes/3o0RYoo5iOMKSmEbunsbvW',
'images': list([
dict({
'height': 640,
'url': 'https://i.scdn.co/image/ab6765630000ba8ac7bedd27a4413b1abf926d8a',
'width': 640,
}),
dict({
'height': 300,
'url': 'https://i.scdn.co/image/ab67656300005f1fc7bedd27a4413b1abf926d8a',
'width': 300,
}),
dict({
'height': 64,
'url': 'https://i.scdn.co/image/ab6765630000f68dc7bedd27a4413b1abf926d8a',
'width': 64,
}),
]),
'name': 'My Squirrel Has Brain Damage - Safety Third 119',
'release_date': '2024-07-26',
'release_date_precision': 'day',
'show': dict({
'description': 'Safety Third is a weekly show hosted by William Osman, NileRed, The Backyard Scientist, Allen Pan, and a couple other YouTube "Scientists". Sometimes we have guests, sometimes it\'s just us, but always: safety is our number three priority.',
'external_urls': dict({
'spotify': 'https://open.spotify.com/show/1Y9ExMgMxoBVrgrfU7u0nD',
}),
'href': 'https://api.spotify.com/v1/shows/1Y9ExMgMxoBVrgrfU7u0nD',
'images': list([
dict({
'height': 640,
'url': 'https://i.scdn.co/image/ab6765630000ba8ac7bedd27a4413b1abf926d8a',
'width': 640,
}),
dict({
'height': 300,
'url': 'https://i.scdn.co/image/ab67656300005f1fc7bedd27a4413b1abf926d8a',
'width': 300,
}),
dict({
'height': 64,
'url': 'https://i.scdn.co/image/ab6765630000f68dc7bedd27a4413b1abf926d8a',
'width': 64,
}),
]),
'name': 'Safety Third',
'publisher': 'Safety Third ',
'show_id': '1Y9ExMgMxoBVrgrfU7u0nD',
'total_episodes': 120,
'uri': 'spotify:show:1Y9ExMgMxoBVrgrfU7u0nD',
}),
'type': 'episode',
'uri': 'spotify:episode:3o0RYoo5iOMKSmEbunsbvW',
}),
}),
]),
}),
'uri': 'spotify:playlist:3cEYpjA9oz9GiPac4AsH4n',

View File

@ -649,6 +649,16 @@
'thumbnail': 'https://i.scdn.co/image/ab67616d0000b27304e57d181ff062f8339d6c71',
'title': 'You Are So Beautiful',
}),
dict({
'can_expand': False,
'can_play': True,
'children_media_class': None,
'media_class': <MediaClass.EPISODE: 'episode'>,
'media_content_id': 'spotify://01j5tx5a0ff6g5v0qjx6hbc94t/spotify:episode:3o0RYoo5iOMKSmEbunsbvW',
'media_content_type': 'spotify://episode',
'thumbnail': 'https://i.scdn.co/image/ab6765630000ba8ac7bedd27a4413b1abf926d8a',
'title': 'My Squirrel Has Brain Damage - Safety Third 119',
}),
]),
'children_media_class': <MediaClass.TRACK: 'track'>,
'media_class': <MediaClass.PLAYLIST: 'playlist'>,