Skip to content

Conversation

blastbeng
Copy link

@blastbeng blastbeng commented May 13, 2025

Title

Fixing KeyError: 'videoDetails' when downloading from youtube links.

Description

Sometimes youtube APIs does not correctly returns the song object with "videoDetails", this cause spotdl to crash.

Related Issue

#2375

Motivation and Context

This change is required because spotdl sometimes crashes when downloading a big list of youtube music songs

How Has This Been Tested?

This has been tested locally with a debug session on vscode and with:

  1. mapfile -t <000000_track_list.txt; /home/$USER/.local/bin/spotdl sync ${MAPFILE[@]} --config --headless --ignore-albums "live" "mixes" "in concert" "tour" --save-file 000000_sync.spotdl
  2. /home/$USER/.local/bin/spotdl sync --config --headless --ignore-albums "live" "mixes" "in concert" "tour" --save-file 000000_sync.spotdl --scan-for-songs --overwrite metadata

000000_track_list.txt contains a very long list of yt music links, line by line - 5000+

Now when the song searched from youtube music link hasn't the "videoDetails" object, it just skips the song as it should.

Screenshots (if appropriate)

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 change)

Checklist

  • My code follows the code style of this project
  • My change requires a change to the documentation
  • I have updated the documentation accordingly
  • I have read the CONTRIBUTING document
  • I have read the CORE VALUES document
  • I have added tests to cover my changes
  • All new and existing tests passed

@Silverarmor Silverarmor changed the base branch from master to dev August 2, 2025 07:48
Copy link
Member

@Silverarmor Silverarmor left a comment

Choose a reason for hiding this comment

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

Looks good but lacking logic for if the keys are missing?
Do we want to give up on the song and raise an error?

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants