-
-
Notifications
You must be signed in to change notification settings - Fork 449
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
fix: properly display shipped badges
- Loading branch information
Showing
4 changed files
with
69 additions
and
37 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,28 @@ | ||
import sys | ||
import json | ||
from pathlib import Path | ||
|
||
|
||
def trim_version(version): | ||
base_url = version["image_url_1x"].removesuffix("1") | ||
assert version["image_url_2x"] == base_url + "2" | ||
assert version["image_url_4x"] == base_url + "3" | ||
v = { | ||
"id": version["id"], | ||
"title": version["title"], | ||
"image": base_url, | ||
} | ||
if version["click_url"]: | ||
v["url"] = version["click_url"] | ||
return v | ||
|
||
|
||
raw = sys.stdin.read() | ||
assert len(raw) > 0, "Response from Helix' chat/badges/global needs to be piped" | ||
base = json.loads(raw)["data"] | ||
out = {set["set_id"]: [trim_version(v) for v in set["versions"]] for set in base} | ||
|
||
with open( | ||
Path(__file__).parent.parent / "resources" / "twitch-badges.json", mode="w" | ||
) as f: | ||
f.write(json.dumps(out, separators=(",", ":"))) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters