-
-
Save AdrianKoshka/b8142ff55d089ab7bf05 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# pomf clone uploader | |
# requires: curl | |
# formerly known as 1339load | |
#1339.cf works, so does pomf.cat, if you test others and they work, tell me. | |
dest_url='https://pomf.cat/upload.php' | |
return_url='https://a.pomf.cat' | |
if [[ -n "${1}" ]]; then | |
file="${1}" | |
if [ -f "${file}" ]; then | |
printf "Uploading ${file}..." | |
my_output=$(curl --silent -sf -F files[]="@${file}" "${dest_url}") | |
n=0 # Multipe tries | |
while [[ $n -le 3 ]]; do | |
printf "try #${n}...\n" | |
if [[ "${my_output}" =~ '"success":true,' ]]; then | |
return_file=$(echo "$my_output" | grep -Eo '"url":"[A-Za-z0-9]+.*",' | sed 's/"url":"//;s/",//') | |
printf 'done.\n' | |
break | |
else | |
printf 'failed.\n' | |
((n = n +1)) | |
fi | |
done | |
if [[ -n ${return_file} ]]; then | |
printf "${return_url}/${return_file}" | xclip -selection clipboard | |
else | |
printf 'Error! File not uploaded.\n' | |
fi | |
else | |
printf 'Error! File does not exist!\n' | |
exit 1 | |
fi | |
else | |
printf 'Error! You must supply a filename to upload!\n' | |
exit 1 | |
fi |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment