~iortega/scripts

c5ab1b7d7760f279161bf4adeeccd4fb23dbde07 — Iñigo Ortega Martínez 2 years ago 57ff81f
youtube-dl -> yt-dlp
1 files changed, 6 insertions(+), 6 deletions(-)

M download-audio.sh
M download-audio.sh => download-audio.sh +6 -6
@@ 12,14 12,14 @@ usage() {
                 Default: ogg opus when possible, otherwise vorbis ogg.

    -d <directory>  Sets the directory where downloaded audio will be stored.
                    Default: \$HOME/Downloads/youtube-dl/
                    Default: \$HOME/Downloads/yt-dlp/

" >&2
    exit 1
}

origin="$(pwd)"
dir="$HOME/Downloads/youtube-dl"
dir="$HOME/Downloads/yt-dlp"
[ -d "$dir" ] && mkdir "$dir"

# To get options provided to the command


@@ 48,20 48,20 @@ fi

[ -z "$format" ] && format="opus"
if [ "$format" = "opus" ]; then
    filename="$(youtube-dl -x --audio-quality 0 --audio-format opus --get-filename "$link")"
    filename="$(yt-dlp -x --audio-quality 0 --audio-format opus --get-filename "$link")"
    filename="$(printf "$filename" | sed -r "s|\..*$||").opus"

    youtube-dl -x --audio-quality 0 --audio-format opus "$link"
    yt-dlp -x --audio-quality 0 --audio-format opus "$link"
    size="$(stat --printf="%s" "$filename")"

    # Little hack to check if opus file is ok
    if [ "$size" -lt 500000 ]; then
        youtube-dl -x --audio-quality 0 --audio-format vorbis "$link"
        yt-dlp -x --audio-quality 0 --audio-format vorbis "$link"
        rm "$filename"
    fi

else
    youtube-dl -x --audio-quality 0 --audio-format "$format" "$link"
    yt-dlp -x --audio-quality 0 --audio-format "$format" "$link"
fi

cd "$origin"