summaryrefslogtreecommitdiff
path: root/conf.d/99-youtube-dl.zsh
blob: c3f64834fec4ae883823222c1f4e49d57fe9fb01 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
function download_audio() {
  format="$1"
  shift

  youtube-dl \
    --extract-audio --audio-format "$format" --audio-quality 0 --no-call-home \
    --restrict-filenames --ignore-errors --add-metadata "$@"
}

function rip() {
  : "${format:=opus}"
  if [ "$#" -ne 1 ]; then
    download_audio "$format" $(xclip -o -selection clipboard)
  else
    download_audio "$format" "$@"
  fi
}

function ripto() {
  mkdir $1
  pushd $1
  rip $2
  popd
}