Skip to content

Instantly share code, notes, and snippets.

@ryuichi24
Created January 28, 2021 15:57
Show Gist options
  • Select an option

  • Save ryuichi24/b76a19ea46e0cd851f32e390c0619da9 to your computer and use it in GitHub Desktop.

Select an option

Save ryuichi24/b76a19ea46e0cd851f32e390c0619da9 to your computer and use it in GitHub Desktop.
wrapper commands for youtube-dl
#!/bin/zsh
ydDir="$HOME/yd"
videoDir="$HOME/yd/videos"
musicDir="$HOME/yd/music"
# make yd directories if not exist
if [ ! -d "$ydDir" ]; then
mkdir "$HOME/yd"
mkdir "$videoDir"
mkdir "$musicDir"
fi
function getmusic() {
musicUrl=$1
if [ -z $musicUrl ]; then
echo "please provide an url to the music"
else
youtube-dl -o "$musicDir/%(title)s.%(ext)s" --extract-audio --audio-format mp3 $musicUrl
fi
}
function getvideo() {
videoUrl=$1
if [ -z $videoUrl ]; then
echo "please provide an url to the video"
else
youtube-dl -o "$videoDir/%(title)s.%(ext)s" -f 18 $videoUrl
fi
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment