This commit is contained in:
NaiJi ✨ 2022-05-09 17:23:01 +00:00
commit 89187db103
1 changed files with 60 additions and 0 deletions

60
post.sh Normal file
View File

@ -0,0 +1,60 @@
#!/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="./music"
if [ ! -d $sources_dat ]
then
echo "Missing ./music/"
exit 1
fi
api_base_url="https://udongein.xyz/"
access_token="$(cat ${token_dat})"
folder_name=$(ls music/ | shuf -n 1)
track_name=$(ls music/"${folder_name}" | grep opus | shuf -n 1)
echo "From: $folder_name"
echo "Pick: $track_name"
echo " "
cp -f music/"$folder_name"/"$track_name" temp.opus
cp -f music/"$folder_name"/cover.jpg ./cover.jpg
link=$(cat music/"$folder_name"/link)
full_title=$(exiftool -s -s -s -Title temp.opus)
full_artist=$(exiftool -s -s -s -Artist temp.opus)
media_cover_json=$(curl -X POST "${api_base_url}/api/v1/media" \
-H "Authorization: Bearer ${access_token}" \
-F "file=@`ls cover.*`")
media_music_json=$(curl -X POST "${api_base_url}/api/v1/media" \
-H "Authorization: Bearer ${access_token}" \
-F "file=@`ls temp.opus`")
media_cover_id=$(jq -r ".id" <<< ${media_cover_json})
media_music_id=$(jq -r ".id" <<< ${media_music_json})
echo $media_json
curl -X POST -d '{"status":" :mikulove: '"${full_title}"' by '"${full_artist}"' '"${link}"'", "visibility":"'unlisted'", "media_ids":'[\"${media_cover_id}\",\"${media_music_id}\"]'}' \
-H "Authorization: Bearer ${access_token}" \
-H "Content-Type: application/json" \
"${api_base_url}/api/v1/statuses"
rm -f temp.opus
rm -f cover.*