mad/plugins/pjscloud.sh
kittykat d62376f7a8
# 2025.02.18 - [uploadhive] Add handling of the new /cgi-bin/dl.cgi/ url tickets (WIP)
#               (unfortunately, this is tied to the requesting ip, so downloads get "Wrong IP")
# 2025.02.18 - [up_oshi] Add Manage url as comment on uploads
# 2025.02.18 - [up_oshi / oshi] use /nossl/ url and http
# 2025.02.17 - [gofile] Add a random sleep if 429 response detected (too many requests)
# 2025.02.17 - [*ALL] Audit and update all single bracket operations
# 2025.02.17 - [filehaus] Fix downloading from fh
# 2025.02.15 - [uploadbay] Update urls regex for acceptable alternate
# 2025.02.15 - [up_sendnow] Add send.now as upload host
# 2025.02.15 - [sendnow] Fix handling of filenames with special characters in url
2025-02-19 13:41:07 +00:00

74 lines
3.3 KiB
Bash

#! Name: pjscloud.sh
#! Author: kittykat
#! Version: 2025.02.18
#! Desc: Wrapper to use PhantomJSCloud to retrieve url response
#! Usage: Edit LoadPlugin="" line in mad.sh or mad.config
#! LoadPlugin="pjscloud.sh"
#! * Optional: Setup additional / personal PJSCloud accounts
#!
#! Notes:
#! * Returns http query response
#!
#! Available Hook Functions:
#! -------------------------
#! * OnLoad(): Occurs after load mad.config / load plugins (prior to processing).
#! * BeginProcessing(): Occurs immediately after beginning processin of urls.txt (loops with Catnaps).
#! * PreProcessUrl(): occurs immediately after reading in an unprocessed url (^http) line to process.
#! * PostSuccessfulDownload(): occurs after a download success (is marked #OK# in the urls.txt).
#! * PostFailedDownload(): occurs after a download fails (is marked #FAIL# in the urls.txt).
#! * PostFailRetryDownload(): occurs after a download fails with a retry (is marked #RETRY# in the urls.txt).
#! * DoneProcessingAllUrls(): occurs after all the urls have finished processing (no flocks or other terms downloading).
#! * PostSuccessfulUpload(): occurs after an upload success (after upload completed ticket is created in ./downloads/).
#! * PostFailedUpload(): occurs after an upload fails definitively -- #FAIL# in the temp_upload_handler.txt
#! * PostFailRetryUpload(): occurs after an upload fails with a retry (network drop, unexpected result)
#! * DoneProcessingAllUploads: occurs after alll the files have finished processing
#!
#!
pjscloud_tor_request() {
local plugName='pjscloud'
local plugFunc='pjscloud_tor_request'
if [[ "${DebugPluginsEnabled}" == "true" ]]; then
echo -e "[${PINK}DEBUG${NC}]: Running ${PINK}$plugFunc${NC} in ${BLUE}$plugName${NC} ...${NC}"
fi
pjs_targeturl="$1"
pjs_data="$2"
if [[ -z "$pjs_targeturl" ]]; then
echo "Aborting: No target url specified."
fi
GetRandomPjsKey
if [[ ! -z "$pjs_targeturl" ]] && [[ ! -z "$pjs_data" ]] ; then
pjs_urldata='{"url":"'"$pjs_targeturl"'", urlSettings:{"operation":"POST", "data":"'"$pjs_data"'"}, "renderType":"plainText"}'
else
pjs_urldata='{"url":"'"$pjs_targeturl"'", "renderType":"plainText"}'
fi
if [[ "${UseTorCurlImpersonate}" == "true" ]]; then
response=$("${curl_impersonate[@]}" --proxy "socks5h://${tor_identity}@${TorIp}:${torPort}" \
--connect-timeout ${ConnectTimeout} \
--insecure -k -s \
-H "Content-Type: application/json" \
-H "Expect:" -X POST \
-d "$pjs_urldata" \
"https://PhantomJScloud.com/api/browser/v2/$RandomPjsKey/" & sleep 8s; kill -HUP $! 2>/dev/null)
else
response=$(curl --proxy "socks5h://${tor_identity}@${TorIp}:${torPort}" \
--connect-timeout ${ConnectTimeout} \
--insecure -k -s \
-H "Content-Type: application/json" \
-H "Expect:" -X POST \
-d "$pjs_urldata" \
"https://PhantomJScloud.com/api/browser/v2/$RandomPjsKey/" & sleep 8s; kill -HUP $! 2>/dev/null)
fi
echo -e "[PJSC_RESPONSE_BEGIN]"
echo -e "${response}"
echo -e "[PJSC_RESPONSE_END]"
}
#!
#! --------------- Extra Functions ------------------- #
#!
GetRandomPjsKey() {
arrSize=${#ar_pgsKey[@]}
index=$(($RANDOM % $arrSize))
RandomPjsKey=${ar_pgsKey[$index]}
}
#! Initialize PJSCloud and get a random key
GetRandomPjsKey