#! Name: up_uploadhive.sh #! Author: kittykat #! Version: 2025.02.14 #! Desc: Add support for uploading files to uploadhive.com #! Info: Files are accessible at https://uploadhive.com/ #! MaxSize: 5GB #! Expire: 100d 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='uhive' HostNick='uploadhive' HostFuncPrefix='uhive' #! #! !! 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() uhive_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=5368709120 fsize=$(GetFileSize "$filepath" "false") if ((fsize > MaxUploadSizeInBytes)); then rm -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 uhive_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 --------------- # #! uhive_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}" PostUrlHost='https://fs430.uploadhive.com/cgi-bin/upload.cgi' if [[ "$UploadHiveRandomizeExt" == "true" ]]; then randomext=$(mktemp -u XXX) randomext=${randomext,,} echo -e "${BLUE}MAD Randomized Extension: $randomext${NC}" origext=${filepath##*.} if [[ "$origext" == "7z" ]]; then tmpfilepath="${filepath%.*}--7_.${randomext}" elif [[ "$origext" == "zip" ]]; then tmpfilepath="${filepath%.*}--z_.${randomext}" elif grep -Eqi '\.part.*\.rar' <<< "${filepath##*/}" ; then partnum="${filepath##*.part}" partnum="${partnum%.rar*}" echo -e "$partnum" tmpfilepath="${filepath%.part*}_-p${partnum}--r_.${randomext}" elif [[ "$origext" == "rar" ]]; then tmpfilepath="${filepath%.*}--r_.${randomext}" elif [[ "$origext" == "tar" ]]; then tmpfilepath="${filepath%.*}--t_.${randomext}" elif [[ "${filepath##*/}" == *".7z."* ]]; then tmpfilepath="${filepath%.*}_-7--${origext}_.${randomext}" else tmpfilepath="${filepath%.*}--${origext}_.${randomext}" fi echo -e "Creating temp random ext file..." cp $filepath $tmpfilepath else tmpfilepath=$filepath fi arrFiles=("$tmpfilepath") trap "rm -f ${UploadTicket}; echo ""; rm -f $tmpfilepath; tput cnorm; exit" 0 1 2 3 6 15 response=$(tor_curl_upload --insecure -i \ -H "Content-Type: multipart/form-data" \ -F "sess_id=" \ -F "utype=anon" \ -F "link_rcpt=" \ -F "link_pass=" \ -F "to_folder=" \ -F "file_descr=" \ -F "file_public=1" \ -F "upload=Start upload" \ -F "file_0=@$tmpfilepath" \ "${PostUrlHost}") if [ "${DebugAllEnabled}" == "true" ] ; then debugHtml "${filepath##*/}" "${_hostCode}_upload" "post_url: ${PostUrlHost}"$'\n'"${response}" fi if [[ "$UploadHiveRandomizeExt" == "true" ]]; then rm -f $tmpfilepath; fi if grep -Eqi '"file_status":"OK"' <<< "${response}" ; then hash=$(grep -oPi '(?<=file_code":").*?(?=".*$)' <<< "$response") filesize=$(GetFileSize "$filepath" "false") downloadLink="https://uploadhive.com/${hash}" echo -e "${GREEN}| Upload Success${NC}" echo -e "| Size: ${BLUE}${filesize}${NC} bytes${NC}" echo -e "| Link: ${YELLOW}${downloadLink}${NC}" if [[ "$UploadHiveRandomizeExt" == "true" ]]; then successUpload "$pline" "${filepath}" "${_hostCode}" "${filesize}" "${downloadLink}" "{$response}" "[rand ext, rename to $filename or use MAD v2025.02.13+]" else successUpload "$pline" "${filepath}" "${_hostCode}" "${filesize}" "${downloadLink}" "{$response}" fi return 0 else err=$(grep -oPi '(?<="file_status":").*?(?=".*$)' <<< "$response") httpstatus=$(grep -oPi '(?<=HTTP/.* ).*?(?=$)' <<< "$response") if [ "${finalAttempt}" == "true" ] ; then printf "\\n" echo -e "${RED}| Upload failed. Status: ${httpstatus}, Error: ${err}${NC}" failedRetryUpload "$pline" "${filepath}" "${_hostCode}" "Failed to upload file" "Status: ${httpstatus}, Error: ${err}" exitUploadError=true return 1 else return 1 fi fi } #! #! --------------- Host Extra Functions ------------------- # #!