diff options
| author | Daniel Kilimnik <mail@kilimnik.de> | 2025-03-25 18:46:43 +0100 |
|---|---|---|
| committer | GitHub <noreply@github.com> | 2025-03-25 19:46:43 +0200 |
| commit | a8effa2efa0bc41173bf086742bbe615ee733091 (patch) | |
| tree | 86133f163db3c88d9455be7250bca8f3f4a526c0 /sticker/pack.py | |
| parent | 89d3aece041c85ebe5a1ad4e620388af5227cbb0 (diff) | |
Save and server thumbnails locally (#88)
Fixes #83
Fixes #86
Fixes #87
Diffstat (limited to 'sticker/pack.py')
| -rw-r--r-- | sticker/pack.py | 5 |
1 files changed, 5 insertions, 0 deletions
diff --git a/sticker/pack.py b/sticker/pack.py index f082370..a4ca1f2 100644 --- a/sticker/pack.py +++ b/sticker/pack.py @@ -13,6 +13,7 @@ # # You should have received a copy of the GNU Affero General Public License # along with this program. If not, see <https://www.gnu.org/licenses/>. +from pathlib import Path from typing import Dict, Optional from hashlib import sha256 import mimetypes @@ -107,9 +108,11 @@ async def main(args: argparse.Namespace) -> None: old_stickers = {sticker["id"]: sticker for sticker in pack["stickers"]} pack["stickers"] = [] + stickers_data: Dict[str, bytes] = {} for file in sorted(os.listdir(args.path)): sticker = await upload_sticker(file, args.path, old_stickers=old_stickers) if sticker: + stickers_data[sticker["url"]] = Path(args.path, file).read_bytes() pack["stickers"].append(sticker) with util.open_utf8(meta_path, "w") as pack_file: @@ -122,6 +125,8 @@ async def main(args: argparse.Namespace) -> None: with util.open_utf8(picker_pack_path, "w") as pack_file: json.dump(pack, pack_file) print(f"Copied pack to {picker_pack_path}") + + util.add_thumbnails(pack["stickers"], stickers_data, args.add_to_index) util.add_to_index(picker_file_name, args.add_to_index) |
