# 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
This commit is contained in:
kittykat 2025-02-19 13:41:07 +00:00
parent d48116dbe3
commit d62376f7a8
Signed by: kittykat
GPG key ID: E3F1556620F70C3C
103 changed files with 3541 additions and 3517 deletions

View file

@ -46,13 +46,13 @@ fich_DownloadFile() {
trap "rm -f ${WorkDir}/.flocks/${CLEANSTRING}; rm -f $lockfile; echo ""; tput cnorm; exit" 0 1 2 3 6 15
tor_identity="${RANDOM}"
PAGE=$(tor_curl_request --insecure --max-time "$ConnectTimeout" -s "${remote_url}")
if [ "${DebugAllEnabled}" == "true" ] ; then
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${remote_url##*/?}" "prechk$y" "${PAGE}"
fi
file_information=$(grep -oP '(?<=<td class="normal">)[^<]*?(?=</td>)' <<< "${PAGE}")
size=$(echo "${file_information}" | tail -n 1)
filename=$(echo "${file_information}" | head -n 1)
if [ ! "$filename_override" == "" ] ; then
if [[ ! "$filename_override" == "" ]] ; then
filename="$filename_override"
fi
filename=$(sanitize_file_or_folder_name "${filename}")
@ -89,7 +89,7 @@ fich_DownloadFile() {
return 1
fi
if [[ -z "$filename" || -z "$size" || ${size//[!0-9]/} =~ '^[0-9]+([.][0-9]+?$' ]]; then
if [ $y -eq $MaxUrlRetries ] ; then
if ((y == MaxUrlRetries )) ; then
echo -e "\n${RED}ERROR: Filename or size not found${NC}"
echo -e "url: ${remote_url}"
echo -e "filename: $filename"
@ -106,7 +106,7 @@ fich_DownloadFile() {
passwordProtectedDownload "${remote_url}"
return 1
fi
if [ $y -gt 1 ] ; then
if ((y > 1 )) ; then
printf "\\n"
fi
echo -e "${GREEN}${filename} (${size}) is available.${NC}"
@ -114,24 +114,24 @@ fich_DownloadFile() {
done
finalAttempt="false"
for ((z=0; z<=$MaxUrlRetries; z++)); do
if [ $z -eq $MaxUrlRetries ] ; then
if [[ $z -eq $MaxUrlRetries ]] ; then
finalAttempt="true"
fi
CLEANSTRING=${remote_url//[^a-zA-Z0-9]/}
trap "rm -f ${WorkDir}/.flocks/${CLEANSTRING}; echo ""; tput cnorm; exit" 0 1 2 3 6 15
if fich_FindEmptySlot && fich_FetchFileInfo "" $((z+1)) $finalAttempt && fich_GetFile "${filecnt}" $((z+1)) $finalAttempt $filename ; then
return 0
elif [ $z -lt $MaxUrlRetries ]; then
if [ "${fileAlreadyDone}" == "true" ] ; then
elif [[ $z -lt $MaxUrlRetries ]]; then
if [[ "${fileAlreadyDone}" == "true" ]] ; then
break
fi
if [[ "${warnAndRetryUnknownError}" == "true" ]] ; then
if [ "${DebugAllEnabled}" == "true" ] ; then
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${remote_url##*/?}" "error" "Retry due to an unknown issue: attempt #$((z+1)) of ${MaxUrlRetries}"
fi
fi
if [[ "${exitDownloadError}" == "true" || "${exitDownloadNotAvailable}" == "true" ]] ; then
if [ "${DebugAllEnabled}" == "true" ] ; then
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${remote_url##*/?}" "error" "Exit due to unrecoverable issue"
fi
rm -f "${WorkDir}/.flocks/${remote_url//[^a-zA-Z0-9]/}"
@ -159,7 +159,7 @@ fich_FetchFileInfo() {
trap "rm -f ${WorkDir}/.flocks/${CLEANSTRING}; rm -f "${fich_cookie_jar}"; echo ""; tput cnorm; exit" 0 1 2 3 6 15
cdn_request=$(tor_curl_request --insecure -s -L -b "${fich_cookie_jar}" -c "${fich_cookie_jar}" -F "submit=Download" -F "pass=${fich_user_provided_password}" -F "adz=${fich_adz_parameter}" "${remote_url}")
target_file_link=$(echo "$cdn_request" | grep -A 2 '<div style="width:600px;height:80px;margin:auto;text-align:center;vertical-align:middle">' | grep -oP '<a href="\K[^"]+')
if [ "${DebugAllEnabled}" == "true" ] ; then
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${remote_url##*/?}" "fich_cdn${num_attempt}_1" "target_file_link: ${target_file_link}"$'\n'"${cdn_request}"
fi
rm -f "${fich_cookie_jar}"
@ -171,7 +171,7 @@ fich_FetchFileInfo() {
return 2
else
echo -e "${RED}ERROR: Could not find CDN URL${NC}"
if [ "${finalAttempt}" == "true" ] ; then
if [[ "${finalAttempt}" == "true" ]] ; then
noCdnDownload "${remote_url}"
fi
return 1
@ -197,7 +197,7 @@ fich_GetFile() {
download_inflight_path="${WorkDir}/.inflight/"
completed_location="${WorkDir}/downloads/"
file_path="${download_inflight_path}${filename}"
if [ "${DebugAllEnabled}" == "true" ] ; then
if [[ "${DebugAllEnabled}" == "true" ]] ; then
debugHtml "${remote_url##*/?}" "fich_savehead${num_attempt}_${j}" "target_file_link: ${target_file_link}"$'\n'"${file_header}"
fi
if [[ -z "$file_header" ]] || [[ -z "$file_size_bytes" ]]; then
@ -210,19 +210,19 @@ fich_GetFile() {
echo "We good" > /dev/null
elif grep -Eqi "410 Gone" <<< "${file_header}" > /dev/null ; then
echo -e "${RED}ERROR: Failed to retrieve file header (410 Gone).${NC}\nThis could be due to 1fichier experiencing a temporary issue."
if [ "${finalAttempt}" == "true" ] ; then
if [[ "${finalAttempt}" == "true" ]] ; then
failedDownload "${remote_url}" "${filename}" "410 Gone"
fi
return 1
elif grep -Eqi "403 Forbidden" <<< "${file_header}" > /dev/null ; then
echo -e "${RED}ERROR: Failed to retrieve file header (403 Forbidden).${NC}\nThis could be due to 1fichier experiencing a temporary issue."
if [ "${finalAttempt}" == "true" ] ; then
if [[ "${finalAttempt}" == "true" ]] ; then
failedDownload "${remote_url}" "${filename}" "403 Forbidden"
fi
return 1
else
echo -e "${RED}ERROR: Failed to retrieve file header (Unknown Head Response).${NC}\nThis could be due to 1fichier experiencing a temporary issue."
if [ "${finalAttempt}" == "true" ] ; then
if [[ "${finalAttempt}" == "true" ]] ; then
failedDownload "${remote_url}" "${filename}" "Unknown Head Response"
fi
return 1
@ -242,7 +242,7 @@ fich_GetFile() {
if (( $(echo "$percent_diff > $percent_threshold" |bc -l) )); then
echo -e "${RED}ERROR: The difference between the advertised and retrieved file size is too big${NC}\nThis is most likely due to someone else taking the slot or some other error along the way."
echo -e "AdvertisedSize: $size ($size_bytes), Size: $file_size_bytes, Diff: $percent_diff"
if [ "${finalAttempt}" == "true" ] ; then
if [[ "${finalAttempt}" == "true" ]] ; then
droppedSizeBadDownload "${remote_url}" "${filename}" "${file_size_bytes}" "${size}"
fi
return 1
@ -255,18 +255,18 @@ fich_GetFile() {
return 1
fi
echo "${remote_url//[^a-zA-Z0-9]/}" > $flockDownload
touch ${WorkDir}/.flocks/${remote_url//[^a-zA-Z0-9]/}
touch "${WorkDir}/.flocks/${remote_url//[^a-zA-Z0-9]/}"
CLEANSTRING=${remote_url//[^a-zA-Z0-9]/}
trap "rm -f ${WorkDir}/.flocks/${CLEANSTRING}; rm -f $flockDownload; echo ""; tput cnorm; exit" 0 1 2 3 6 15
tor_curl_request --insecure -e "${remote_url}" "${target_file_link}" -C - -o "${file_path}"
rm -f "$flockDownload";
received_file_size=0
if [ -f "$file_path" ] ; then
if [[ -f "$file_path" ]] ; then
received_file_size=$(stat --format="%s" "$file_path" | tr -d '[:space:]')
fi
if [[ "${received_file_size}" -ne "${file_size_bytes}" ]]; then
echo -e "${RED}ERROR: Size mismatch after downloading${NC}\nPerhaps you or 1fichier lost connection for a while?"
if [ "${finalAttempt}" == "true" ] ; then
if [[ "${finalAttempt}" == "true" ]] ; then
droppedSizeBadDownload "${remote_url}" "${filename}" "${received_file_size}"
fi
return 1