From a8effa2efa0bc41173bf086742bbe615ee733091 Mon Sep 17 00:00:00 2001 From: Daniel Kilimnik Date: Tue, 25 Mar 2025 18:46:43 +0100 Subject: Save and server thumbnails locally (#88) Fixes #83 Fixes #86 Fixes #87 --- sticker/pack.py | 5 +++++ 1 file changed, 5 insertions(+) (limited to 'sticker/pack.py') 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 . +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) -- cgit v1.2.3