~iortega/scripts

57ff81faf96e6060e8071b869414af2c61ea15f5 — Iñigo Ortega Martínez 11 months ago e0e7912
help updates on download audio
1 files changed, 10 insertions(+), 5 deletions(-)

M download-audio.sh
M download-audio.sh => download-audio.sh +10 -5
@@ 2,13 2,17 @@

# Help menu
usage() {
    printf "Usage: $0 [-f <format>] [-d <directory>]" 1>&2
    printf "Usage: $0 [-f <format>] [-d <directory>] [link]" 1>&2
    printf "
-f <format>  Sets the format the audio will be downloaded on.
             Default: ogg opus when possible, otherwise vorbis ogg.

-d <directory>  Sets the directory where downloaded audio will be stored.
                Default: \$HOME/Downloads/youtube-dl/
    It downloads on a directory the audio from the provided link.
    If no link is provided, clipboard content is used.

    -f <format>  Sets the format the audio will be downloaded on.
                 Default: ogg opus when possible, otherwise vorbis ogg.

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

" >&2
    exit 1


@@ 50,6 54,7 @@ if [ "$format" = "opus" ]; then
    youtube-dl -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"
        rm "$filename"