From 94afbc8e3176a2925c36b2e05425990a653ed7da Mon Sep 17 00:00:00 2001 From: Reuben Frankel Date: Mon, 26 Feb 2024 01:07:24 +0000 Subject: [PATCH] Handle `null` tracks in playlists --- tap_spotify/streams.py | 7 ++++++- 1 file changed, 6 insertions(+), 1 deletion(-) diff --git a/tap_spotify/streams.py b/tap_spotify/streams.py index 90656a2..425b8b6 100644 --- a/tap_spotify/streams.py +++ b/tap_spotify/streams.py @@ -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 @@ -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) @@ -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."""