Hydrax/Abyss offers a free and unlimited video hosting service that is an ideal choice for web developers and bloggers who want to share video content. In this guide, I’ll walk you through the process of remotely uploading video files from the Internet to Hydrax using a simple bash script.
Requirements
- A machine running Linux (CentOS or Ubuntu)
- Root or sudo access
- API Key from Hydrax/Abyss
Install Required Libraries
On CentOS:
Open your terminal and run the following commands to install curl
and jq
:
sudo yum update -y
sudo yum install curl jq nano -y
On Ubuntu:
Open your terminal and run:
sudo apt update
sudo apt install curl jq nano -y
Create and Configure the Bash Script
Using Nano Editor:
- Open the terminal and create a new script file:
nano upload.sh
- Paste the following script into the editor:
#!/bin/bash
# Config
API_KEY="YOUR_API_KEY"
# Create uploaded.txt if not exists
[ ! -f uploaded.txt ] && touch uploaded.txt
# Function to upload file to Hydrax
upload_to_hydrax() {
file_path="$1"
file_name=$(basename "$file_path")
md5_hash=$(md5sum "$file_path" | awk '{print $1}')
# Check if the file has already been uploaded
if grep -q "$md5_hash" uploaded.txt; then
echo "File already uploaded: $file_name"
slug=$(grep "$md5_hash" uploaded.txt | awk -F '|' '{print $3}' | xargs)
echo "Slug: $slug"
return
fi
# Notify that we're about to upload the file
echo "Uploading file: $file_name ..."
# Upload file
response=$(curl -s -F "file=@$file_path" "up.hydrax.net/$API_KEY")
status=$(echo "$response" | jq -r '.status')
slug=$(echo "$response" | jq -r '.slug')
if [ "$status" == "true" ]; then
echo "Successfully uploaded: $file_name"
echo "Slug: $slug"
echo "$md5_hash | $file_name | $slug" >> uploaded.txt
rm -f "$file_path"
else
echo "Failed to upload: $file_name"
fi
}
# Function to download file and check HTTP status code
download_file() {
url="$1"
file_name="$2"
http_status=$(curl -o /dev/null --silent --head --write-out '%{http_code}\n' "$url")
if [[ "$http_status" -eq 403 || "$http_status" -eq 404 ]]; then
echo "Failed to download due to HTTP status code: $http_status"
return 1
fi
echo "Downloading $url..."
curl -o "$file_name" "$url"
}
# Main script
if [[ "$1" == *".txt" ]]; then
while read -r line; do
[[ "$line" == \#* ]] && continue
file_name=$(basename "$line")
if download_file "$line" "$file_name"; then
upload_to_hydrax "$file_name"
sed -i "s|$line|# $line|" "$1"
fi
done < "$1"
else
url="$1"
file_name=${2:-$(basename "$url")}
if download_file "$url" "$file_name"; then
upload_to_hydrax "$file_name"
fi
fi
- Replace
YOUR_API_KEY
with your actual API key from Hydrax. - Save and exit by pressing
Ctrl + O
, thenCtrl + X
.
Make the Script Executable:
Run the following command to make it executable:
chmod +x upload.sh
How to Use the Script
- To upload a single video file from a URL:
- bash
upload.sh http://domain.com/file.mp4
- To save the video file with a specific name and then upload:
- bash
upload.sh http://domain.com/file.mp4 video.mp4
- To batch upload from a list in a text file:
- bash
/upload.sh list.txt
In list.txt
, you can have:
http://domain.com/file1.mp4
http://domain.com/file2.mp4
Conclusion
With these simple steps, you can automate the process of uploading video files from the Internet to Hydrax quickly and conveniently. I hope this guide helps you make the most of this free video hosting service.
Happy uploading!
Leave a Reply