Some updates
This commit is contained in:
@@ -6,35 +6,27 @@ show_help() {
|
|||||||
# echo "Usage: `basename $0` [--no-abort-on-found] [--parallel] [--custom-grep-search|-c <string>]"
|
# echo "Usage: `basename $0` [--no-abort-on-found] [--parallel] [--custom-grep-search|-c <string>]"
|
||||||
echo "Usage: `basename $0` [--custom-grep-search|-c <string>]"
|
echo "Usage: `basename $0` [--custom-grep-search|-c <string>]"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
# echo " --no-abort-on-found (optional) The script will not update each gallery download until it finds an already downloaded file."
|
echo " --no-abort-on-found (optional) The script will not update each gallery download until it finds an already downloaded file."
|
||||||
# echo " --parallel-jobs (optional) The script will update each gallery download in parallel, with multiple background jobs running on your operating system."
|
echo " --no-parallel (optional) The script will update the found URLs in sequence"
|
||||||
# echo " --parallel-tmux (optional) The script will update each gallery download in parallel, with a tmux session with multiple tabs and panels."
|
|
||||||
echo " --custom-grep-search|-c (optional) Includes a string to filter the URLs."
|
echo " --custom-grep-search|-c (optional) Includes a string to filter the URLs."
|
||||||
}
|
}
|
||||||
|
|
||||||
should_abort_on_found=true
|
should_abort_on_found=true
|
||||||
should_use_parallel_downloads=false
|
parallel=true
|
||||||
should_use_parallel_tmux=true
|
should_use_tmux=true
|
||||||
custom_grep_search=''
|
custom_grep_search=''
|
||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--help|-h) show_help; exit ;;
|
--help|-h) show_help; exit ;;
|
||||||
# --no-abort-on-found) should_abort_on_found=false; shift ;;
|
--no-abort-on-found) should_abort_on_found=false; shift ;;
|
||||||
# --parallel-jobs) should_use_parallel_downloads=true; shift ;;
|
--no-parallel|-n) parallel=false; shift ;;
|
||||||
# --parallel-tmux) should_use_parallel_tmux=true; shift ;;
|
|
||||||
--custom-grep-search|-c) custom_grep_search="$2"; shift 2 ;;
|
--custom-grep-search|-c) custom_grep_search="$2"; shift 2 ;;
|
||||||
*) shift ;;
|
*) shift ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
|
|
||||||
if $should_use_parallel_downloads && $should_use_parallel_tmux; then
|
gallery_dl_path=/mnt/e/home/documents/data-hoarding
|
||||||
echo "Only one (or none) of these parameters should be used:"
|
|
||||||
echo " --parallel-jobs"
|
|
||||||
echo " --parallel-tmux"
|
|
||||||
fi
|
|
||||||
|
|
||||||
gallery_dl_path=/mnt/e/home/data-hoarding
|
|
||||||
cd "$gallery_dl_path"
|
cd "$gallery_dl_path"
|
||||||
|
|
||||||
urls=($(grep -v "filter" -i "$gallery_dl_path/todo.md" | grep -Eo "(mastodon:)?(http|https)://[a-zA-Z0-9.(/~@)?=_%:-]*"))
|
urls=($(grep -v "filter" -i "$gallery_dl_path/todo.md" | grep -Eo "(mastodon:)?(http|https)://[a-zA-Z0-9.(/~@)?=_%:-]*"))
|
||||||
@@ -86,24 +78,23 @@ commands_list=()
|
|||||||
for url in ${urls[@]}; do
|
for url in ${urls[@]}; do
|
||||||
gdl_command="$gdl_command_base $url"
|
gdl_command="$gdl_command_base $url"
|
||||||
|
|
||||||
if $should_use_parallel_downloads; then
|
|
||||||
gdl_command+=' &'
|
|
||||||
fi
|
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
if false; then
|
if false; then
|
||||||
echo "Command:"
|
echo "Command:"
|
||||||
echo " $gdl_command"
|
echo " $gdl_command"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $should_use_parallel_tmux; then
|
if $should_use_tmux; then
|
||||||
# commands_list+=("$gdl_command")
|
|
||||||
commands_list+=("$gdl_command")
|
commands_list+=("$gdl_command")
|
||||||
else
|
else
|
||||||
eval $gdl_command
|
eval $gdl_command
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
|
if ! $should_use_tmux; then
|
||||||
|
exit 0
|
||||||
|
fi
|
||||||
|
|
||||||
# debug
|
# debug
|
||||||
if false; then
|
if false; then
|
||||||
commands_list=(
|
commands_list=(
|
||||||
@@ -132,7 +123,7 @@ if false; then
|
|||||||
exit 0
|
exit 0
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if $should_use_parallel_tmux; then
|
if $should_use_tmux; then
|
||||||
session_name="tmp_gdl-update-todo-`uuidgen | sed 's/[-]//g' | head -c 10; echo;`"
|
session_name="tmp_gdl-update-todo-`uuidgen | sed 's/[-]//g' | head -c 10; echo;`"
|
||||||
|
|
||||||
tmux new-session -d -s $session_name
|
tmux new-session -d -s $session_name
|
||||||
@@ -140,27 +131,32 @@ if $should_use_parallel_tmux; then
|
|||||||
current_window_num=0
|
current_window_num=0
|
||||||
current_panel_num=0
|
current_panel_num=0
|
||||||
|
|
||||||
for ((i = 0; i < ${#commands_list[@]}; i++)); do
|
if $parallel; then
|
||||||
command_to_run="${commands_list[$i]}"
|
for ((i = 0; i < ${#commands_list[@]}; i++)); do
|
||||||
|
command_to_run="${commands_list[$i]}"
|
||||||
|
|
||||||
if [ "$i" -eq 0 ] || [ $(( i % 4 )) -eq 0 ]; then
|
if [ "$i" -eq 0 ] || [ $(( i % 4 )) -eq 0 ]; then
|
||||||
if [ "$i" -ne 0 ]; then
|
if [ "$i" -ne 0 ]; then
|
||||||
tmux new-window -t $session_name
|
tmux new-window -t $session_name
|
||||||
|
fi
|
||||||
|
|
||||||
|
((current_window_num++))
|
||||||
|
current_panel_num=1
|
||||||
|
|
||||||
|
tmux split-window -v -t $session_name
|
||||||
|
tmux select-pane -t $session_name:$current_window_num.1
|
||||||
|
tmux split-window -h -t $session_name
|
||||||
|
tmux select-pane -t $session_name:$current_window_num.3
|
||||||
|
tmux split-window -h -t $session_name
|
||||||
fi
|
fi
|
||||||
|
|
||||||
((current_window_num++))
|
tmux select-pane -t $session_name:$current_window_num.$current_panel_num
|
||||||
current_panel_num=1
|
tmux send-keys -t $session_name "$command_to_run" Enter
|
||||||
|
|
||||||
tmux split-window -v -t $session_name
|
((current_panel_num++))
|
||||||
tmux select-pane -t $session_name:$current_window_num.1
|
done
|
||||||
tmux split-window -h -t $session_name
|
else
|
||||||
tmux select-pane -t $session_name:$current_window_num.3
|
tmux send-keys -t $session_name 'for ((i = 0; i < ${#commands_list[@]}; i++)); do echo ${commands_list[$i]}; done'
|
||||||
tmux split-window -h -t $session_name
|
tmux send-keys -t $session_name 'for url in "${urls[@]}"; do echo $url; done'
|
||||||
fi
|
fi
|
||||||
|
|
||||||
tmux select-pane -t $session_name:$current_window_num.$current_panel_num
|
|
||||||
tmux send-keys -t $session_name "$command_to_run" Enter
|
|
||||||
|
|
||||||
((current_panel_num++))
|
|
||||||
done
|
|
||||||
fi
|
fi
|
||||||
|
|||||||
@@ -20,7 +20,7 @@ if [ ${#commands_not_found[@]} -ne 0 ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
cur_dir=`pwd`
|
cur_dir=`pwd`
|
||||||
furry_commission_ideas_path=/mnt/e/home/sync/nextcloud/furry-commission-ideas
|
furry_commission_ideas_path=/mnt/e/home/documents/data-hoarding/furry-commission-ideas
|
||||||
furry_commission_ideas_urls_filename="urls.txt"
|
furry_commission_ideas_urls_filename="urls.txt"
|
||||||
scripts_path=/home/cloud/repos/personal-devboot/scripts/shell
|
scripts_path=/home/cloud/repos/personal-devboot/scripts/shell
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user