-
Notifications
You must be signed in to change notification settings - Fork 0
/
volaupload.sh
executable file
·546 lines (502 loc) · 20.3 KB
/
volaupload.sh
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
#!/usr/bin/env bash
# shellcheck disable=SC2153,SC1117
# shellcheck disable=SC2034
__VOLAUPLOADSH_VERSION__=3.3
if ! OPTS=$(getopt --options hr:cn:p:u:a:f:t:wmvb: \
--longoptions help,room:,call,nick:,pass:,room-pass:,upload-as:,force-server:,retries:,watch,most-new,vanned,server-blacklist \
-n 'volaupload.sh' -- "$@") ; then
echo -e "\nFailed while parsing options.\n" ; exit 1
fi
if [[ -f "$HOME/.volascriptsrc" ]]; then
#shellcheck disable=SC1090
source "$HOME/.volascriptsrc"
fi
#Remove space from IFS so we can upload files that contain spaces.
#I use little hack here, I replaced default separator from space to
#carrige return so we can iterate over the TARGETS variable without
#a fear of splitting filenames.
IFS=$'\r'
if [ -z "$TMPDIR" ]; then
TMP="/tmp"
else
TMP="${TMPDIR%/}"
fi
genRandNumber() {
head -c"$1" <(tr -dc '[:alnum:]' < /dev/urandom)
}
declare -r SERVER="https://volafile.org"
declare COOKIE; COOKIE="$TMP/cuckie_$(genRandNumber 6)"
declare LAST_ERROR; LAST_ERROR="$TMP/error_$(genRandNumber 6)"
declare PART; PART="$TMP/filepart_$(genRandNumber 6)"
declare STUFF
declare -r RETRIES="3"
#Return non zero value when script gets interrupted with Ctrl+C or some error occurs
# and remove the intermediate files
handle_exit() {
trap - SIGHUP SIGINT SIGTERM EXIT
local failure
local exit_code="$1"
if [[ "$exit_code" == "" ]]; then
echo -e "\n\033[0mProgram interrupted by user."
exit_code=10
fi
for failure in "${@:2}"; do
echo -e "\033[31m$failure\033[0m" >&2
done; rm -rf "$COOKIE" "$LAST_ERROR" "$STUFF" "$PART"
if [[ $exit_code -eq 0 ]]; then
local current; current="$(date "+%s")"
echo -en "Uploading completed in "
TZ='' date -d "@$((current-upload_start))" "+%H hours, %M minutes and %S seconds."
fi; exit "$exit_code"
}
contains_element () {
local e match="$1"
shift
for e; do [[ "$e" == "$match" ]] && return 0; done
return 1
}
getUploadServers() {
local -i server_counter=1
local -a ulServers
while [[ $server_counter -lt 12 ]]; do
if curl -sLIm 3 "https://dl${server_counter}.volafile.org" > /dev/null 2>&1; then
ulServers+=("${server_counter}")
fi
((server_counter++))
done
# shellcheck disable=SC2178
ulServers="$(declare -p ulServers)"
local IFS=$'\v';
echo "${ulServers#*=}"
}
print_help() {
cat >&2 << EOF
volaupload.sh help page
Upload files or whole directories to volafile. Every argument that is
not prepended with any option will be treated as upload target.
-h, --help
Show this help message.
-r, --room <room_name>
Specifiy upload room. (This plus at least one upload target is the only
required option to upload something).
-c, --call <method> <query>
Make Rest API call.
-n, --nick <name>
Specify name, under which your file(s) will be uploaded.
-p, --pass <password>
Set your account password. If you upload as logged user, file
uploads will count towards your file statistics on Volafile.
See https://volafile.org/user/<your_username>
-u, --room-pass <password>
You need to specify this only for password protected rooms.
-a, --upload-as <renamed_file>
Upload file with custom name. (It won't overwrite the filename in your
fielsystem). You can upload multiple renamed files.
Example:
volaupload.sh -r BEEPi file1.jpg file2.png -a funny.jpg -a nasty.png
First occurence of -a parameter always renames first given file and so on.
-f, --force-server <server_number>
Force uploading to a specific server because not all of them are equal.
-b, --server-blacklist <1,2,3..N>
Comma separated lists of servers we don't want to talk about right now.
Uploads will go to any server that isn't on said list.
-t, --retries <number>
Specify number of retries when upload fails. Defaults to 3.
You can't retry more than 9 times.
-w, --watch <directory>
Makes your script watch over a specific directory. Every file added
to that directory will be uploaded to Volafile. (To exit press Ctrl+C)
-m, --most-new <directory>
Uploads only the first file that was recently modified in specified directory
-v, --vanned
V& mode. After specifying this option, each consecutive file that manages to
upload will be removed from your storage. This command delete the directories too,
so watch out!
EOF
exit 0
}
eval set -- "$OPTS"
while true; do
case "$1" in
-h | --help) print_help ; shift ;;
-r | --room)
if ROOM="$(echo "$2" | grep -oP "/r/\\K[a-zA-Z0-9_-]+$")"; then
shift 2; continue
fi
if ROOM="$(echo "$2" | grep -oP "^[a-zA-Z0-9_-]+$")"; then
shift 2; continue
fi
handle_exit "2" "Sorry my dude, but your room ID doesn't match Volafile's format!\n" ;;
-c | --call) CALL="true"; shift ;;
-n | --nick) NICK="$2"; shift 2 ;;
-p | --pass) PASSWORD="$2"; shift 2 ;;
-u | --room-pass) ROOMPASS="$2"; shift 2 ;;
-a | --upload-as) RENAMES+=("$2"); shift 2 ;;
-f | --force-server) UL_SERVER="$2"
eval declare -a UL_SERVERS="$(getUploadServers)"
if ! contains_element "$UL_SERVER" "${UL_SERVERS[@]}"; then
IFS=$','; handle_exit "9" "Server you wanted force upload to doesn't exist." \
"Possible servers are: ${UL_SERVERS[*]// /|}"
fi; shift 2 ;;
-b | --server-blacklist) echo "$UL_SERVERS"
if [[ -n "$UL_SERVERS" ]]; then
handle_exit "12" "Don't use this option with server forcing, its pointless.\n"
fi; eval declare -a UL_SERVERS="$(getUploadServers)"
IFS=',' read -ra BLACKLIST <<< "$2"; shift 2 ;;
-t | --retries) RETRIES="$2"
if ! [[ "$RETRIES" =~ ^[0-9]$ ]] || [[ "$RETRIES" -lt 0 ]]; then
handle_exit "3" "You wanted to set negative number of retries or ..." \
"... exceeded maximum retry count.\n"
fi ; shift 2 ;;
-w | --watch) WATCHING="true"; shift ;;
-m | --most-new) NEWEST="true"; shift ;;
-v | --vanned) ANTIRAID="true"; shift ;;
--) shift;
until [[ -z "$1" ]]; do
TARGETS+=("$1") ; shift
done ; break ;;
* ) shift ;;
esac
done
trap 'handle_exit "0"' EXIT
trap 'handle_exit "1"' SIGHUP SIGTERM
trap handle_exit SIGINT
#remove cookie on server error to get fresh session for next upload
skip() {
local omit
for omit in "$@"; do
echo -e "\033[31m$omit\033[0m" >&2
done; rm -f "$COOKIE"
}
if [[ $(type curlbar 2>/dev/null) ]]; then
# we can silence the progressbar if we use curlbar
# since we can create our own through trace-ascii option
declare cURL="curlbar"
declare silence="sS"
else
declare cURL="curl"
declare silence=""
fi
extract() {
local line b _key="$2"
echo "$1" | (while read -r line; do
b="$(echo "$line" | cut -d'=' -f1)"
if [[ "$b" == "$_key" ]]; then
printf "%s" "$line" | cut -d'=' -f2
return
fi
done)
}
trim() {
local var="$*"
var="${var#"${var%%[![:space:]]*}"}" # remove leading whitespace characters
var="${var%"${var##*[![:space:]]}"}" # remove trailing whitespace characters
printf '%s' "$var"
}
counter() {
# 1st variable is number that is replaced with '##' placeholder
# 2nd and later variables are text with '##' placeholder
# line with placeholder will be printed 1stvar-times on the same line
# placeholder can only be used once
local -i count=$1; local line; local -i position; local -i i=0; local -a a
local IFS=$'\n'
while read -r line; do a+=("${line#"${line%%[![:space:]]*}"}"); done < <(echo -e "${@:2}")
for line in "${a[@]}"; do
if [[ $line =~ '##' ]]; then
echo >&2; position="$i"
else
printf "%s\n" "$line" >&2; ((i++))
fi
done
i=$(( ${#a[@]} - position - 1 ))
echo -ne "\033[${i}A" >&2
while [[ $count -ge 0 ]]; do
echo -en "\033[0G${a[$position]//\#\#/$count}\033[0K" >&2; ((--count)); sleep 1
done; echo -ne "\033[0G\033[$(( ${#a[@]} - i ))A\033[0J\033[0m" >&2
}
makeApiCall() {
local method="$1"
local query="$2"
local room="$3"
local name="$4"
local password="$5"
local server="$6"
local cookie=""
local serv="$SERVER"
if [[ -n "$room" ]]; then
local ref="Referer: ${SERVER}/r/${room}"
else
local ref="Referer: ${SERVER}"
fi
if [[ -n "$name" ]] && [[ -n "$password" ]]; then
#session "memoization"
if [[ ! -f "$COOKIE" ]]; then
curl -sS1L -H "Origin: ${SERVER}" -H "$ref" -H "Accept: text/values" \
"${SERVER}/rest/login?name=${name}&password=${password}" 2>"$LAST_ERROR" | \
cut -d$'\n' -f1 > "$COOKIE"
fi
cookie="$(head -qn 1 "$COOKIE")"
if [[ "$cookie" == "error.code=403" ]]; then
return 101
fi
fi
[[ -n "$server" ]] && serv="$server"
curl -sS1fL -b "$cookie" -H "Origin: ${SERVER}" -H "$ref" -H "Connection: close" \
-H "Accept: text/values" "${serv}/rest/${method}?${query}" 2>"$LAST_ERROR"
}
volapost() {
IFS=""; $cURL -"${silence}"1fL -H "Origin: $SERVER" -H "Referer: $SERVER/r/$1" \
-H "Connection: close" -F "file=@\"$2\"$3" "${4}/upload?room=${1}${*:5}" 1>/dev/null
}
doUpload() {
trap 'handle_exit "1"' SIGHUP SIGTERM
trap handle_exit SIGINT
local file="$1"
local room="$2"
local name="$3"
local pass="$4"
local roompass="$5"
local renamed="$6"
local response replace
local error lerr
if [[ -n "$name" ]] && [[ -n "$pass" ]]; then
response=$(makeApiCall getUploadKey "name=$name&room=$room" "$room" "$name" "$pass")
else
#If user didn't specify name, default it to Volaphile.
[[ -z "$name" ]] && name="Volaphile"
response=$(makeApiCall getUploadKey "name=$name&room=$room" "$room")
fi
error="$?"; lerr="$(trim "$(cat "$LAST_ERROR")")"
case "$error" in
0 ) ;;
6 ) echo "106"; echo "Check your interwebz connection, my friendo!"
echo "Either that, or volafile is dead.#"; return ;;
101) echo "101"; echo "Login Error: You used wrong login and/or password my dude."
echo "You wanna login properly, so those sweet volastats can stack up!#"; return;;
* ) ;;
esac
error=$(extract "$response" "error.code")
if [[ "$error" == "429" ]] ; then
echo "103"; echo "$(extract "$response" "error.info.timeout")#"; return
elif [[ $(echo "$lerr" | cut -d$' ' -f8) == "429" ]]; then
echo "103"; echo "14000#"; return
elif [[ -n "$error" ]] || [[ -n "$lerr" ]]; then
echo "104"; echo -e "Error number $error\nStuff from cURL: $lerr"
echo -e "$(extract "$response" "error.message")#"; return
fi
local server server_short
server="$(extract "$response" server)"; server_short=$(echo -ne "$server" | grep -oP "dl\K(\d+)")
if [[ -n "$UL_SERVER" ]]; then
if [[ ! "$UL_SERVER" == "$server_short" ]]; then
echo "107#"; return
fi
fi
if [[ -n ${BLACKLIST+x} ]]; then
for i in "${BLACKLIST[@]}"; do
if ! contains_element "$i" "${UL_SERVERS[@]}"; then
IFS=$','; echo "109"; echo "$i: Invalid server."
echo "Server you wanted omit uploading to doesn't exist." \
"Available servers: ${UL_SERVERS[*]// /|}#"; return
fi
if [[ "$i" == "$server_short" ]]; then
echo "108#"; return
fi
done
fi
local key; key="&key=$(extract "$response" key)"
local file_id; file_id=$(extract "$response" file_id)
local up_str; local startAT; local mainfile="$file"
[[ -n "$roompass" ]] && roompass="&password=$roompass"
up_str="\033[32m<\033[38;5;22m/\\\\\033[32m> Uploading \033[1m$(basename "$file")\033[22m"
up_str+=" to \033[1m$ROOM, $(echo "$server" | cut -f1 -d'.')\033[22m as \033[1m$name\033[22m\033[33m"
server="https://$server"
# -f option makes curl return error 22 on server responses with code 400 and higher
echo -e "$up_str" >&2
if [[ -n "$renamed" ]]; then
#curlbar prints stuff to stderr so we change color in that descriptor
echo -e "-> File renamed to: \033[1m${renamed}\033[22m" >&2
replace=";filename=\"${renamed}\""
fi
while true; do
printf "\033[33m" >&2
if [[ -n "$silence" ]]; then
volapost "$room" "$file" "$replace" "$server" "$key" "$roompass" "$startAT" 3>"$LAST_ERROR"
else
volapost "$room" "$file" "$replace" "$server" "$key" "$roompass" "$startAT" 2> >(tee "$LAST_ERROR" >&2)
fi; error="$?"; lerr="$(trim "$(cat "$LAST_ERROR")")"
if [[ "$error" -eq 22 ]] && grep -q "50[23]" "$LAST_ERROR"; then
response=$(makeApiCall uploadStatus "room=$room$key" "$room" "" "" "$server")
error="$?"; lerr="$(trim "$(cat "$LAST_ERROR")")"
[[ $(extract "$response" ended) == "true" ]] && break
local recv_bytes; recv_bytes=$(extract "$response" receivedBytes)
printf "\n\033[35mResuming upload at the %sth byte from the beginning of the file... \033[0m\n" "$recv_bytes" >&2
startAT="&startAt=$recv_bytes"
[[ ! -d "$PART" ]] && { mkdir -p "$PART"; file="$PART/$(basename "$mainfile")"; }
dd bs="$recv_bytes" skip=1 if="$mainfile" of="$file" 2>/dev/null
continue
fi; break
done; [[ -d "$PART" ]] && { rm -rf "$PART"; sync; }
case $error in
0 | 1 | 102) #Replace spaces with %20 so my terminal url finder can see links properly.
if [[ $error -eq 102 ]]; then
printf "\033[33mFile was too small to make me bothered with printing the progress bar.\033[0m\n" >&2
fi
[[ -n "$renamed" ]] && file="$renamed"
file=$(basename "$file" | sed -r "s/ /%20/g" )
printf "\n\033[35mVola direct link:\033[0m\n" >&2
printf "\033[1m%s/get/%s/%s\033[0m\n\n" "$SERVER" "$file_id" "$file" >&2 ;;
* ) skip "\n$lerr\n" ;;
esac
echo "${error}#"
}
tryUpload() {
trap 'handle_exit "1"' SIGHUP SIGTERM
trap handle_exit SIGINT
local -i i=0
while ((i<RETRIES)); do
# first argument of 'handle' is error code
# second and later arguments are whatever
{ local IFS=$'\n'; read -r -d'#' -a handle
if [[ ${handle[0]} == "0" ]] || [[ ${handle[0]} == "1" ]] \
|| [[ ${handle[0]} == "102" ]]; then
return
elif [[ ${handle[0]} == "101" ]] || [[ ${handle[0]} == "104" ]] \
|| [[ ${handle[0]} == "105" ]] || [[ ${handle[0]} == "106" ]] || \
[[ ${handle[0]} == "109" ]]; then
handle_exit "${handle[@]}"
elif [[ ${handle[0]} == "103" ]]; then
local penalty
penalty="$(bc <<< "(${handle[1]}/1000)+1")"
counter "$penalty" "\033[33mToo many key requests, hotshot. Gotta wait ## seconds now...\n"
elif [[ ${handle[0]} == "107" ]]; then
counter "3" "\033[33mRetrying in ## seconds until we force upload to dl${UL_SERVER} server.\n"
((--i))
elif [[ ${handle[0]} == "108" ]]; then
counter "3" "\033[33mRetrying in ## seconds until we reach non-blacklisted server.\n"
((--i))
else
counter "5" "\033[33mcURL error nr ${handle[0]} happend.\n" \
"Retrying upload after ## seconds ...\n"
fi
} < <(doUpload "$1" "$2" "$3" "$4" "$5" "$6")
((++i))
done
handle_exit "8" "Exceeded maximum number of retries... Closing script."
}
getExtension() {
if [[ "${2##*.}" == "$2" ]]; then
printf "%s" "$1"
else
printf "%s" "${1%%.*}.${2##*.}"
fi
}
declare -i argc
argc=${#TARGETS[@]}
if [[ -z "$ROOM" ]]; then
handle_exit "11" "I don't have any room I can upload to! Use -r option, brah.\n"
fi
if [[ $argc -eq 0 ]]; then
handle_exit "4" "You didn't specify any files that can be uploaded!\n"
elif [[ $argc == 2 ]] && [[ -n "$CALL" ]]; then
set -f ; set -- "${TARGETS[@]}"
declare -i error
makeApiCall "$1" "$2"; error="$?"
if [[ "$error" -ne 0 ]]; then
handle_exit "$?" "cURL error of code $error happend."
fi
handle_exit "10"
fi
if [[ ${#ROOM_ALIASES[@]} -gt 0 ]]; then
for a in "${ROOM_ALIASES[@]}"; do
if [[ "$ROOM" == "$(echo "$a" | cut -d'=' -f1)" ]]; then
ROOM="$(echo "$a" | cut -d'=' -f2)"; break
fi
done
fi
if [[ -n "$ROOM" ]] ; then
if ! ROOM=$(curl -fsLH "Referer: $SERVER" -H "Accept: text/values" \
"$SERVER/r/$ROOM" | grep -oP "\"room_id\s*\"\s*:\s*\"\K[a-zA-Z0-9_-]+(?=\",)"); then
handle_exit "5" "Room you specified doesn't exist, or Vola is busted for good this time!\n"
fi
fi
upload_start="$(date "+%s")"
if [[ -z "$NICK" ]] && [[ -n "$PASSWORD" ]]; then
handle_exit "4" "Specifying password, but not a username? What are you? A silly-willy?\n"
elif [[ -n "$WATCHING" ]] && [[ -n "$ROOM" ]] && [[ $argc == 1 ]]; then
if ! type inotifywait > /dev/null 2>&1; then
handle_exit "6" "Please install inotify-tools package in order to use this feature.\n"
fi
TARGET=$(echo "${TARGETS[0]}" | tr -d "\r")
if [[ -d "$TARGET" ]]; then
declare stop_double_upload=""
inotifywait -m -e moved_to -e create --format '%w%f' "$TARGET" | \
while read -r dir file; do
if [[ $stop_double_upload != "${dir}${file}" ]]; then
tryUpload "${dir}${file}" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS"
fi
stop_double_upload="${dir}${file}"
done
else
handle_exit "7" "You have to specify the directory that can be watched.\n"
fi
elif [[ $argc -gt 0 ]] && [[ -z "$WATCHING" ]] && [[ -z "$CALL" ]]; then
set -- "${RENAMES[@]}"
for t in "${TARGETS[@]}" ; do
if [[ -d "$t" ]] && [[ -n "$NEWEST" ]]; then
file=$(find "$t" -maxdepth 1 -type f -printf '%T@ %p\n' \
| sort -n | tail -n1 | cut -d' ' -f2-)
if [[ -n "$1" ]]; then
tryUpload "$file" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS" "$(getExtension "$1" "$file")"
else
tryUpload "$file" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS"
fi
elif [[ -d "$t" ]]; then
shopt -s globstar
GLOBIGNORE=".:.."
for f in "${t}"/** ; do
if [[ -f "$f" ]] && [[ -n "$1" ]]; then
tryUpload "${f}" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS" "$(getExtension "$1" "$f")" ; shift
elif [[ -f "$f" ]]; then
tryUpload "${f}" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS"
fi
if [[ -f "$f" ]] && [[ -n "$ANTIRAID" ]]; then
rm -rf "$f"
echo -e "\033[33;1m${f}\033[22m: Purged this bad boi...\033[0m\n" >&2
fi
done
if [[ -d "$t" ]] && [[ -n "$ANTIRAID" ]]; then
rm -rf "$t"
echo -e "\033[33;1m${t}\033[22m: Purged this directory...\033[0m\n" >&2
fi
elif [[ -f "$t" ]] && [[ -n "$1" ]]; then
tryUpload "$t" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS" "$(getExtension "$1" "$t")" ; shift
if [[ -n "$ANTIRAID" ]]; then
rm -rf "$t"
echo -e "\033[33;1m${t}\033[22m: Purged this bad boi...\033[0m\n" >&2
fi
elif [[ -f "$t" ]] ; then
tryUpload "$t" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS"
if [[ -n "$ANTIRAID" ]]; then
rm -rf "$t"
echo -e "\033[33;1m${t}\033[22m: Purged this bad boi...\033[0m\n" >&2
fi
elif [[ "$(readlink "$t")" == "pipe:"* ]]; then
STUFF="$(mktemp)"
cat "$t" > "$STUFF"
while read -r line; do
rename=$(echo "$line" | tr -s " ")
if [[ -n "$rename" ]]; then
break
fi
done < "$STUFF"
[[ -n "$1" ]] && rename="$1"
tryUpload "$STUFF" "$ROOM" "$NICK" "$PASSWORD" "$ROOMPASS" "$rename"
else
echo -e "\n\033[33;1m${t}\033[22m: This argument isn't a file or a directory. Skipping ...\033[0m\n" >&2
echo -e "Use -h or --help to check program usage.\n" >&2
shift
fi
done
else
print_help
fi