udonge-bot/post-local.sh

38 lines
950 B
Bash

#!/bin/bash
if [ -z $(which jq) ]
then
echo "Missing jq package, please install"
exit 1
fi
token_dat="./token.dat"
if [ ! -f $token_dat ]
then
echo "Missing ./token.dat"
exit 1
fi
api_base_url="https://udongein.xyz/"
access_token="$(cat ${token_dat})"
sensitivity="$(ls | grep sfw | shuf -n 1)"
source_url="${sensitivity}/$(ls ${sensitivity} | shuf -n 1)"
is_sensitive=true
if [ "${sensitivity}" == "sfw" ]
then
is_sensitive=false
fi
media_json=$(curl -X POST "${api_base_url}/api/v1/media" \
-H "Authorization: Bearer ${access_token}" \
-F "file=@${source_url}")
media_id=$(jq -r ".id" <<< ${media_json})
curl -X POST -d '{"status":" :gyate_reisen_love:", "sensitive":'${is_sensitive}', "visibility":"'unlisted'", "media_ids":'[\"${media_id}\"]'}' \
-H "Authorization: Bearer ${access_token}" \
-H "Content-Type: application/json" \
"${api_base_url}/api/v1/statuses"