Skip to content

Instantly share code, notes, and snippets.

@Jackzmc
Last active April 1, 2020 15:20
Show Gist options
  • Select an option

  • Save Jackzmc/b00ecbf10cbf48a547bab2d21f327890 to your computer and use it in GitHub Desktop.

Select an option

Save Jackzmc/b00ecbf10cbf48a547bab2d21f327890 to your computer and use it in GitHub Desktop.
#!/bin/bash
DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" >/dev/null 2>&1 && pwd )"
if [[ "$#" -lt 1 ]]; then #if less than 1
echo "Usage: ./download.sh <youtube url> [name of file] "
exit 2
fi
if [[ "$#" -ne 2 ]]; then
echo Downloading $1
OUTPUT="$DIR/%(id)s.%(ext)s"
else
echo Downloading $1 as $2
OUTPUT="$DIR/$2.%(ext)s"
fi
youtube-dl -f 'bestaudio[ext=m4a]' "$1" --output $OUTPUT --add-metadata --embed-thumbnail --no-playlist
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment