π· SpotifyΒΆ
Module: spotify.py
Provides methods to retrieve track and album metadata from search queries, IDs, URIs, or URLs.
- class Spotify(CLIENT_ID: str, CLIENT_SECRET: str)ΒΆ
A class for interacting with the Spotify API to search and retrieve track and album metadata.
- get_track(query: str, limit: int = 6) List[TrackMetadata] ΒΆ
Searches for tracks based on a query or Spotify ID/URI/URL and retrieves their metadata.
- Parameters:
query (str) β The search query or Spotify ID/URI/URL for the track.
limit (int, optional) β Max number of tracks to retrieve (only applies to search by text). Defaults to 6.
- Returns:
A list of track metadata.
- Return type:
List[TrackMetadata]
- Raises:
InvalidSearchLimit β If the limit is less than 1.
NoMatchingTrackFound β If no matching tracks are found.
- get_album(query: str, limit: int = 6, shuffle: bool = False) List[AlbumMetadata] ΒΆ
Searches for album based on a query or Spotify ID/URI/URL and retrieves their metadata.
- Parameters:
query (str) β The search query or Spotify ID/URI/URL for the album.
limit (int, optional) β Max number of albums to retrieve (only applies to search by text). Defaults to 6.
shuffle (bool, optional) β Whether to shuffle the track list. Defaults to False.
- Returns:
A list of album metadata with track listings.
- Return type:
List[AlbumMetadata]
- Raises:
InvalidSearchLimit β If the limit is less than 1.
NoMatchingAlbumFound β If no matching albums are found.