50 lines
1.1 KiB
Bash
50 lines
1.1 KiB
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
|
|
|
|
sources_dat="./sources.dat"
|
|
|
|
if [ ! -f $sources_dat ]
|
|
then
|
|
echo "Missing ./sources.dat"
|
|
exit 1
|
|
fi
|
|
|
|
api_base_url="https://your.site/"
|
|
access_token="$(cat ${token_dat})"
|
|
|
|
pair_to_post=($(cat ${sources_dat} | shuf -n 1))
|
|
source_url=${pair_to_post[0]}
|
|
hyperlink_url=${pair_to_post[1]}
|
|
|
|
mkdir source
|
|
cd source
|
|
wget "${source_url}" 2> /dev/null || (echo "Error with ${source_url}" && exit 1)
|
|
|
|
media_json=$(curl -X POST "${api_base_url}/api/v1/media" \
|
|
-H "Authorization: Bearer ${access_token}" \
|
|
-F "file=@`ls *`")
|
|
|
|
media_id=$(jq -r ".id" <<< ${media_json})
|
|
|
|
echo $media_json
|
|
cd ..
|
|
rm -rf source/
|
|
|
|
curl -X POST -d '{"status":" :azrn_shiratsuyu_maid: '${hyperlink_url}'", "visibility":"'unlisted'", "media_ids":'[\"${media_id}\"]'}' \
|
|
-H "Authorization: Bearer ${access_token}" \
|
|
-H "Content-Type: application/json" \
|
|
"${api_base_url}/api/v1/statuses"
|