Skip to content

Instantly share code, notes, and snippets.

@dylan-chong
Created December 28, 2019 00:44
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save dylan-chong/60a87729a913ecd27487ca914c735bb0 to your computer and use it in GitHub Desktop.
Save dylan-chong/60a87729a913ecd27487ca914c735bb0 to your computer and use it in GitHub Desktop.
Download a list of songs by name
# Requires spotdl and youtube-dl to installed with python3
# Should be a list of search query text for spotify (e.g. `Song Name Artist Name`)
SONG_LIST_FILE = '/Users/Dylan/Desktop/songs.txt'.freeze
OUTPUT_FOLDER = '/Users/Dylan/Desktop/songs'.freeze
File.foreach(SONG_LIST_FILE) do |line|
command = [
'spotdl',
'--song',
line.delete("\n"),
'--output-ext',
'.m4a',
'--search-format',
'{artist} - {track_name}',
'--folder',
OUTPUT_FOLDER,
]
puts
puts command.inspect
system(*command)
end
@dylan-chong
Copy link
Author

dylan-chong commented Dec 28, 2019

NOTE: you have to be on the lookout for warnings like

ERROR: <SONG_NAME> was not found.

in which case manually search for <SONG_NAME> on youtube and download it using

youtube-dl --extract-audio --embed-thumbnail --audio-format m4a '<URL>'

There is another warning

INFO: Track not found on Spotify, falling back on YouTube metadata

which means the song will still probably get downloaded from youtube but the downloaded track won't have the spotify metadata attached to it

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment