Skip to content

Instantly share code, notes, and snippets.

@akinozgen
Created June 26, 2020 17:06
Show Gist options
  • Save akinozgen/c6415a28f6196327b98d6be2828861c5 to your computer and use it in GitHub Desktop.
Save akinozgen/c6415a28f6196327b98d6be2828861c5 to your computer and use it in GitHub Desktop.
Download any song by searching in dmenu.
#!/bin/bash
directory="$(find -L ~ -type d -not -path '*/\.*' -not -path '*/Android/*' -maxdepth 5 | dmenu -i -l 10 -p 'Where do you want to save the file? Only absolute path...')"
query="$(echo '' | dmenu -i -p 'Search for Artist - Song name format')"
provider="$(echo -e 'Youtube\nSpotify' | dmenu -i -l 2 -p 'Select provider')"
cd $directory
if [ "$provider" = "Spotify" ]
then
spotdl --song "$query" -f "$directory/{artist} - {track-name}.{output-ext}"
elif [ "$provider" = "Youtube" ]
then
youtube-dl "ytsearch1:$query" -x --audio-format mp3 -o "$directory/%(title)s.%(ext)s"
fi
exit
clear
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment