dotfiles

configuration files for shell, text editor, graphical environment, etc.
git clone git://src.adamsgaard.dk/dotfiles # fast
git clone https://src.adamsgaard.dk/dotfiles.git # slow
Log | Files | Refs | README | LICENSE Back to index

commit 6f63739f3938c61ff698935d522ec19901162e43
parent c3d8129e0f2b51a54dda75388656d63025ddbf77
Author: Anders Damsgaard <anders@adamsgaard.dk>
Date:   Wed, 17 Mar 2021 16:25:07 +0100

youtube-dl-music: fix script with new youtube-dl versions

Diffstat:
M.local/bin/youtube-dl-music | 21++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/.local/bin/youtube-dl-music b/.local/bin/youtube-dl-music @@ -24,6 +24,16 @@ show_help() { echo " -- do not consider any following arguments as options" } +ytdl() { + $prefix youtube-dl \ + --format bestaudio \ + --extract-audio \ + --audio-quality 0 \ + --audio-format mp3 \ + --add-metadata \ + --output "%(playlist_index)s - %(title)s.%(ext)s" \ + "$1" +} handle_url() { oldpwd="$PWD" @@ -31,14 +41,7 @@ handle_url() { mkdir -p "$outputdir" cd "$outputdir" - album="$($prefix youtube-dl \ - --format bestaudio \ - --extract-audio \ - --audio-quality 0 \ - --audio-format mp3 \ - --add-metadata \ - --output \'%\(playlist_index\)s - %\(title\)s.%\(ext\)s\' \ - "$1" | tee /dev/tty | grep 'Finished downloading' | sed 's/.*: //')" + album="$(ytdl "$1" | tee /dev/tty | grep 'Finished downloading' | sed 's/.*: //')" if [ $? -ne 0 ]; then die "youtube-dl error" @@ -81,7 +84,7 @@ handle_url() { printf 'file: %s\n' "$f" - song=$(printf '%s' "$f" | sed 's/.* - //' | sed 's/^ //' | sed 's/\.mp3//') + song=$(printf '%s' "$f" | sed 's/.* - //; s/^ //; s/\.mp3//') if [ "$auto" = 0 ]; then printf 'song [%s]: ' "$song"