2020-12-31 15:08:46 +00:00
|
|
|
#!/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
|
|
|
|
|
2021-11-13 01:44:46 +00:00
|
|
|
check_exists yt-dlp || die "yt-dlp not found"
|
|
|
|
|
2020-12-31 15:08:46 +00:00
|
|
|
[ -d "$dest" ] || mkdir -p "$dest"
|
|
|
|
|
|
|
|
notify-send -t 3000 "mp3dl" "Downloading $url..."
|
|
|
|
|
2021-11-13 01:44:46 +00:00
|
|
|
yt-dlp -x --audio-format mp3 --no-playlist --add-metadata -o "$dest/%(title)s.%(ext)s" "$url" 2>&1 \
|
2020-12-31 15:08:46 +00:00
|
|
|
| grep 'ERROR:' \
|
|
|
|
| notify_err
|