dotfiles/.config/zsh/functions/mk_dl_emoji

21 lines
583 B
Plaintext
Raw Normal View History

2024-02-04 10:39:46 +01:00
#!/usr/bin/env zsh
# download emojis from a misskey instance
setopt LOCAL_OPTIONS ERR_RETURN NO_UNSET PIPE_FAIL
autoload -U die
[[ ${ARGC} -ne 1 ]] && die 1 "Usage: ${0} <emoji name>"
local instance=very.tastytea.de
local name=${1}
local json=$(curl --silent --json '{"name": "'${name}'"}' \
https://${instance}/api/emoji)
local url=$(jq -r .url <<<${json})
2024-02-10 19:52:11 +01:00
curl --silent --location --output ${name} ${url}
2024-02-04 10:39:46 +01:00
local identification=$(file --extension ${name})
local extension=${${identification##*: }%%/*}
mv ${name} ${name}.${extension}
print "${name}.${extension} downloaded"