rc/bin/mp3dl
2021-11-13 02:44:46 +01:00

46 lines
735 B
Bash
Executable file

#!/bin/sh
set -eu
# Load helper functions
source "$(dirname "$(rreadlink "$0")")/../lib/utils.sh"
usage() {
>&2 echo "Usage: $0 [-d folder_dest] <video url>"
exit 1
}
dest="$HOME/mus/download/"
url=""
while [ $# -gt 0 ]; do
arg="$1"
case $arg in
-h|--help)
usage
;;
-d)
dest="$2"
shift 2
;;
*)
url="$1"
shift
;;
esac
done
if [ -z "$url" ]; then
usage
fi
check_exists yt-dlp || die "yt-dlp not found"
[ -d "$dest" ] || mkdir -p "$dest"
notify-send -t 3000 "mp3dl" "Downloading $url..."
yt-dlp -x --audio-format mp3 --no-playlist --add-metadata -o "$dest/%(title)s.%(ext)s" "$url" 2>&1 \
| grep 'ERROR:' \
| notify_err