From f4464491bbee1dda4626d5df21e87e3f9d248c57 Mon Sep 17 00:00:00 2001 From: Matheus Albino Date: Wed, 19 Jun 2024 07:57:11 -0300 Subject: [PATCH] Improves gdl.sh and images-indexer.sh scripts --- scripts/shell/gdl.sh | 4 +--- scripts/shell/images-indexer.sh | 12 ++++++++++-- 2 files changed, 11 insertions(+), 5 deletions(-) diff --git a/scripts/shell/gdl.sh b/scripts/shell/gdl.sh index 43ea7b7..7d94595 100755 --- a/scripts/shell/gdl.sh +++ b/scripts/shell/gdl.sh @@ -8,13 +8,11 @@ fi media_url=$1 gallery-dl $media_url -cmd_exit_code=$? -if [[ $cmd_exit_code -ne 0 ]]; then +if [[ $? -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 diff --git a/scripts/shell/images-indexer.sh b/scripts/shell/images-indexer.sh index bb81085..3dffece 100755 --- a/scripts/shell/images-indexer.sh +++ b/scripts/shell/images-indexer.sh @@ -20,7 +20,7 @@ if [ ${#commands_not_found[@]} -ne 0 ]; then fi cur_dir=`pwd` -furry_commission_ideas_path=/mnt/e/home/Documents/sync/nextcloud-pudimxyz-cloud/furry-commission-ideas +furry_commission_ideas_path=/mnt/e/home/sync/nextcloud/furry-commission-ideas furry_commission_ideas_urls_filename="urls.txt" scripts_path=/home/cloud/repos/personal-devboot/scripts/shell @@ -47,6 +47,12 @@ done # remove trailing slashes media_url=`sed 's:/*$::' <<< "$media_url"` +url_regex='(https?)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]' +if [[ ! $media_url =~ $url_regex ]]; then + echo "The URL informed is not valid." + exit 1 +fi + cd $furry_commission_ideas_path existing_folders=($(find * -type d -not -path artists -not -path kinks -not -path ideas)) @@ -130,7 +136,9 @@ if [ -f "$furry_commission_ideas_urls_filename" ] && grep -qE "$media_url" -i "$ exit 0 fi -command_output=`$scripts_path/gdl.sh $media_url` +if ! command_output=$($scripts_path/gdl.sh $media_url); then + exit 1 +fi media_filenames=()