From 9f53345e498cc558a78cf547a78298b827c61930 Mon Sep 17 00:00:00 2001 From: "Matheus A." Date: Wed, 1 Jan 2025 11:56:13 -0300 Subject: [PATCH] Fixes gdltool.sh for links with spaces --- scripts/shell/gdltool.sh | 19 ++++++++++--------- 1 file changed, 10 insertions(+), 9 deletions(-) diff --git a/scripts/shell/gdltool.sh b/scripts/shell/gdltool.sh index 0c3c755..3d92447 100755 --- a/scripts/shell/gdltool.sh +++ b/scripts/shell/gdltool.sh @@ -36,7 +36,7 @@ while [ "$#" -gt 0 ]; do esac done -commands_to_check=(gallery-dl gdl.sh feh xdotool stoml) +commands_to_check=(gallery-dl gdl.sh feh xdotool) commands_not_found=() for command in ${commands_to_check[@]}; do @@ -141,7 +141,7 @@ input_selected_folders_and_fill_selected_folders_variable() { mkdir --parents "$new_foldername" - selected_folders=("$new_foldername") + selected_folders+=("$new_foldername") else for selected_option in ${selected_options[@]}; do selected_folder=${existing_folders[$selected_option]} @@ -447,7 +447,7 @@ image_download_steps() { echo "" echo "Download starting..." - downloaded_images=($(gallery-dl --directory ${tmp_dir} $url_to_download)) + downloaded_images=$(gallery-dl --directory ${tmp_dir} $url_to_download) if [[ $? -ne 0 ]]; then unsucessful_downloads+="$url_to_download" @@ -456,8 +456,9 @@ image_download_steps() { echo "Download finished." - for downloaded_image_temp_path in "${downloaded_images[@]}"; do - if [ $downloaded_image_temp_path == '#' ]; then + # for downloaded_image_temp_path in "${downloaded_images[@]}"; do + while read -r downloaded_image_temp_path; do + if [ "$downloaded_image_temp_path" == '#' ]; then continue fi @@ -466,17 +467,17 @@ image_download_steps() { file_extension=$(get_extension_from_filename "$downloaded_image_temp_path") - final_temp_filepath_md5=($(md5sum $downloaded_image_temp_path)) + final_temp_filepath_md5=($(md5sum "$downloaded_image_temp_path")) final_filename="${final_temp_filepath_md5}.${file_extension}" - cp $downloaded_image_temp_path ./${final_filename} + cp "$downloaded_image_temp_path" ./${final_filename} echo "$final_filename,$url_to_download" >>$furry_commission_ideas_urls_filename done - done - rm $downloaded_image_temp_path + rm "$downloaded_image_temp_path" + done < <(echo "$downloaded_images") } fill_existing_folders_array