Skip to content
View mastermrx008's full-sized avatar

Block or report mastermrx008

Block user

Prevent this user from interacting with your repositories and sending you notifications. Learn more about blocking users.

You must be logged in to block users.

Please don't include any personal information such as legal names or email addresses. Maximum 100 characters, markdown supported. This note will be visible to only you.
Report abuse

Contact GitHub support about this user’s behavior. Learn more about reporting abuse.

Report abuse
mastermrx008/README.md

Hi there 👋

#!/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

Popular repositories Loading

  1. mastermrx008 mastermrx008 Public

    Config files for my GitHub profile.

    1

  2. markdownlint markdownlint Public

    Forked from DavidAnson/markdownlint

    A Node.js style checker and lint tool for Markdown/CommonMark files.มม

    JavaScript 1

  3. leagues-of-code-thailand leagues-of-code-thailand Public template

    Forked from Nacnano/leagues-of-code-thailand

    repository for storing codes from League of Code Thailand Camp

    C++ 1

  4. giphy-js giphy-js Public

    Forked from Giphy/giphy-js

    Official GIPHY packages

    TypeScript

  5. react-pdf-demo react-pdf-demo Public

    Forked from bchaichon/react-pdf-demo

    สร้างไฟล์ pdf ด้วย React + pdfmake ภาษาไทย

    JavaScript

  6. cl-cookbook cl-cookbook Public

    Forked from LispCookbook/cl-cookbook

    The Common Lisp Cookbook

    JavaScript