-
Notifications
You must be signed in to change notification settings - Fork 17
/
Copy pathdosya_yukle2
executable file
·259 lines (228 loc) · 6.99 KB
/
dosya_yukle2
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
#!/usr/bin/env bash
#
# uguush - upload to uguu.se, teknik.io and 0x0.st
# milisarge-milislinux
## CONFIGURATION
# colors
n="$(tput sgr0)"
r="$(tput setaf 1)"
g="$(tput setaf 2)"
# screenshot utility
fshot='maim --hidecursor'
#fshot='scrot'
sshot='maim -s --hidecursor'
#sshot='scrot -s'
wshot="maim -i $(xprop -root _NET_ACTIVE_WINDOW | grep -o '0x.*') --hidecursor"
#wshot='scrot -s'
# default delay
secs='0'
# image host
usehost='uguu'
hosts='uguu teknik 0x0 mixtape ptpb maxfile lewd'
shorteners='waaai 0x0 ptpb'
## EXIT IF NO ARGUMENTS ARE FOUND
if [ $# -lt 1 ]; then
echo '`uguush` requires an argument. Run `uguush -h` for help.'
exit 1
fi
## FUNCTIONS
depends() {
if ! type xclip &> /dev/null; then
echo >&2 "xclip... [${r}YOK${n}]"
exit 1
fi
}
usage() {
cat <<-HELP
uguush - upload to various file hosts
Usage:
$(basename "${0}") [options]
Options:
-d Delay the screenshot by the specified number of seconds.
-f Take a fullscreen screenshot.
-h Show this help message.
-o Select a host to use. Can be uguu, teknik, 0x0, ptpb, maxfile, mixtape or lewd.
-p <path> Custom path to save the image to. Saves the image as "%Y-%m-%d %H-%M-%S.png".
-s Take a selection screenshot.
-u <file> Upload a file.
-x Do not notify dbus, update the log, or modify the clipboard.
-w Take a screenshot of the current window.
-S Select a shortener to use. Can be waaai, ptpb, or 0x0.
-l <url> Upload the provided url.
HELP
}
delay() {
for (( i=secs; i > 0; --i )) ; do
echo "${i}..."
sleep 1
done
}
screenshot() {
if [ "${ful}" ]; then
FILE="$(mktemp --suffix=.png)"
${fshot} "${FILE}"
elif [ "${sel}" ]; then
FILE="$(mktemp --suffix=.png)"
${sshot} "${FILE}" &> /dev/null
if ! [ -s "${FILE}" ]; then
$(rm "${FILE}" 2> /dev/null)
exit
fi
elif [ "${win}" ]; then
FILE="$(mktemp --suffix=.png)"
${wshot} "${FILE}"
elif [ "${lnk}" ]; then
if [ -f "/usr/share/mime/globs" ]; then
urlext="$(curl -sf --head "${url}" | grep 'Content-Type: ' | head -1 | grep -Po '(?<=\ )[^\;]*')"
urlext="$(echo "${urlext}" | sed -e "s/\\r//")"
urlext="$(cat /usr/share/mime/globs | grep "${urlext}" | sort -r | head -1 | grep -Po '(?<=\.)[^\n]*')"
else
urlext="$(basename ${url})"
urlext=${urlext#*.}
fi
FILE="$(mktemp --suffix=.${urlext})"
$(curl -sf "${url}" > "${FILE}")
fi
}
upload() {
for (( i = 1; i <= 3; i++ )); do
printf %s "Seçenek #${i}... "
case "${usehost}" in
teknik) upurl='https://api.teknik.io/v1/Upload' ;;
0x0) upurl='https://0x0.st/' ;;
uguu) upurl='https://uguu.se/api.php?d=upload-tool' ;;
ptpb) upurl='https://ptpb.pw/' ;;
maxfile) upurl='https://maxfile.ro/static/upload.php' ;;
mixtape) upurl='https://mixtape.moe/upload.php' ;;
lewd) upurl='https://lewd.se/api.php?d=upload-tool' ;;
esac
case "${useshortener}" in
waaai) shorturl='https://api.waa.ai/shorten' ;;
0x0) shorturl='http://0x0.st/' ;;
ptpb) shorturl='https://ptpb.pw/u'
esac
if [ "${upurl}" = 'unsupported' ]; then
echo "[${r}FAILED${n}]"
echo "${usehost} doesn't support $([ "${https}" ] && echo HTTPS || echo HTTP)."
exit 1
else
if [ "${usehost}" = 'uguu' ]; then
result="$(curl -sf -F file="@${FILE}" "${upurl}")"
elif [ "${usehost}" = '0x0' ]; then
result="$(curl -sf -F file="@${FILE}" "${upurl}")"
elif [ "${usehost}" = 'teknik' ]; then
result="$(curl -sf -F file="@${FILE}" "${upurl}")"
result="${result##*url\":\"}"
result="${result%%\"*}"
elif [ "${usehost}" = 'mixtape' ]; then
result="$(curl -sf -F files[]="@${FILE}" "${upurl}")"
result="$(echo "${result}" | grep -Eo '"url":"[A-Za-z0-9]+.*",' | sed 's/"url":"//;s/",//')"
result="$(echo "${result//\\\//\/}")"
elif [ "${usehost}" = 'ptpb' ]; then
result="$(curl -sf -F c="@${FILE}" "${upurl}")"
result="${result##*url: }"
result="${result%%$'\n'*}"
elif [ "${usehost}" = 'maxfile' ]; then
result="$(curl -sf -F files[]="@${FILE}" "${upurl}")"
result="$(echo "${result}" | grep -Eo '"url":"[A-Za-z0-9]+.*",' | sed 's/"url":"//;s/",//')"
result="$(echo "https://d.maxfile.ro/${result}")"
elif [ "${usehost}" = 'lewd' ]; then
result="$(curl -sf -F file="@${FILE}" "${upurl}")"
fi
if [ "${useshortener}" = 'waaai' ]; then
tempresult="$(curl -sf -F url="${result}" "${shorturl}")"
code="${tempresult##*short_code\":\"}"
code="${code%%\"*}"
result="https://waa.ai/${code}"
extension="${tempresult##*extension\":}"
extension="${extension%%\}*}"
if [ "${extension}" != "false" ]; then
extension=${extension##\"}
extension=${extension%%\"}
result="${result}.${extension}"
fi
elif [ "${useshortener}" = '0x0' ]; then
result="$(curl -sf -F shorten="${result}" "${shorturl}")"
elif [ "${useshortener}" = 'ptpb' ]; then
result="$(curl -sf -F c="${result}" "${shorturl}")"
fi
fi
if [ "${?}" = 0 ]; then
if [ ! "${nocomm}" ]; then
printf %s "${result}" | xclip -selection primary
printf %s "${result}" | xclip -selection clipboard
echo "$(date +"%D %R") | "${FILE}" | "${result}"" >> ~/.uguush.log
notify-send 'uguu~' "${result}"
fi
echo "[${g}TM${n}]"
echo "Dosyanız yüklendi: ${result}"
# if we took a screenshot, remove the temporary file
if [ -z "${upl}" ]; then
rm "${FILE}"
fi
exit
else
echo "[${r}IPTAL${n}]"
fi
done
}
path() {
if [ "${altpath}" = "true" ]; then
DATE=$(date "+%Y-%m-%d %H-%M-%S")
cp ${FILE} "$path/$DATE.png"
fi
}
## PARSE OPTIONS
while getopts :d:fho:p:su:wxS:l: opt ;do
case "${opt}" in
d)
# set delay value
secs="${OPTARG}" ;;
f)
# fullscreen
ful='true' ;;
h)
# print help
usage
exit 0 ;;
o)
# set host
[[ "${hosts}" =~ ${OPTARG} ]] && usehost="${OPTARG}" || exit 1 ;;
s)
# take shot with selection
sel='true' ;;
u)
# change $FILE to the specified file with -u
upl='true'
FILE="${OPTARG}" ;;
w)
# take shot of current window
win='true' ;;
x)
# do not notify dbus, update log, or modify clipboard
nocomm='true' ;;
S)
# set shortener
[[ "${shorteners}" =~ ${OPTARG} ]] && useshortener="${OPTARG}" || exit 1 ;;
l)
# set url to upload
lnk='true'
url="${OPTARG}" ;;
p)
# set path to save file
altpath='true'
path="${OPTARG}" ;;
*)
# print help and EXIT_FAILURE
usage
exit 1 ;;
esac
done
## EXECUTE FUNCTIONS
depends
delay
screenshot
path
upload
# If the program doesn't exit at the for-loop, the upload failed.
echo 'File was not uploaded, did you specify a valid filename?'