Skip to content

Instantly share code, notes, and snippets.

@aiya000
Last active August 9, 2021 07:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save aiya000/8aadcec9833a530e32337601257f0f57 to your computer and use it in GitHub Desktop.
Save aiya000/8aadcec9833a530e32337601257f0f57 to your computer and use it in GitHub Desktop.
#!/bin/bash
apiKey=JlE5Jldo5Jibnk5O5hTx6XVqsJu4WJ26
if [[ $# -lt 3 ]] ; then
{
echo 'help:'
echo " $0 {input-file} {world-tag} {authcookie}"
} > /dev/stderr
exit 1
fi
world_ids_json=$1
tags="[\"$2\"]"
auth=$3
is_first=true
for favoriteId in $(jq -r '.[]' < "$world_ids_json") ; do
if [[ $is_first = true ]] ; then
is_first=false
else
sleep 60
fi
json=$( \
curl --silent -X POST \
"https://api.vrchat.cloud/api/1/favorites?apiKey=$apiKey" \
-b "$auth" \
-H 'Content-Type: application/json' \
-d "{\"type\": \"world\", \"favoriteId\": \"$favoriteId\", \"tags\": $tags}" \
)
error_message=$(echo "$json" | jq '.error.message')
if [[ $error_message != null ]] ; then
{
echo 'Skip this world:'
echo " favoriteId: $favoriteId"
echo " error message: $error_message"
} > /dev/stderr
continue
fi
error=$(echo "$json" | jq '.error')
if [[ $error != null ]] ; then
echo "Fatal errors: $error" > /dev/stderr
exit 1
fi
echo 'This world is favorite:'
echo " favoriteId: $favoriteId"
echo " tags: $tags"
done
The MIT License (MIT)
Copyright (c) 2021 aiya000
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
The above copyright notice and this permission notice shall be included in
all copies or substantial portions of the Software.
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
THE SOFTWARE.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment