diff --git a/hosts/up_offshorecat.sh b/hosts/up_offshorecat.sh new file mode 100644 index 0000000..971eb83 --- /dev/null +++ b/hosts/up_offshorecat.sh @@ -0,0 +1,143 @@ +#! Name: up_offshorecat.sh +#! Author: kittykat +#! Version: 2024.11.12 +#! Desc: Add support for uploading files to offshore.cat +#! Info: Files are accessible at https://files.offshore.cat/ +#! MaxSize: 4GB +#! Expire: ?? +#! 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='offcat' +HostNick='offshore.cat' +HostFuncPrefix='offcat' +#! +#! !! 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() +offcat_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=4294967296 + 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 offcat_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 --------------- # +#! +offcat_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://files.offshore.cat/api/upload' + arrFiles=("$filepath") + trap "rm -f ${UploadTicket}; echo ""; tput cnorm; exit" 0 1 2 3 6 15 + GetRandomOscKey + apikey="$RandomOscKey" + response=$(tor_curl_upload --insecure -i \ + -H "Content-Type: multipart/form-data" \ + -H "apiKey: $apikey" \ + -F "files[]=@$filepath" \ + "${PostUrlHost}") + if [ "${DebugAllEnabled}" == "true" ] ; then + debugHtml "${filepath##*/}" "${_hostCode}_upload" "post_url: ${PostUrlHost}"$'\n'"${response}" + fi + if grep -Eqi '"url":"https://files.offshore.cat/' <<< "${response}" ; then + hash=$(grep -oPi '(?<="url":"https://files.offshore.cat/).*?(?=".*$)' <<< "$response") + filesize=$(GetFileSize "$filepath" "false") + downloadLink="https://files.offshore.cat/${hash}" + echo -e "${GREEN}| Upload Success${NC}" + echo -e "| Size: ${BLUE}${filesize}${NC} bytes${NC}" + echo -e "| Link: ${YELLOW}${downloadLink}${NC}" + successUpload "$pline" "${filepath}" "${_hostCode}" "${filesize}" "${downloadLink}" "{$response}" + return 0 + else + err=$(grep -oPi '(?<=HTTP/.* ).*?(?=$)' <<< "$response") + if [ "${finalAttempt}" == "true" ] ; then + printf "\\n" + echo -e "${RED}| Upload failed. Status: ${err}${NC}" + failedRetryUpload "$pline" "${filepath}" "${_hostCode}" "Failed to upload file" "Status: $err" + exitUploadError=true + return 1 + else + return 1 + fi + fi +} +#! +#! --------------- Host Extra Functions ------------------- # +#! +GetRandomOscKey() { + arrSize=${#ar_oscKey[@]} + index=$(($RANDOM % $arrSize)) + RandomOscKey=${ar_oscKey[$index]} +} +#! Initialize ar_oscKey and get a random key +GetRandomOscKey diff --git a/mad.sh b/mad.sh index 9054616..b614b43 100644 --- a/mad.sh +++ b/mad.sh @@ -31,9 +31,11 @@ # * klonkerz - feedback and suggestions, url only processing # * Everyone who provided feedback and helped test.. and those who wish to remain anonymous -ScriptVersion=2024.11.10 +ScriptVersion=2024.11.11 #================================================= # Recent Additions +# 2024.11.11 - [up_offcat] Add Offshore.cat as upload host +# 2024.11.11 - [mad] Add OffShore.cat Upload ApiKeys section to allow using Offshore.cat as upload host # 2024.11.10 - [mad] Fix uploads.txt multi-terminal processing (use /uploads/temp_upload_handler.txt) # 2024.11.10 - [1fichier] Add new "has been automatically deleted after its free hosting period expired" # 2024.11.10 - [up_torup] Add TorUp as an upload host @@ -293,11 +295,18 @@ ar_fdUP[0]="user1|pass1" #ar_fdUP[2]="user3|pass3" # Uncomment line to use a 3rd account #ar_fdUP[3]="user4|pass4" # Uncomment line to use a 4th account #ar_fdUP[4]="user5|pass5" # Uncomment line to use a 5th account -#ar_fdUP[5]="user6|pass6" # Uncomment line to use a 6th account -#ar_fdUP[6]="user7|pass7" # Uncomment line to use a 7th account -#ar_fdUP[7]="user8|pass8" # Uncomment line to use a 8th account -#ar_fdUP[8]="user9|pass9" # Uncomment line to use a 9th account -#ar_fdUP[9]="user10|pass10" # Uncomment line to use a 10th account + +# [OffShore.cat Upload ApiKeys] +# ! If you wish to use OffShore.cat uploading, you must create an account and get an apikey (or use the general public +# one shared here. +# - Setup free accounts: https://files.offshore.cat/register (use any username/pass - not verified) +# - Get apikey: https://files.offshore.cat/dashboard/account (use login created above) +# - The accounts are randomly selected for every download. +ar_oscKey[0]="CJZaU3yCQXZrozRmgXOLHjKqP1bbqbvEbJgOZig53WRgEHFHRTh5kIbEWbhEdyLq" # Shared general +#ar_oscKey[1]="apikey" # Uncomment line to use a 2nd +#ar_oscKey[2]="apikey" # Uncomment line to use a 3rd +#ar_oscKey[3]="apikey" # Uncomment line to use a 4th +#ar_oscKey[4]="apikey" # Uncomment line to use a 5th # [PhantomJS Keys]: pjscloud.sh plugin # ! Required for pixeldrain ViewPump and pjscloud functionality (enable / disable each in the pjscloud.sh file) @@ -315,12 +324,6 @@ ar_pgsKey[6]='ak-x2ng1-cr476-k4bph-ae8ks-9eg45' # Uncomment line to use a 7th ke ar_pgsKey[7]='ak-s6k8z-wb6fz-dgb37-j268v-mgspe' # Uncomment line to use a 8th key ar_pgsKey[8]='ak-msdn7-vs5jr-4kknq-3qgw7-grj57' # Uncomment line to use a 9th key ar_pgsKey[9]='ak-77pgx-g1ge9-twmhy-em51a-p8p53' # Uncomment line to use a 10th key -#ar_pgsKey[10]='aa-bbbbb-ccccc-ddddd-eeeee-fffff' # Uncomment line to use a 11th key -#ar_pgsKey[11]='aa-bbbbb-ccccc-ddddd-eeeee-fffff' # Uncomment line to use a 12th key -#ar_pgsKey[12]='aa-bbbbb-ccccc-ddddd-eeeee-fffff' # Uncomment line to use a 13th key -#ar_pgsKey[13]='aa-bbbbb-ccccc-ddddd-eeeee-fffff' # Uncomment line to use a 14th key -#ar_pgsKey[14]='aa-bbbbb-ccccc-ddddd-eeeee-fffff' # Uncomment line to use a 15th key -#ar_pgsKey[15]='aa-bbbbb-ccccc-ddddd-eeeee-fffff' # Uncomment line to use a 16th key # Global pjscloud enabled hosts PJSCloud_pixeldrain=true # Enables pixeldrain ViewPump (pjscloud.sh plugin required) @@ -4385,7 +4388,7 @@ do echo -e "${NC}" echo -e "${YELLOW}Unprocessed / Skipped URL(s) Found:${NC}" echo -e "Most likely from a different host than ${YELLOW}$hostOnlyOrUrl${NC}, another terminal is downloading it, or a flock exists...${NC}" - echo -e "Switching back to processing ${YELLOW}all hosts${NC} urls...${NC}" + echo -e "Switching back to processing ${YELLOW}all host${NC} urls...${NC}" ReloadScript "" exit 0 else