Remove redundant playlist ownership filtering
Eliminated unnecessary filtering of playlists by owner or collaboration status, as the Spotify API already returns all accessible playlists. This simplifies the code and ensures all relevant playlists are processed.
This commit is contained in:
parent
665281f184
commit
6e02aa03ac
1 changed files with 12 additions and 10 deletions
|
|
@ -243,11 +243,12 @@ class SpotifyClient:
|
||||||
|
|
||||||
while results:
|
while results:
|
||||||
for playlist_data in results['items']:
|
for playlist_data in results['items']:
|
||||||
if playlist_data['owner']['id'] == self.user_id or playlist_data['collaborative']:
|
# Spotify API already returns all playlists the user has access to
|
||||||
logger.info(f"Fetching tracks for playlist: {playlist_data['name']}")
|
# (owned + followed), so no need to filter
|
||||||
tracks = self._get_playlist_tracks(playlist_data['id'])
|
logger.info(f"Fetching tracks for playlist: {playlist_data['name']}")
|
||||||
playlist = Playlist.from_spotify_playlist(playlist_data, tracks)
|
tracks = self._get_playlist_tracks(playlist_data['id'])
|
||||||
playlists.append(playlist)
|
playlist = Playlist.from_spotify_playlist(playlist_data, tracks)
|
||||||
|
playlists.append(playlist)
|
||||||
|
|
||||||
results = self.sp.next(results) if results['next'] else None
|
results = self.sp.next(results) if results['next'] else None
|
||||||
|
|
||||||
|
|
@ -285,11 +286,12 @@ class SpotifyClient:
|
||||||
|
|
||||||
batch_count = 0
|
batch_count = 0
|
||||||
for playlist_data in results['items']:
|
for playlist_data in results['items']:
|
||||||
if playlist_data['owner']['id'] == self.user_id or playlist_data['collaborative']:
|
# Spotify API already returns all playlists the user has access to
|
||||||
# Create playlist with empty tracks list for now
|
# (owned + followed), so no need to filter
|
||||||
playlist = Playlist.from_spotify_playlist(playlist_data, [])
|
# Create playlist with empty tracks list for now
|
||||||
playlists.append(playlist)
|
playlist = Playlist.from_spotify_playlist(playlist_data, [])
|
||||||
batch_count += 1
|
playlists.append(playlist)
|
||||||
|
batch_count += 1
|
||||||
|
|
||||||
total_fetched += batch_count
|
total_fetched += batch_count
|
||||||
logger.info(f"Retrieved {batch_count} playlists in batch (offset {offset}), total: {total_fetched}")
|
logger.info(f"Retrieved {batch_count} playlists in batch (offset {offset}), total: {total_fetched}")
|
||||||
|
|
|
||||||
Loading…
Reference in a new issue