Files
dotfiles/scripts/shell/gdl.sh
2024-06-12 02:00:39 -03:00

24 lines
486 B
Bash
Executable File

#!/usr/bin/zsh
if ! command -v "gallery-dl" &> /dev/null; then
echo 'The "gallery-dl" command is necessary in order to run the script, but was not found.'
exit 1
fi
media_url=$1
gallery-dl $media_url
cmd_exit_code=$?
if [[ $cmd_exit_code -ne 0 ]]; then
printf "\n"
echo "[ERROR] `basename $0`: Could not download url \"$media_url\""
echo "[ERROR] Exit status: $cmd_exit_code"
exit 1
fi
find gallery-dl -type f -exec mv '{}' . \;
rm --recursive gallery-dl