Bulk Upload Tool for Abyss Using Bash Script and Curl

Hello there! Want to create an automated tool to upload videos to Hydrax? You’ve come to the right place! Hydrax is a free video hosting service with unlimited storage, bandwidth, and super-fast video conversion. Let’s get started!

Step 1: Install Necessary Tools

Ubuntu

sudo apt-get update
sudo apt-get install curl jq file

CentOS

sudo yum update
sudo yum install curl jq file

Step 2: Write the Upload Script

Here’s the script you need. Note: Replace YOUR_API_KEY_HERE with your API key from your Abyss Dashboard.

#!/bin/bash

# Your API key
API_KEY="YOUR_API_KEY_HERE"

# Option to delete file after successful upload (true/false)
DELETE_AFTER_UPLOAD=false

# Function to upload a single file
upload_file() {
  FILE_PATH=$1
  FILE_NAME=$(basename $FILE_PATH)
  
  # Check file's MD5 to avoid duplicate uploads
  MD5=$(md5sum $FILE_PATH | awk '{ print $1 }')
  if grep -q "^$MD5" uploaded.txt; then
    echo "File $FILE_NAME already uploaded. Skipping."
    return
  fi

  # Send the file to Hydrax
  RESPONSE=$(curl -F "file=@$FILE_PATH" "up.hydrax.net/$API_KEY")
  SLUG=$(echo $RESPONSE | jq -r '.slug')

  # Check and save upload information
  if [ "$SLUG" != "null" ]; then
    echo "$MD5 | $FILE_NAME | $SLUG" >> uploaded.txt
    echo "Uploaded $FILE_NAME with slug $SLUG."
    # Delete the file if the option is set to true
    if [ "$DELETE_AFTER_UPLOAD" = true ]; then
      rm $FILE_PATH
      echo "File $FILE_NAME deleted after successful upload."
    fi
  else
    echo "Failed to upload $FILE_NAME."
  fi
}

# Check argument count
if [ "$#" -ne 1 ]; then
  echo "Usage: $0 /path/to/file/or/folder"
  exit 1
fi

# Check if the argument is a file or folder
if [ -f "$1" ]; then
  upload_file "$1"
elif [ -d "$1" ]; then
  for FILE_PATH in "$1"/*; do
    FILE_TYPE=$(file --mime-type -b "$FILE_PATH")
    if [[ "$FILE_TYPE" == video/* ]]; then
      upload_file "$FILE_PATH"
    fi
  done
else
  echo "Error: Path must be a valid file or folder."
  exit 1
fi

Note: Information about uploaded files will be saved in the uploaded.txt file.

Step 3: Grant Permissions and Use

  • Save the above script as upload.sh
  • Open Terminal and type:
chmod +x upload.sh

Upload a Single File

bash upload.sh /path/to/your/video.mp4

Upload an Entire Folder

bash upload.sh /path/to/your/folder/

Conclusion

With just a few simple steps, you’ve created a tool to upload videos to Abyss. Don’t forget to replace the API key and try it out today! Enjoy uploading your videos!


Posted

in

,

by

Comments

Leave a Reply

Your email address will not be published. Required fields are marked *