Script to create or update *oma emoji packs by yoinking from other servers
Find a file
Oneric c992995adb Fix empty set detection
A friendly error message here was a last minute addition,
but untested and as it turns out broken. Due to piping the loop executes
in a subshell and thus meta_prefix always retains its original value at
the time of check. Instead actually test for anything being written out.
2024-09-26 02:21:58 +02:00
.gitignore Initial commit 2024-09-25 17:31:59 +02:00
README.rst readme: more spelling 2024-09-25 18:55:27 +02:00
yoink-or-update-emojipack.sh Fix empty set detection 2024-09-26 02:21:58 +02:00

===========
Yoink-Emoji
===========

Lets you yoink emoji packs from any other instance with MastoAPI support,
instead of only shareable packs from other \*oma instances like admin-fe does.

Note this currently might not work as well for updating packs not created by this script.
It expects files to be named after their shortcode, if a meowji already exists but with
a different filename this will leave duplicate images behind.
*(shortcode names are checked to be safe wrt to path traversal before writing anything)*

Installing
==========

Just plop the script somewhere.

A ``.cache`` for remote emoji data will be created at the script location.
*(Caches remain valid within the same UTC day, currently not cleaned up automatically so just `rm -fr .cache` from time to time if it becomes too big)*

Usage
=====

Enter the emoji pack dir (or create a new empty dir for this), then invoke the script;
the third argument is optional:

```
yoink-or-update-emoj.sh domain_of_server_to_be_yoinked_from category_to yoink [additional_conditions]
```

Additionally the following env vars affect the result:

- ``OVERWRITE_IMG=YES``: overwrite existing images instead of skipping download
- ``OVERWRITE_METAKEYS=YES``: overwrite existing shortcode file path entries instead of preserving the original

Example
-------

Yoinking the blobcat pack from an Akkoma instance and also merge any blobcat emotes from another category into the local pack:
```sh
yoink-or-update-emoji.sh example.org "pack:blobcat"  'or (.shortcode | test("blobcatpnd|^ameow|^blobcat|^ablobcat"))'
```

Yoink woozy pack from a Sharkey instance *(no ``pack:`` prefix)*:
```sh
yoink-or-update-emoji.sh example.org "woozy"
```

Merge multiple remote packs into one local pack:
```sh
yoink-or-update-emoji.sh example.org "pack:touhou" 'or .category == "pack:reimu" or .category == "pack:marisa"'
```


Dependencies
============

- POSIX ``sh`` and ``awk`` _(in general all POSIX tools)_
- ``date`` with ``-I`` extension
- jq
- wget **and** curl _(idk why i used both, might remove one at some point)_
- ``mktemp``