Script updates
This commit is contained in:
2
scripts/shell/backup-stuff.sh
Normal file
2
scripts/shell/backup-stuff.sh
Normal file
@@ -0,0 +1,2 @@
|
|||||||
|
# vencord stuff
|
||||||
|
cp '/mnt/c/Users/cloud/AppData/Roaming/Vencord/settings/settings.json' '/mnt/e/home/clouds/google-drive/backup'
|
||||||
3
scripts/shell/ffmpeg-get-video-fps.sh
Executable file
3
scripts/shell/ffmpeg-get-video-fps.sh
Executable file
@@ -0,0 +1,3 @@
|
|||||||
|
#!/bin/bash
|
||||||
|
|
||||||
|
ffmpeg -i $1 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p"
|
||||||
@@ -1,7 +1,7 @@
|
|||||||
#!/bin/bash
|
#!/bin/bash
|
||||||
|
|
||||||
show_help() {
|
show_help() {
|
||||||
echo "Usage: `basename $0` [--input|-i input_file] [--crop|-c width:height] [--trim-start start] [--trim-end end] [--crf crf_value] [--fps new_fps] [--scale640] [--merge-audio] [--remove-audio] --output|-o output_file"
|
echo "Usage: $(basename $0) [--input|-i input_file] [--crop|-c width:height] [--trim-start start] [--trim-end end] [--crf crf_value] [--fps new_fps] [--scale new_video_resolution] [--merge-audio] [--remove-audio] --output|-o output_file"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --input|-i Specify the input video file (required)."
|
echo " --input|-i Specify the input video file (required)."
|
||||||
echo " --crop|-c Specify the width:height for video cropping."
|
echo " --crop|-c Specify the width:height for video cropping."
|
||||||
@@ -9,7 +9,7 @@ show_help() {
|
|||||||
echo " --trim-end Specify the end timestamp for video trimming."
|
echo " --trim-end Specify the end timestamp for video trimming."
|
||||||
echo " --crf Specify the CRF value for video compressing."
|
echo " --crf Specify the CRF value for video compressing."
|
||||||
echo " --fps Specify the new frames per second for the video."
|
echo " --fps Specify the new frames per second for the video."
|
||||||
echo " --scale640 Scale the video to 640x320."
|
echo " --scale Scale the video to a new resolution."
|
||||||
echo " --merge-audio Merge all audio tracks into the main track."
|
echo " --merge-audio Merge all audio tracks into the main track."
|
||||||
echo " --remove-audio Suppress all audio and remove audio tracks."
|
echo " --remove-audio Suppress all audio and remove audio tracks."
|
||||||
echo " --audio-track-no Selects a specific audio track for the output"
|
echo " --audio-track-no Selects a specific audio track for the output"
|
||||||
@@ -23,7 +23,7 @@ remove_audio() {
|
|||||||
ffmpeg -i "$input_file" -an "$output_file"
|
ffmpeg -i "$input_file" -an "$output_file"
|
||||||
}
|
}
|
||||||
|
|
||||||
if ! command -v ffmpeg &> /dev/null; then
|
if ! command -v ffmpeg &>/dev/null; then
|
||||||
echo "Error: 'ffmpeg' command not found. Please install ffmpeg."
|
echo "Error: 'ffmpeg' command not found. Please install ffmpeg."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -34,7 +34,7 @@ trim_start=""
|
|||||||
trim_end=""
|
trim_end=""
|
||||||
crf=""
|
crf=""
|
||||||
new_fps=""
|
new_fps=""
|
||||||
scale640=false
|
scale=""
|
||||||
merge_audio=false
|
merge_audio=false
|
||||||
remove_audio=false
|
remove_audio=false
|
||||||
audio_track_no=1
|
audio_track_no=1
|
||||||
@@ -42,18 +42,54 @@ output_file=""
|
|||||||
|
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--help|-h) show_help; exit ;;
|
--help | -h)
|
||||||
--input|-i) input_file="$2"; shift 2 ;;
|
show_help
|
||||||
--crop|-c) crop="$2"; shift 2 ;;
|
exit
|
||||||
--trim-start) trim_start="$2"; shift 2 ;;
|
;;
|
||||||
--trim-end) trim_end="$2"; shift 2 ;;
|
--input | -i)
|
||||||
--crf) crf="$2"; shift 2 ;;
|
input_file="$2"
|
||||||
--fps) new_fps="$2"; shift 2 ;;
|
shift 2
|
||||||
--scale640) scale640=true; shift ;;
|
;;
|
||||||
--merge-audio) merge_audio=true; shift ;;
|
--crop | -c)
|
||||||
--remove-audio) remove_audio=true; shift;;
|
crop="$2"
|
||||||
--audio-track-no) audio_track_no="$2"; shift;;
|
shift 2
|
||||||
--output|-o) output_file="$2"; shift 2 ;;
|
;;
|
||||||
|
--trim-start)
|
||||||
|
trim_start="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--trim-end)
|
||||||
|
trim_end="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--crf)
|
||||||
|
crf="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--fps)
|
||||||
|
new_fps="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--scale)
|
||||||
|
scale="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
|
--merge-audio)
|
||||||
|
merge_audio=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--remove-audio)
|
||||||
|
remove_audio=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--audio-track-no)
|
||||||
|
audio_track_no="$2"
|
||||||
|
shift
|
||||||
|
;;
|
||||||
|
--output | -o)
|
||||||
|
output_file="$2"
|
||||||
|
shift 2
|
||||||
|
;;
|
||||||
*) shift ;;
|
*) shift ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -68,7 +104,7 @@ if [ -z "$output_file" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -z "$crop" ] && [ -z "$trim_start" ] && [ -z "$trim_end" ] && [ -z "$crf" ] && [ -z "$new_fps" ] && [ "$merge_audio" = false ] && [ "$scale640" = false ] && [ "$remove_audio" = false ]; then
|
if [ -z "$crop" ] && [ -z "$trim_start" ] && [ -z "$trim_end" ] && [ -z "$crf" ] && [ -z "$new_fps" ] && [ "$merge_audio" = false ] && [ -z "$scale" ] && [ "$remove_audio" = false ]; then
|
||||||
echo "Error: At least one optional parameter is required."
|
echo "Error: At least one optional parameter is required."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
@@ -83,8 +119,8 @@ if [ -n "$trim_end" ] && [ -z "$trim_start" ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$crop" ] && [ "$scale640" = true ]; then
|
if [ -n "$crop" ] && [ "$scale" = true ]; then
|
||||||
echo "Error: Cannot use both --crop and --scale640 together."
|
echo "Error: Cannot use both --crop and --scale together."
|
||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -122,15 +158,15 @@ if [ -n "$trim_start" ] && [ -n "$trim_end" ]; then
|
|||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$crf" ]; then
|
if [ -n "$crf" ]; then
|
||||||
ffmpeg_command+=" -c:v libx264 -crf $crf"
|
ffmpeg_command+=" -c:v libx265 -crf $crf"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ -n "$new_fps" ]; then
|
if [ -n "$new_fps" ]; then
|
||||||
ffmpeg_command+=" -r $new_fps"
|
ffmpeg_command+=" -r $new_fps"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$scale640" = true ]; then
|
if [ -n "$scale" ]; then
|
||||||
ffmpeg_command+=" -vf scale=640:320"
|
ffmpeg_command+=" -s $scale"
|
||||||
fi
|
fi
|
||||||
|
|
||||||
if [ "$merge_audio" = true ]; then
|
if [ "$merge_audio" = true ]; then
|
||||||
|
|||||||
@@ -8,4 +8,4 @@ video_res=$(ffprobe -v error -select_streams v:0 -show_entries stream=width,heig
|
|||||||
video_framerate=$(ffmpeg -i $file_to_convert 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p")
|
video_framerate=$(ffmpeg -i $file_to_convert 2>&1 | sed -n "s/.*, \(.*\) fp.*/\1/p")
|
||||||
|
|
||||||
ffmpeg -y -i $file_to_convert -vf palettegen $pallete_file
|
ffmpeg -y -i $file_to_convert -vf palettegen $pallete_file
|
||||||
ffmpeg -y -i $file_to_convert -i $pallete_file -filter_complex paletteuse "${file_to_convert%"$file_to_convert_extension"}.gif"
|
ffmpeg -y -i $file_to_convert -i $pallete_file -filter_complex fps=20,paletteuse "${file_to_convert%".$file_to_convert_extension"}.gif"
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
|
|
||||||
show_help() {
|
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` [--help|-h] [--filter-mode|-f]"
|
echo "Usage: $(basename $0) [--help|-h] [--filter-mode|-f]"
|
||||||
echo "Options:"
|
echo "Options:"
|
||||||
echo " --help | -h (optional) Display script's help text"
|
echo " --help | -h (optional) Display script's help text"
|
||||||
echo " --filter-mode | -f (optional) The script iterate over the files of a selected folder and store the ones that should be deleted"
|
echo " --filter-mode | -f (optional) The script iterate over the files of a selected folder and store the ones that should be deleted"
|
||||||
@@ -11,8 +11,14 @@ show_help() {
|
|||||||
filter_mode=false
|
filter_mode=false
|
||||||
while [ "$#" -gt 0 ]; do
|
while [ "$#" -gt 0 ]; do
|
||||||
case "$1" in
|
case "$1" in
|
||||||
--help|-h) show_help; exit ;;
|
--help | -h)
|
||||||
--filter-mode|-f) filter_mode=true; shift;;
|
show_help
|
||||||
|
exit
|
||||||
|
;;
|
||||||
|
--filter-mode | -f)
|
||||||
|
filter_mode=true
|
||||||
|
shift
|
||||||
|
;;
|
||||||
*) shift ;;
|
*) shift ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
@@ -21,7 +27,7 @@ commands_to_check=(gallery-dl gdl.sh feh xdotool)
|
|||||||
|
|
||||||
commands_not_found=()
|
commands_not_found=()
|
||||||
for command in ${commands_to_check[@]}; do
|
for command in ${commands_to_check[@]}; do
|
||||||
if ! command -v "$command" &> /dev/null; then
|
if ! command -v "$command" &>/dev/null; then
|
||||||
commands_not_found+=("$command")
|
commands_not_found+=("$command")
|
||||||
fi
|
fi
|
||||||
done
|
done
|
||||||
@@ -36,8 +42,8 @@ if [ ${#commands_not_found[@]} -ne 0 ]; then
|
|||||||
exit 1
|
exit 1
|
||||||
fi
|
fi
|
||||||
|
|
||||||
cur_dir=`pwd`
|
cur_dir=$(pwd)
|
||||||
furry_commission_ideas_path=/mnt/e/home/documents/data-hoarding/furry-commission-ideas
|
furry_commission_ideas_path=/mnt/e/home/documents/downloads-furry
|
||||||
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
|
||||||
|
|
||||||
@@ -59,13 +65,13 @@ input_media_url() {
|
|||||||
media_url=''
|
media_url=''
|
||||||
|
|
||||||
if ! $filter_mode; then
|
if ! $filter_mode; then
|
||||||
media_url=`input_media_url`
|
media_url=$(input_media_url)
|
||||||
while [ -z "$media_url" ]; do
|
while [ -z "$media_url" ]; do
|
||||||
media_url=`input_media_url`
|
media_url=$(input_media_url)
|
||||||
done
|
done
|
||||||
|
|
||||||
# remove trailing slashes
|
# remove trailing slashes
|
||||||
media_url=`sed 's:/*$::' <<< "$media_url"`
|
media_url=$(sed 's:/*$::' <<<"$media_url")
|
||||||
|
|
||||||
url_regex='(https?)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]'
|
url_regex='(https?)://[-[:alnum:]\+&@#/%?=~_|!:,.;]*[-[:alnum:]\+&@#/%=~_|]'
|
||||||
if [[ ! $media_url =~ $url_regex ]]; then
|
if [[ ! $media_url =~ $url_regex ]]; then
|
||||||
@@ -83,8 +89,8 @@ filtered_existing_folders=()
|
|||||||
# removing artists folder depth 2 only
|
# removing artists folder depth 2 only
|
||||||
for folder in "${existing_folders[@]}"; do
|
for folder in "${existing_folders[@]}"; do
|
||||||
if [[ ! $folder =~ ^artists/[^/]+$ ]]; then
|
if [[ ! $folder =~ ^artists/[^/]+$ ]]; then
|
||||||
filtered_existing_folders+=( "$folder" )
|
filtered_existing_folders+=("$folder")
|
||||||
fi;
|
fi
|
||||||
done
|
done
|
||||||
|
|
||||||
existing_folders=("${filtered_existing_folders[@]}")
|
existing_folders=("${filtered_existing_folders[@]}")
|
||||||
@@ -117,9 +123,9 @@ input_select_folder() {
|
|||||||
read -p "[INFO] Please inform the desired option: " selected_option
|
read -p "[INFO] Please inform the desired option: " selected_option
|
||||||
|
|
||||||
if [ "$selected_option" == 'n' ]; then
|
if [ "$selected_option" == 'n' ]; then
|
||||||
selected_folder=`input_create_folder`
|
selected_folder=$(input_create_folder)
|
||||||
while [ -z "$selected_folder" ]; do
|
while [ -z "$selected_folder" ]; do
|
||||||
selected_folder=`input_create_folder`
|
selected_folder=$(input_create_folder)
|
||||||
done
|
done
|
||||||
|
|
||||||
mkdir --parents "$selected_folder"
|
mkdir --parents "$selected_folder"
|
||||||
@@ -142,9 +148,9 @@ if [ -z "$selected_folder" ]; then
|
|||||||
|
|
||||||
printf "\n"
|
printf "\n"
|
||||||
|
|
||||||
selected_folder=`input_select_folder`
|
selected_folder=$(input_select_folder)
|
||||||
while [ -z "$selected_folder" ]; do
|
while [ -z "$selected_folder" ]; do
|
||||||
selected_folder=`input_select_folder`
|
selected_folder=$(input_select_folder)
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|
||||||
@@ -154,11 +160,11 @@ function confirm() {
|
|||||||
while true; do
|
while true; do
|
||||||
read -n 1 yn
|
read -n 1 yn
|
||||||
case $yn in
|
case $yn in
|
||||||
[Yy]* ) return 0;;
|
[Yy]*) return 0 ;;
|
||||||
[Nn]* ) return 1;;
|
[Nn]*) return 1 ;;
|
||||||
[Uu]* ) return 2;;
|
[Uu]*) return 2 ;;
|
||||||
[Cc]* ) exit;;
|
[Cc]*) exit ;;
|
||||||
* ) echo "Please answer YES, NO, or CANCEL.";;
|
*) echo "Please answer YES, NO, or CANCEL." ;;
|
||||||
esac
|
esac
|
||||||
done
|
done
|
||||||
}
|
}
|
||||||
@@ -170,14 +176,14 @@ escape_string() {
|
|||||||
# Iterate over each character in the input string
|
# Iterate over each character in the input string
|
||||||
while IFS= read -r -n1 char; do
|
while IFS= read -r -n1 char; do
|
||||||
case "$char" in
|
case "$char" in
|
||||||
' '|'\'|'$'|'`'|'!'|'&'|'|'|';'|'<'|'>'|'"'|"'"|'*'|'?'|'['|']'|'{'|'}'|'('|')'|'#')
|
' ' | '\' | '$' | '`' | '!' | '&' | '|' | ';' | '<' | '>' | '"' | "'" | '*' | '?' | '[' | ']' | '{' | '}' | '(' | ')' | '#')
|
||||||
escaped="${escaped}\\${char}"
|
escaped="${escaped}\\${char}"
|
||||||
;;
|
;;
|
||||||
*)
|
*)
|
||||||
escaped="${escaped}${char}"
|
escaped="${escaped}${char}"
|
||||||
;;
|
;;
|
||||||
esac
|
esac
|
||||||
done <<< "$input"
|
done <<<"$input"
|
||||||
|
|
||||||
echo "$escaped"
|
echo "$escaped"
|
||||||
}
|
}
|
||||||
@@ -200,12 +206,12 @@ if $filter_mode; then
|
|||||||
|
|
||||||
files_to_delete=()
|
files_to_delete=()
|
||||||
files_count=${#files[@]}
|
files_count=${#files[@]}
|
||||||
for ((i = 0; i < files_count;)); do
|
for ((i = 0; i < files_count; )); do
|
||||||
file="${files[$i]}"
|
file="${files[$i]}"
|
||||||
file="${file#./}"
|
file="${file#./}"
|
||||||
|
|
||||||
echo ""
|
echo ""
|
||||||
echo "($((i+1))/${files_count}) File: $file"
|
echo "($((i + 1))/${files_count}) File: $file"
|
||||||
echo -n "Should this file be deleted? (y/n): "
|
echo -n "Should this file be deleted? (y/n): "
|
||||||
|
|
||||||
confirm
|
confirm
|
||||||
@@ -218,10 +224,9 @@ if $filter_mode; then
|
|||||||
files_to_delete+=("$file")
|
files_to_delete+=("$file")
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
1)
|
1) ;;
|
||||||
;;
|
|
||||||
2)
|
2)
|
||||||
if (( i - 1 < 0 )); then
|
if ((i - 1 < 0)); then
|
||||||
echo ""
|
echo ""
|
||||||
echo ""
|
echo ""
|
||||||
echo "Can't undo because this is the first image"
|
echo "Can't undo because this is the first image"
|
||||||
@@ -229,7 +234,7 @@ if $filter_mode; then
|
|||||||
else
|
else
|
||||||
((i--))
|
((i--))
|
||||||
xdotool search --name feh key p
|
xdotool search --name feh key p
|
||||||
files_to_delete=("${files_to_delete[@]/$file}")
|
files_to_delete=("${files_to_delete[@]/$file/}")
|
||||||
continue
|
continue
|
||||||
fi
|
fi
|
||||||
;;
|
;;
|
||||||
@@ -282,10 +287,9 @@ else
|
|||||||
media_filenames+=$(basename "$filename")
|
media_filenames+=$(basename "$filename")
|
||||||
done
|
done
|
||||||
|
|
||||||
|
|
||||||
for ((i = 0; i < ${#media_filenames[@]}; i++)); do
|
for ((i = 0; i < ${#media_filenames[@]}; i++)); do
|
||||||
media_filename=${media_filenames[$i]}
|
media_filename=${media_filenames[$i]}
|
||||||
|
|
||||||
echo "$media_filename: $media_url" >> $furry_commission_ideas_urls_filename
|
echo "$media_filename: $media_url" >>$furry_commission_ideas_urls_filename
|
||||||
done
|
done
|
||||||
fi
|
fi
|
||||||
|
|||||||
Reference in New Issue
Block a user