From 03bc4c2c8731ff356d75828fb76e81a8edb4b065 Mon Sep 17 00:00:00 2001 From: kittykat Date: Tue, 12 Nov 2024 02:40:28 +0000 Subject: [PATCH] # 2024.11.12 - [up_uploadee] Add upload.ee as an upload host --- hosts/up_uploadee.sh | 207 +++++++++++++++++++++++++++++++++++++++++++ mad.sh | 3 +- 2 files changed, 209 insertions(+), 1 deletion(-) create mode 100644 hosts/up_uploadee.sh diff --git a/hosts/up_uploadee.sh b/hosts/up_uploadee.sh new file mode 100644 index 0000000..c597c8a --- /dev/null +++ b/hosts/up_uploadee.sh @@ -0,0 +1,207 @@ +#! Name: up_uploadee.sh +#! Author: kittykat +#! Version: 2024.11.12 +#! Desc: Add support for uploading files to upload.ee +#! Info: Files are accessible at https://upload.ee/ +#! MaxSize: 100MB +#! Expire: 50d expiry +#! Usage: Copy this file into the ./${ScriptDir}/hosts/ folder +#! +#! +#! ------------ REQUIRED SECTION --------------- +#! @[UPDATE] ListUploadHosts: This string is loaded into mad.sh and allows dynamic handling of new url data +#! Format: '/HostCode/HostNick/HostFuncPrefix@' +#! HostCode: (ie. 'fh' for filehaus -- cannot be used by other hosts) +#! HostNick: What is displayed throughout MAD output +#! HostFuncPrefix: ie. 'fh' -- fh_UploadFile() +#! * Note: Must begin with a letter a-z (functions beginning with numbers are no bueno) +HostCode='upee' +HostNick='upload.ee' +HostFuncPrefix='upee' +#! +#! !! DO NOT UPDATE OR REMOVE !! +#! This merges the Required HostAndDomainRegexes into mad.sh +ListUploadHosts=${ListUploadHosts}'/'${HostCode}'/'${HostNick}'/'${HostFuncPrefix}'@' +#! +#! +#! Configurables +#! ------------- +#! +#! ------------ (1) Host Main Upload Function --------------- # +#! +#! @REQUIRED: Host Main Upload function +#! Must be named specifically as such: +#! _UploadFile() +upee_UploadFile() { + local _hostCode=${1} + local filepath=${2} + local filecnt=${3} + local pline=${4} + local filename="${filepath##*/}" + warnAndRetryUnknownError=false + exitUploadError=false + exitUploadNotAvailable=false + fileAlreadyDone=false + tor_identity="${RANDOM}" + UploadTicket="${WorkDir}/.flocks/upload_${_hostCode}_${filepath//[^a-zA-Z0-9]/}" + MaxUploadSizeInBytes=104857600 + fsize=$(GetFileSize "$filepath" "false") + if ((fsize > MaxUploadSizeInBytes)); then + m -f "${UploadTicket}" + echo -e "${YELLOW}| SKIP${NC}: The size of $filename is to large for $_hostCode. ($fsize > $MaxUploadSizeInBytes)" + failedUpload "$pline" "${filepath}" "${_hostCode}" "Skipping upload. The size of $filename is to large for $_hostCode. ($fsize > $MaxUploadSizeInBytes)" + return 1 + fi + finalAttempt="false" + for ((z=0; z<=$MaxUploadRetries; z++)); do + if [ $z -eq $MaxUploadRetries ] ; then + finalAttempt="true" + fi + trap "rm -f "${UploadTicket}"; echo ""; tput cnorm; exit" 0 1 2 3 6 15 + if upee_PostFile "${filepath}" "${_hostCode}" "${filename}" "${filecnt}" $((z+1)) $finalAttempt $pline ; then + return 0 + elif [ $z -lt $MaxUploadRetries ]; then + if [ "${fileAlreadyDone}" == "true" ] ; then + break + fi + if [[ "${warnAndRetryUnknownError}" == "true" ]] ; then + if [ "${DebugAllEnabled}" == "true" ] ; then + debugHtml "${filepath##*/}" "error" "Retry due to an unknown issue: attempt #$((z+1)) of ${MaxUploadRetries}" + fi + fi + if [[ "${exitUploadError}" == "true" || "${exitUploadNotAvailable}" == "true" ]] ; then + if [ "${DebugAllEnabled}" == "true" ] ; then + debugHtml "${filepath##*/}" "error" "Exit due to unrecoverable issue" + fi + rm -f "${UploadTicket}" + break + fi + echo -e "\n${YELLOW}A recoverable error occurred, retry attempt $((z+1))/${MaxUploadRetries}${NC}" + sleep 3 + fi + done + rm -f "${UploadTicket}" +} +#! +#! ----------- (2) Post File / Upload File Function --------------- # +#! +upee_PostFile() { + local filepath=$1 + local _hostCode=$2 + local filename=$3 + local fileCnt=$4 + local retryCnt=$5 + local finalAttempt=$6 + local pline=${7} + UploadTicket="${WorkDir}/.flocks/upload_${_hostCode}_${filepath//[^a-zA-Z0-9]/}" + echo -e "[${YELLOW}${_hostCode}${NC}] Uploading ${GREEN}${filename}${NC}" + tor_identity="${RANDOM}" + maxfetchretries=3 + echo -e "${GREEN}# Fetching id info…${NC}" + for ((i=1; i<=$maxfetchretries; i++)); do + mkdir -p "${WorkDir}/.temp" + printf " ." + tor_identity="${RANDOM}" + trap "rm -f ${UploadTicket}; echo ""; tput cnorm; exit" 0 1 2 3 6 15 + response=$(tor_curl_request --insecure -L -s "https://www.upload.ee/ubr_link_upload.php") + if [ "${DebugAllEnabled}" == "true" ] ; then + debugHtml "${filepath##*/}" "${_hostCode}_up_getid_$i" "url: https://www.upload.ee/ubr_link_upload.php"$'\n'"${response}" + fi + if [[ -z $response ]] ; then + if [ $i == $maxfetchretries ] ; then + if [ "${finalAttempt}" == "true" ] ; then + printf "\\n" + echo -e "${RED}| Upload failed. (GetId [1])${NC}" + failedUpload "$pline" "${filepath}" "${_hostCode}" "Failed to upload file" "No Response (GetId [1])" + exitUploadError=true + return 1 + else + printf "\\n" + echo -e "${RED}| Failed get 1F id [1].${NC}" + warnAndRetryUnknownError=true + return 1 + fi + else + continue + fi + else + if grep -Eqi '\{startUpload\("' <<< "${response}" ; then + printf "\\n" + echo -e "${GREEN}| Found id...${NC}" + upee_uploadid=$(grep -oPi '(?<=\{startUpload\(").*?(?=".*$)' <<< "$response") + if [ ! -z "$upee_uploadid" ]; then + break + else + if [ $i == $maxfetchretries ] ; then + if [ "${finalAttempt}" == "true" ] ; then + printf "\\n" + echo -e "${RED}| Upload failed. (GetId [2])${NC}" + failedRetryUpload "$pline" "${filepath}" "${_hostCode}" "Failed to upload file" "(GetId [2])" + exitUploadError=true + return 1 + else + printf "\\n" + echo -e "${RED}| Failed to get id [2].${NC}" + warnAndRetryUnknownError=true + return 1 + fi + else + continue + fi + fi + else + if [ $i == $maxfetchretries ] ; then + if [ "${finalAttempt}" == "true" ] ; then + printf "\\n" + echo -e "${RED}| Upload failed. (GetId [3])${NC}" + failedRetryUpload "$pline" "${filepath}" "${_hostCode}" "Failed to upload file" "(GetId [3])" + exitUploadError=true + return 1 + else + printf "\\n" + echo -e "${RED}| Failed to get id [3].${NC}" + warnAndRetryUnknownError=true + return 1 + fi + else + continue + fi + fi + fi + done + echo -e "${GREEN}# Sending file…${NC}" + PostUrlHost="https://www.upload.ee/cgi-bin/ubr_upload.pl?upload_id=$upee_uploadid" + arrFiles=("$filepath") + trap "rm -f ${UploadTicket}; echo ""; tput cnorm; exit" 0 1 2 3 6 15 + response=$(tor_curl_upload --insecure -i -L \ + -H "Content-Type: multipart/form-data" \ + -F "upfile_0=@$filepath" \ + "${PostUrlHost}") + if [ "${DebugAllEnabled}" == "true" ] ; then + debugHtml "${filepath##*/}" "${_hostCode}_upload" "post_url: ${PostUrlHost}"$'\n'"${response}" + fi + if grep -Eqi 'File successfully uploaded!!' <<< "${response}" ; then + url=$(grep -oPi '(?<=View file:\
\