mirror of
https://github.com/winneon/gsu.git
synced 2026-09-10 07:16:25 -04:00
general: added a check for file extensions
This commit is contained in:
parent
c168f8c2c9
commit
808e3fd13b
43
gsu
43
gsu
|
|
@ -267,6 +267,22 @@ log() {
|
|||
echo "$1" >"$config_path/logs/$(date +'%Y.%m.%d-%H.%M.%S.%N').log"
|
||||
}
|
||||
|
||||
check_valid_exts() {
|
||||
local filename="${operand##*/}"
|
||||
local extension="${filename##*.}"
|
||||
|
||||
IFS="," read -ra exts <<< "$1"
|
||||
|
||||
for ext in "${exts[@]}"; do
|
||||
if [[ "$extension" == "$ext" ]]; then
|
||||
return
|
||||
fi
|
||||
done
|
||||
|
||||
echo "gsu: invalid $type file extension -- '$extension'"
|
||||
exit 1
|
||||
}
|
||||
|
||||
take_screenshot() {
|
||||
if ! type -p maim >/dev/null; then
|
||||
print_missing_deps "maim"
|
||||
|
|
@ -432,9 +448,30 @@ main() {
|
|||
set_type "screenshot"
|
||||
|
||||
case "$type" in
|
||||
"screenshot") take_screenshot ;;
|
||||
"video") take_video ;;
|
||||
"gif") take_video; make_gif ;;
|
||||
"screenshot")
|
||||
if [[ -z "$S_UPLOAD" ]]; then
|
||||
check_valid_exts "png,jpg"
|
||||
fi
|
||||
|
||||
take_screenshot
|
||||
;;
|
||||
|
||||
"video")
|
||||
if [[ -z "$V_UPLOAD" ]]; then
|
||||
check_valid_exts "mp4,mkv,mov"
|
||||
fi
|
||||
|
||||
take_video
|
||||
;;
|
||||
|
||||
"gif")
|
||||
if [[ -z "$G_UPLOAD" ]]; then
|
||||
check_valid_exts "gif"
|
||||
fi
|
||||
|
||||
take_video
|
||||
make_gif
|
||||
;;
|
||||
esac
|
||||
|
||||
if [[ ! -z "$upload" ]]; then
|
||||
|
|
|
|||
Loading…
Reference in a new issue