Fix duplicate icon assignment
This commit is contained in:
parent
ad28b6e81e
commit
4017b4ab72
211 changed files with 782 additions and 6 deletions
28
scripts/download_icons.py
Normal file
28
scripts/download_icons.py
Normal file
|
@ -0,0 +1,28 @@
|
|||
import json
|
||||
from urllib.request import urlopen, Request
|
||||
from pathlib import Path
|
||||
|
||||
ICON_LIST_URL = "https://cc0-icons.jonh.eu/icons.json"
|
||||
BASE_URL = "https://cc0-icons.jonh.eu/"
|
||||
|
||||
OUTPUT_DIR = Path(__file__).resolve().parent.parent / "static" / "icons"
|
||||
|
||||
|
||||
def main() -> None:
|
||||
OUTPUT_DIR.mkdir(parents=True, exist_ok=True)
|
||||
req = Request(ICON_LIST_URL, headers={"User-Agent": "Mozilla/5.0"})
|
||||
with urlopen(req) as resp:
|
||||
data = json.load(resp)
|
||||
icons = data.get("icons", [])
|
||||
for icon in icons:
|
||||
slug = icon.get("slug")
|
||||
url = BASE_URL + icon.get("url")
|
||||
path = OUTPUT_DIR / f"{slug}.svg"
|
||||
req = Request(url, headers={"User-Agent": "Mozilla/5.0"})
|
||||
with urlopen(req) as resp:
|
||||
path.write_bytes(resp.read())
|
||||
print(f"Downloaded {len(icons)} icons to {OUTPUT_DIR}")
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
Loading…
Add table
Add a link
Reference in a new issue