From 86353057403f971b1d5a30cc0639a2021c24adf9 Mon Sep 17 00:00:00 2001 From: NaiJi Date: Fri, 15 Apr 2022 16:44:29 +0000 Subject: [PATCH] Add 'post-local.sh' --- post-local.sh | 34 ++++++++++++++++++++++++++++++++++ 1 file changed, 34 insertions(+) create mode 100644 post-local.sh diff --git a/post-local.sh b/post-local.sh new file mode 100644 index 0000000..067ce09 --- /dev/null +++ b/post-local.sh @@ -0,0 +1,34 @@ +#!/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" \ No newline at end of file