forked from FreakU/watch-party
Compare commits
No commits in common. "f552fdd321244a82b62ae44cb808e26642383273" and "15230facd5af9c97364a49d2d65eeca224fe8831" have entirely different histories.
f552fdd321
...
15230facd5
|
@ -1,9 +0,0 @@
|
|||
root = true
|
||||
|
||||
[*]
|
||||
indent_style = space
|
||||
indent_size = 2
|
||||
end_of_line = lf
|
||||
charset = utf-8
|
||||
trim_trailing_whitespace = false
|
||||
insert_final_newline = false
|
|
@ -1,60 +0,0 @@
|
|||
#!/usr/bin/env bash
|
||||
set -eu
|
||||
|
||||
# Get mastodon instance from MASTODON_INSTANCE
|
||||
if [ -z ${MASTODON_INSTANCE+x} ]; then
|
||||
# set from $1 if available
|
||||
if [ -z ${1+x} ]; then
|
||||
echo "You need to provide a Mastodon instance."
|
||||
exit 1
|
||||
else
|
||||
mastodon_instance="$1"
|
||||
fi
|
||||
else
|
||||
mastodon_instance="$MASTODON_INSTANCE"
|
||||
fi
|
||||
|
||||
echo "Mastodon instance: $mastodon_instance"
|
||||
|
||||
# Get emoji folder
|
||||
emojiFolder="$(readlink -f "$(dirname $0)/../frontend/emojis/")"
|
||||
|
||||
echo "Downloading emojis to $emojiFolder"
|
||||
|
||||
echo "Creating $emojiFolder if it doesn't exist"
|
||||
|
||||
mkdir -p "$emojiFolder"
|
||||
|
||||
# load $MASTODON_INSTANCE/api/v1/custom_emojis with curl into a variable
|
||||
|
||||
customEmojisJson=$(curl -s "$MASTODON_INSTANCE/api/v1/custom_emojis")
|
||||
|
||||
|
||||
shortcodes=$(echo "$customEmojisJson" | jq -r '.[].shortcode')
|
||||
readarray -t shortcodesArray <<< "$shortcodes"
|
||||
urls=$(echo "$customEmojisJson" | jq -r '.[].url')
|
||||
readarray -t urlsArray <<< "$urls"
|
||||
visible_in_pickers=$(echo "$customEmojisJson" | jq -r '.[].visible_in_picker')
|
||||
readarray -t visible_in_pickersArray <<< "$visible_in_pickers"
|
||||
|
||||
# read through the urls and download the emojis
|
||||
for ((i=0; i<${#shortcodesArray[@]}; i++)); do
|
||||
# if not visible_in_pickers, continue
|
||||
if [ "${visible_in_pickersArray[$i]}" != "true" ]; then
|
||||
echo "Skipping ${shortcodesArray[$i]} because it is not visible in the picker"
|
||||
continue
|
||||
fi
|
||||
url="${urlsArray[$i]}"
|
||||
# get only extension from the url
|
||||
fileext=$(echo "$url" | sed 's/.*\///' | sed 's/.*\.//')
|
||||
# filename is shortcode + extension
|
||||
filename="${shortcodesArray[$i]}.$fileext"
|
||||
# download the emoji
|
||||
# if file already exists, skip
|
||||
if [ -f "$emojiFolder/$filename" ]; then
|
||||
echo "Skipping $filename because it already exists"
|
||||
continue
|
||||
fi
|
||||
echo "Downloading $filename"
|
||||
curl -s "$url" -o "$emojiFolder/$filename"
|
||||
done
|
Loading…
Reference in New Issue