Ian's blog
Mar 26 2021

Some youtube-dl aliases

Setup some variables

# Default Command
CMD="youtube-dl"

# Use yt-dlp if avaiable
command -v yt-dlp >/dev/null &&
  CMD="yt-dlp" ARGS=""

# Quality Options
Q_HD="720"
Q_FHD="1080"
Q_DEFAULT="$Q_HD"

Default command

Saves video to ~/Videos/Channel/video.mp4 without video Id.

# Video
ydl() {
  "$CMD" "$ARGS" \
    --no-playlist \
    --embed-subs \
    --format "[height<=$Q_DEFAULT]" \
    --output "$HOME/Videos/%(uploader)s/%(title)s.%(ext)s" "$@"
}

720p Video

# Video (720p)
yhd() {
  "$CMD" "$ARGS" \
    --no-playlist \
    --embed-subs \
    --format "[height<=$Q_HD]" \
    --output "$HOME/Videos/%(uploader)s/%(title)s.%(ext)s" "$@"
}

720p video playlist

ypl() {
  "$CMD" "$ARGS" \
    --yes-playlist \
    --format "[height<=$Q_DEFAULT]" \
    --output "$HOME/Videos/%(uploader)s/%(playlist)s/%(title)s.%(ext)s" "$@"
}

Audio

# Audio
ymp3() {
  "$CMD" "$ARGS" \
    --extract-audio \
    --audio-format mp3 \
    --no-playlist \
    --embed-thumbnail \
    --format "bestaudio" \
    --output "$HOME/Music/%(uploader)s/%(title)s.%(ext)s" "$@"
}

Audio Playlist

# Audio Playlist
ypl3() {
  "$CMD" "$ARGS" \
    --extract-audio \
    --audio-format mp3 \
    --yes-playlist \
    --embed-thumbnail \
    --format "bestaudio" \
    --output "$HOME/Music/%(uploader)s/%(playlist)s/%(title)s.%(ext)s" "$@"
}