Skip to content

Commit

Permalink
Define max tracks for audio features stream
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenFrankel committed Feb 26, 2024
1 parent 0b2b98b commit 8bbe81f
Showing 1 changed file with 8 additions and 0 deletions.
8 changes: 8 additions & 0 deletions tap_spotify/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -69,9 +69,17 @@ class _AudioFeaturesStream(SpotifyStream):
path = "/audio-features"
records_jsonpath = "$.audio_features[*]"
schema = AudioFeaturesObject.schema
max_tracks = 100

def __init__(self, tracks_stream: _TracksStream, track_records: Iterable[dict]):
super().__init__(tracks_stream._tap)

total_tracks = len(track_records)

if total_tracks > self.max_tracks:
msg = f"Cannot get audio features for more than {self.max_tracks} tracks at a time: {total_tracks} requested"
raise ValueError(msg)

self._track_records = track_records

def get_url_params(self, *args, **kwargs):
Expand Down

0 comments on commit 8bbe81f

Please sign in to comment.