Skip to content

Commit

Permalink
Handle null tracks in playlists
Browse files Browse the repository at this point in the history
  • Loading branch information
ReubenFrankel committed Feb 26, 2024
1 parent 1b55610 commit 94afbc8
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion tap_spotify/streams.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,6 +3,7 @@
from datetime import datetime
from typing import Iterable

from requests.models import Response as Response
from singer_sdk.streams.rest import RESTStream

from tap_spotify.client import SpotifyStream
Expand Down Expand Up @@ -52,7 +53,6 @@ def get_records(self, context):

# merge track and audio features records
for track, audio_features in zip(track_records, audio_features_records):

# account for tracks with `null` audio features
row = {**(audio_features or {}), **track}
yield self.post_process(row, context)
Expand Down Expand Up @@ -174,6 +174,11 @@ class _PlaylistTracksStream(_RankStream, _SyncedAtStream, _TracksStream):
schema = TrackObject.extend_with(Rank, SyncedAt, AudioFeaturesObject).schema
primary_keys = ["rank", "synced_at"]

def parse_response(self, response):
for track in super().parse_response(response):
if track:
yield track


class GlobalTopTracksDailyStream(_PlaylistTracksStream):
"""Define global top tracks daily stream."""
Expand Down

0 comments on commit 94afbc8

Please sign in to comment.