Jafner.net/dotfiles/utility-scripts/ffmpeg/send-to-zipline
Joey Hafner 27cf692572
Clean up dotfiles
- Move shell profiles to shell folder
- Add `ffconvert` and `zipline` functions
- Delete configuration files for tools I don't use
2024-09-04 13:06:03 -07:00

36 lines
1.5 KiB
Bash
Executable File

#!/bin/bash
# Uploads via Curl will not be configured with a correct mimetype unles the server's `UPLOADER_ASSUME_MIMETYPES` env var is set to true.
# Set the $FILE variable to act on. Varies with file manager, but Dolphin's servicemenus and CLI both use $1
if ! [ -z $NAUTILUS_SCRIPT_SELECTED_FILE_PATHS ]; then
echo "$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS" > ~/.nautilus_script_selected_file_paths
if (( $(grep -c . <<<"$(cat ~/.nautilus_script_selected_file_paths)") > 1 )); then notify-send -u critical "Script error" "Selecting more than 1 file is not supported."; exit 1; fi
rm ~/.nautilus_script_selected_file_paths
INPUT_FILE="$NAUTILUS_SCRIPT_SELECTED_FILE_PATHS"
elif ! [ -z "$1" ]; then
INPUT_FILE="$1"
else
echo "No file selected."
exit 1
fi
# Break up the input file's parts so we know the:
# - absolute path (e.g. /home/user/Videos/MyVideo.mkv)
# - file name (without extension) (e.g. MyVideo)
INPUT_FILE=$(realpath "$INPUT_FILE")
FILE_NAME=$(basename "$INPUT_FILE")
FILE_NAME="${FILE_NAME%.*}"
ZIPLINE_HOST_ROOT=https://zipline.jafner.net
TOKEN=$(cat ~/.zipline-auth.token)
LINK=$(curl \
--header "authorization: $TOKEN" \
$ZIPLINE_HOST_ROOT/api/upload -F "file=@$INPUT_FILE" \
--header "Content-Type: multipart/form-data" \
--header "Format: name" \
--header "Embed: true" \
--header "Original-Name: true")
LINK=$(echo "$LINK" | jq -r .'files[0]')
echo "[$FILE_NAME]($LINK)" | wl-copy
notify-send -t 4000 "Zipline - Upload complete." "Link copied to clipboard: $LINK"