Skip to content
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
41 changes: 20 additions & 21 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ pylint = "4.0.4"
pytest = "9.0.2"
pytest-asyncio = "1.3.0"
pytest-cov = "7.0.0"
ruff = "0.14.14"
ruff = "0.15.2"
safety = "3.7.0"
yamllint = "1.38.0"
syrupy = "5.1.0"
Expand Down
16 changes: 8 additions & 8 deletions src/spotifyaio/spotify.py
Original file line number Diff line number Diff line change
Expand Up @@ -292,7 +292,7 @@ async def get_new_releases(self) -> list[SimplifiedAlbum]:
@catch_json_decode_error
async def get_artist(self, artist_id: str) -> Artist:
"""Get artist."""
identifier = artist_id.split(":")[-1]
identifier = artist_id.rsplit(":", maxsplit=1)[-1]
response = await self._get(f"v1/artists/{identifier}")
return Artist.from_json(response)

Expand All @@ -314,14 +314,14 @@ async def get_artists(self, artist_ids: list[str]) -> list[Artist]:
async def get_artist_albums(self, artist_id: str) -> list[SimplifiedAlbum]:
"""Get artist albums."""
params: dict[str, Any] = {"limit": 48}
identifier = artist_id.split(":")[-1]
identifier = artist_id.rsplit(":", maxsplit=1)[-1]
response = await self._get(f"v1/artists/{identifier}/albums", params=params)
return NewReleasesResponseInner.from_json(response).items

@catch_json_decode_error
async def get_artist_top_tracks(self, artist_id: str) -> list[Track]:
"""Get artist top tracks."""
identifier = artist_id.split(":")[-1]
identifier = artist_id.rsplit(":", maxsplit=1)[-1]
response = await self._get(f"v1/artists/{identifier}/top-tracks")
return ArtistTopTracksResponse.from_json(response).tracks

Expand Down Expand Up @@ -413,7 +413,7 @@ async def get_category(self, category_id: str) -> Category:
@catch_json_decode_error
async def get_chapter(self, chapter_id: str) -> Chapter:
"""Get chapter."""
identifier = chapter_id.split(":")[-1]
identifier = chapter_id.rsplit(":", maxsplit=1)[-1]
response = await self._get(f"v1/chapters/{identifier}")
return Chapter.from_json(response)

Expand All @@ -434,7 +434,7 @@ async def get_chapters(self, chapter_ids: list[str]) -> list[Chapter]:
@catch_json_decode_error
async def get_episode(self, episode_id: str) -> Episode:
"""Get episode."""
identifier = episode_id.split(":")[-1]
identifier = episode_id.rsplit(":", maxsplit=1)[-1]
response = await self._get(f"v1/episodes/{identifier}")
return Episode.from_json(response)

Expand Down Expand Up @@ -638,7 +638,7 @@ async def add_to_queue(self, uri: str, device_id: str | None = None) -> None:
@catch_json_decode_error
async def get_playlist(self, playlist_id: str) -> Playlist:
"""Get playlist."""
identifier = playlist_id.split(":")[-1]
identifier = playlist_id.rsplit(":", maxsplit=1)[-1]
response = await self._get(
f"v1/playlists/{identifier}", params={"additional_types": "track,episode"}
)
Expand Down Expand Up @@ -810,7 +810,7 @@ async def search(
@catch_json_decode_error
async def get_show(self, show_id: str) -> Show:
"""Get show."""
identifier = show_id.split(":")[-1]
identifier = show_id.rsplit(":", maxsplit=1)[-1]
response = await self._get(f"v1/shows/{identifier}")
return Show.from_json(response)

Expand All @@ -819,7 +819,7 @@ async def get_show(self, show_id: str) -> Show:
@catch_json_decode_error
async def get_show_episodes(self, show_id: str) -> list[SimplifiedEpisode]:
"""Get show episodes."""
identifier = show_id.split(":")[-1]
identifier = show_id.rsplit(":", maxsplit=1)[-1]
params: dict[str, Any] = {"limit": 48}
response = await self._get(f"v1/shows/{identifier}/episodes", params=params)
return ShowEpisodesResponse.from_json(response).items
Expand Down
2 changes: 1 addition & 1 deletion src/spotifyaio/util.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,4 +3,4 @@

def get_identifier(identifier: str) -> str:
"""Get the identifier from a Spotify URI."""
return identifier.split(":")[-1]
return identifier.rsplit(":", maxsplit=1)[-1]
Loading