From 0ce1c686ae54347039d770758bea1c2027f68bc3 Mon Sep 17 00:00:00 2001 From: Till Höppner Date: Sun, 22 Apr 2018 11:06:58 +0200 Subject: youtube-dl: variable format with fallback to opus --- conf.d/99-youtube-dl.zsh | 12 ++++++++---- 1 file changed, 8 insertions(+), 4 deletions(-) (limited to 'conf.d') diff --git a/conf.d/99-youtube-dl.zsh b/conf.d/99-youtube-dl.zsh index 8e572a5..c3f6483 100644 --- a/conf.d/99-youtube-dl.zsh +++ b/conf.d/99-youtube-dl.zsh @@ -1,14 +1,18 @@ function download_audio() { + format="$1" + shift + youtube-dl \ - --extract-audio --audio-format vorbis --audio-quality 0 --no-call-home \ - --restrict-filenames --ignore-errors --add-metadata $@ + --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 $(xclip -o) + download_audio "$format" $(xclip -o -selection clipboard) else - download_audio $@ + download_audio "$format" "$@" fi } -- cgit v1.2.3