#!/usr/bin/env nix-shell #!nix-shell -i python3 -p python3Packages.requests import base64 import json import plistlib import requests from typing import Dict, Any, List assets = plistlib.loads( requests.get( "https://mesu.apple.com/assets/com_apple_MobileAsset_Font7/com_apple_MobileAsset_Font7.xml" ).content )["Assets"] families: Dict[str, Any] = dict() all_assets: List[Dict[str, str]] = [] for asset in assets: # Period used for extra PUA font names = set( [ info["FontFamilyName"] for info in asset["FontInfo4"] if not info["FontFamilyName"].startswith(".") ] ) name = names.pop() # There seems to be some support for things other than SHA-1 but I haven't seen it hsh = "sha1-" + base64.b64encode(asset["_Measurement"]).decode("utf-8") url = asset["__BaseURL"] + asset["__RelativePath"] asset_obj = { "url": url, "hash": hsh, } all_assets.append(asset_obj) version = asset["_CompatibilityVersion"] if len(names) > 1: print("Multiple family names found in asset:", ", ".join(names)) if name in families: other_version = families[name]["version"] if version == other_version: families[name]["assets"].append(asset_obj) continue elif int(version) < int(other_version): print(f"Duplicate asset found for family {name}, skipping") continue families[name] = { "assets": [asset_obj], "version": version, } with open("assets.json", "w") as f: json.dump( {"extra": families, "all_extra": {"assets": all_assets, "version": "mixed"}}, f )