Skip to content

Commit

Permalink
Avoid constructing query params manually (#332)
Browse files Browse the repository at this point in the history
  • Loading branch information
felix-hilden committed Dec 1, 2024
1 parent ae6b76c commit 4d00649
Show file tree
Hide file tree
Showing 9 changed files with 26 additions and 20 deletions.
6 changes: 6 additions & 0 deletions docs/src/release_notes.rst
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,12 @@

Release notes
=============
Unreleased
----------
Fixed
*****
- Avoid constructing query params manually (:issue:`332`)

5.5.1 (2024-09-09)
------------------
Fixed
Expand Down
2 changes: 1 addition & 1 deletion src/tekore/_client/api/album.py
Original file line number Diff line number Diff line change
Expand Up @@ -64,4 +64,4 @@ def albums(self, album_ids: list, market: str = None) -> List[FullAlbum]:
market
an ISO 3166-1 alpha-2 country code or 'from_token'
"""
return self._get("albums/?ids=" + ",".join(album_ids), market=market)
return self._get("albums", ids=",".join(album_ids), market=market)
2 changes: 1 addition & 1 deletion src/tekore/_client/api/artist.py
Original file line number Diff line number Diff line change
Expand Up @@ -36,7 +36,7 @@ def artists(self, artist_ids: list) -> List[FullArtist]:
artist_ids
list of artist IDs, max 50 without chunking
"""
return self._get("artists/?ids=" + ",".join(artist_ids))
return self._get("artists", ids=",".join(artist_ids))

@scopes()
@send_and_process(single(SimpleAlbumPaging))
Expand Down
2 changes: 1 addition & 1 deletion src/tekore/_client/api/audiobook.py
Original file line number Diff line number Diff line change
Expand Up @@ -50,7 +50,7 @@ def audiobooks(
If an application token is used and no market is specified,
the show is considered unavailable.
"""
return self._get("audiobook/?ids=" + ",".join(audiobook_ids), market=market)
return self._get("audiobook", ids=",".join(audiobook_ids), market=market)

@scopes()
@send_and_process(single(SimpleChapterPaging))
Expand Down
2 changes: 1 addition & 1 deletion src/tekore/_client/api/chapter.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def chapters(self, chapter_ids: list, market: str = None) -> List[FullChapter]:
If an application token is used and no market is specified,
the episode is considered unavailable.
"""
return self._get("chapters/?ids=" + ",".join(chapter_ids), market=market)
return self._get("chapters", ids=",".join(chapter_ids), market=market)
2 changes: 1 addition & 1 deletion src/tekore/_client/api/episode.py
Original file line number Diff line number Diff line change
Expand Up @@ -48,4 +48,4 @@ def episodes(self, episode_ids: list, market: str = None) -> List[FullEpisode]:
If an application token is used and no market is specified,
the episode is considered unavailable.
"""
return self._get("episodes/?ids=" + ",".join(episode_ids), market=market)
return self._get("episodes", ids=",".join(episode_ids), market=market)
24 changes: 12 additions & 12 deletions src/tekore/_client/api/library.py
Original file line number Diff line number Diff line change
Expand Up @@ -54,7 +54,7 @@ def saved_albums_contains(self, album_ids: list) -> List[bool]:
List[bool]
save statuses in the same order the album IDs were given
"""
return self._get("me/albums/contains?ids=" + ",".join(album_ids))
return self._get("me/albums/contains", ids=",".join(album_ids))

@scopes([scope.user_library_modify])
@chunked("album_ids", 1, 50, return_none)
Expand All @@ -68,7 +68,7 @@ def saved_albums_add(self, album_ids: list) -> None:
album_ids
list of album IDs, max 50 without chunking
"""
return self._put("me/albums?ids=" + ",".join(album_ids))
return self._put("me/albums", ids=",".join(album_ids))

@scopes([scope.user_library_modify])
@chunked("album_ids", 1, 50, return_none)
Expand All @@ -82,7 +82,7 @@ def saved_albums_delete(self, album_ids: list) -> None:
album_ids
list of album IDs, max 50 without chunking
"""
return self._delete("me/albums?ids=" + ",".join(album_ids))
return self._delete("me/albums", ids=",".join(album_ids))

@scopes([scope.user_library_read])
@send_and_process(single(SavedEpisodePaging))
Expand Down Expand Up @@ -121,7 +121,7 @@ def saved_episodes_contains(self, episode_ids: list) -> List[bool]:
List[bool]
save statuses in the same order the episode IDs were given
"""
return self._get("me/episodes/contains?ids=" + ",".join(episode_ids))
return self._get("me/episodes/contains", ids=",".join(episode_ids))

@scopes([scope.user_library_modify])
@chunked("episode_ids", 1, 50, return_none)
Expand All @@ -135,7 +135,7 @@ def saved_episodes_add(self, episode_ids: list) -> None:
episode_ids
list of episode IDs, max 50 without chunking
"""
return self._put("me/episodes?ids=" + ",".join(episode_ids))
return self._put("me/episodes", ids=",".join(episode_ids))

@scopes([scope.user_library_modify])
@chunked("episode_ids", 1, 50, return_none)
Expand All @@ -149,7 +149,7 @@ def saved_episodes_delete(self, episode_ids: list) -> None:
episode_ids
list of episode IDs, max 50 without chunking
"""
return self._delete("me/episodes?ids=" + ",".join(episode_ids))
return self._delete("me/episodes", ids=",".join(episode_ids))

@scopes([scope.user_library_read])
@send_and_process(single(SavedTrackPaging))
Expand Down Expand Up @@ -188,7 +188,7 @@ def saved_tracks_contains(self, track_ids: list) -> List[bool]:
List[bool]
save statuses in the same order the track IDs were given
"""
return self._get("me/tracks/contains?ids=" + ",".join(track_ids))
return self._get("me/tracks/contains", ids=",".join(track_ids))

@scopes([scope.user_library_modify])
@chunked("track_ids", 1, 50, return_none)
Expand All @@ -202,7 +202,7 @@ def saved_tracks_add(self, track_ids: list) -> None:
track_ids
list of track IDs, max 50 without chunking
"""
return self._put("me/tracks/?ids=" + ",".join(track_ids))
return self._put("me/tracks", ids=",".join(track_ids))

@scopes([scope.user_library_modify])
@chunked("track_ids", 1, 50, return_none)
Expand All @@ -216,7 +216,7 @@ def saved_tracks_delete(self, track_ids: list) -> None:
track_ids
list of track IDs, max 50 without chunking
"""
return self._delete("me/tracks/?ids=" + ",".join(track_ids))
return self._delete("me/tracks", ids=",".join(track_ids))

@scopes([scope.user_library_read])
@send_and_process(single(SavedShowPaging))
Expand Down Expand Up @@ -255,7 +255,7 @@ def saved_shows_contains(self, show_ids: list) -> List[bool]:
List[bool]
save statuses in the same order the show IDs were given
"""
return self._get("me/shows/contains?ids=" + ",".join(show_ids))
return self._get("me/shows/contains", ids=",".join(show_ids))

@scopes([scope.user_library_modify])
@chunked("show_ids", 1, 50, return_none)
Expand All @@ -269,7 +269,7 @@ def saved_shows_add(self, show_ids: list) -> None:
show_ids
list of show IDs, max 50 without chunking
"""
return self._put("me/shows/?ids=" + ",".join(show_ids))
return self._put("me/shows", ids=",".join(show_ids))

@scopes([scope.user_library_modify])
@chunked("show_ids", 1, 50, return_none)
Expand All @@ -286,4 +286,4 @@ def saved_shows_delete(self, show_ids: list, market: str = None) -> None:
an ISO 3166-1 alpha-2 country code, only remove shows that are
available in the specified market, overrided by token's country
"""
return self._delete("me/shows/?ids=" + ",".join(show_ids), market=market)
return self._delete("me/shows", ids=",".join(show_ids), market=market)
2 changes: 1 addition & 1 deletion src/tekore/_client/api/show.py
Original file line number Diff line number Diff line change
Expand Up @@ -55,7 +55,7 @@ def shows(self, show_ids: list, market: str = None) -> List[FullShow]:
If an application token is used and no market is specified,
the show is considered unavailable.
"""
return self._get("shows/?ids=" + ",".join(show_ids), market=market)
return self._get("shows", ids=",".join(show_ids), market=market)

@scopes()
@send_and_process(single(SimpleEpisodePaging))
Expand Down
4 changes: 2 additions & 2 deletions src/tekore/_client/api/track.py
Original file line number Diff line number Diff line change
Expand Up @@ -40,7 +40,7 @@ def tracks(self, track_ids: list, market: str = None) -> List[FullTrack]:
market
an ISO 3166-1 alpha-2 country code or 'from_token'
"""
return self._get("tracks/?ids=" + ",".join(track_ids), market=market)
return self._get("tracks", ids=",".join(track_ids), market=market)

@scopes()
@send_and_process(single(AudioAnalysis))
Expand Down Expand Up @@ -73,4 +73,4 @@ def tracks_audio_features(self, track_ids: list) -> List[AudioFeatures]:
track_ids
track IDs, max 100 without chunking
"""
return self._get("audio-features?ids=" + ",".join(track_ids))
return self._get("audio-features", ids=",".join(track_ids))

0 comments on commit 4d00649

Please sign in to comment.