aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorTulir Asokan <tulir@maunium.net>2020-09-08 14:55:07 +0300
committerTulir Asokan <tulir@maunium.net>2020-09-08 14:55:07 +0300
commit314f6c0ff564f955f13f4aee85b4865a960f3303 (patch)
tree8d1baf7a2b1634bf3bf2685ca907270896008a48
parent3ef92d588ab7bd99a38945a4dd7dff487283aa23 (diff)
Add namespacing for IDs
-rw-r--r--import.py14
1 files changed, 9 insertions, 5 deletions
diff --git a/import.py b/import.py
index bb1438d..cd917ed 100644
--- a/import.py
+++ b/import.py
@@ -142,7 +142,9 @@ def add_to_index(name: str) -> None:
with open(index_path) as index_file:
index_data = json.load(index_file)
except (FileNotFoundError, json.JSONDecodeError):
- index_data = {"packs": [], "homeserver_url": homeserver_url}
+ index_data = {"packs": []}
+ if "homeserver_url" not in index_data:
+ index_data["homeserver_url"] = homeserver_url
if name not in index_data["packs"]:
index_data["packs"].append(name)
with open(index_path, "w") as index_file:
@@ -154,7 +156,7 @@ def add_meta(document: Document, info: 'MatrixStickerInfo', pack: StickerSetFull
for attr in document.attributes:
if isinstance(attr, DocumentAttributeSticker):
info["body"] = attr.alt
- info["id"] = str(document.id)
+ info["id"] = f"tg-{document.id}"
info["net.maunium.telegram.sticker"] = {
"pack": {
"id": str(pack.set.id),
@@ -212,9 +214,11 @@ async def reupload_pack(client: TelegramClient, pack: StickerSetFull) -> None:
with open(pack_path, "w") as pack_file:
json.dump({
"title": pack.set.title,
- "short_name": pack.set.short_name,
- "id": str(pack.set.id),
- "hash": str(pack.set.hash),
+ "id": f"tg-{pack.set.id}",
+ "net.maunium.telegram.pack": {
+ "short_name": pack.set.short_name,
+ "hash": str(pack.set.hash),
+ },
"stickers": list(reuploaded_documents.values()),
}, pack_file, ensure_ascii=False)
print(f"Saved {pack.set.title} as {pack.set.short_name}.json")
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage