mirror of
https://github.com/home-assistant/core.git
synced 2025-08-03 20:55:10 +02:00
Handle query and anchors in Spotify URI's (#33084)
* Handle query and anchors in Spotify URI's * Use yarl for cleaning up the URL
This commit is contained in:
@@ -7,6 +7,7 @@ from typing import Any, Callable, Dict, List, Optional
|
||||
|
||||
from aiohttp import ClientError
|
||||
from spotipy import Spotify, SpotifyException
|
||||
from yarl import URL
|
||||
|
||||
from homeassistant.components.media_player import MediaPlayerDevice
|
||||
from homeassistant.components.media_player.const import (
|
||||
@@ -295,6 +296,10 @@ class SpotifyMediaPlayer(MediaPlayerDevice):
|
||||
"""Play media."""
|
||||
kwargs = {}
|
||||
|
||||
# Spotify can't handle URI's with query strings or anchors
|
||||
# Yet, they do generate those types of URI in their official clients.
|
||||
media_id = str(URL(media_id).with_query(None).with_fragment(None))
|
||||
|
||||
if media_type == MEDIA_TYPE_MUSIC:
|
||||
kwargs["uris"] = [media_id]
|
||||
elif media_type == MEDIA_TYPE_PLAYLIST:
|
||||
|
Reference in New Issue
Block a user