Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Skip song if track is empty. #1164

Merged
merged 2 commits into from
Feb 7, 2021
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
5 changes: 4 additions & 1 deletion spotdl/search/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,6 +82,9 @@ def get_playlist_tracks(playlistUrl: str) -> List[SongObj]:
while True:

for songEntry in playlistResponse['items']:
if songEntry['track'] is None:
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we should check if the id is None because if the track is not None but the id is missing spotdl will crash

if songEntry['track']['id'] is None:
    continue

image

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think we'd need to check both of them. Because in #1147 the songEntry['track'] is None

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is it possible to have a none None track, but with an empty id?

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I guess so. If the track would be empty we would get object is not subscriptable error, but in the screenshot above songEntry['track']['id'] returns None for some reason

Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Looks like tracks with no id are tracks that are not available in your country/removed from spotify or something like that

image

image

continue

song = SongObj.from_url(
'https://open.spotify.com/track/' + songEntry['track']['id'])

Expand All @@ -92,7 +95,7 @@ def get_playlist_tracks(playlistUrl: str) -> List[SongObj]:
if playlistResponse['next']:
playlistResponse = spotifyClient.playlist_tracks(
playlistUrl,
offset=len(playlistTracks)
offset=playlistResponse['offset'] + playlistResponse['limit']
)
else:
break
Expand Down