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

Conversation

bee395
Copy link
Contributor

@bee395 bee395 commented Jan 30, 2021

Description

Some playlist requested with spotipy contain empty tracks.
This change will skip those tracks, and use the correct offset for the next request.

Types of changes

  • Bug fix (non-breaking change which fixes an issue)
  • New feature (non-breaking change which adds functionality)
  • Breaking change (fix or feature that would cause existing functionality to not work as expected)

@ghost
Copy link

ghost commented Jan 30, 2021

#1163 is for the same thing. Not sure which is better. Maybe have a look at that too.

@Silverarmor Silverarmor changed the base branch from hotfix to dev February 6, 2021 08:31
if song.get_youtube_link() != None:
playlistTracks.append(song)

# check if more tracks are to be passed
if playlistResponse['next']:
playlistResponse = spotifyClient.playlist_tracks(
playlistUrl,
offset = len(playlistTracks)
offset = playlistResponse['offset'] + playlistResponse['limit']
Copy link
Contributor

Choose a reason for hiding this comment

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

This is not need necessary, is it?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

If a track is None, playlisttracks will not increase. So you will request duplicate entries
And if you have, in theory, 100 None entries. The offset will stay the same and the program will be stuck

So I would say it's essential

@@ -79,17 +79,20 @@ 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

@Silverarmor Silverarmor added the Bug Fix PRs that fix bugs label Feb 6, 2021
@Silverarmor
Copy link
Member

@bee395 can you pull from spotDL:dev and resolve conflicts from that merge please

@Silverarmor Silverarmor merged commit c40fad3 into spotDL:dev Feb 7, 2021
Silverarmor added a commit that referenced this pull request Feb 8, 2021
* Run regressions on CI (#1158)
Authored by @aklajnert 

* Use argparse instead of raw `sys.argv` (#1157)
Authored by @aklajnert 

* FIxed error caused by songs with ':' in name (#1162)
Authored by @MikhailZex 

* Fixed TypeError when downloading tracks (#1177)
Authored by @xnetcat

* Bump version to 3.3.2

* Lint with flake8, fix code to pass it (#1178)
Authored by @aklajnert 

* Fixed flake8 (#1181)
Authored by @aklajnert

* Skip song if track is empty. (#1164)
Authored by @bee395 

Co-authored-by: Andrzej Klajnert <github@aklajnert.pl>
Co-authored-by: Michael George <MikhailZex@gmail.com>
Co-authored-by: Jakub <42355410+xnetcat@users.noreply.github.com>
Co-authored-by: bee395 <bee395@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Bug Fix PRs that fix bugs
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

4 participants