Recently Written · git

subread-extension

Show your own .srt over a YouTube video, in time with it. Chrome and Firefox.

git clone https://github.com/equwal/subread-extension

Log | Files | Refs


tools/pack.py (1050 bytes)

1 """Make the two store uploads: dist/subread-chrome.zip and dist/subread-firefox.zip.
2 
3 The same files go to both stores. Chrome does not know the key
4 "browser_specific_settings" and warns about it, so the Chrome zip leaves it out.
5 """
6 import json, pathlib, zipfile
7 
8 ROOT = pathlib.Path(__file__).resolve().parent.parent
9 FILES = ["popup.html", "LICENSE", *sorted(str(p.relative_to(ROOT)).replace("\\", "/")
10          for d in ("src", "icons") for p in (ROOT / d).iterdir())]
11 
12 def pack(name: str, manifest: dict) -> None:
13     out = ROOT / "dist" / name
14     out.parent.mkdir(exist_ok=True)
15     with zipfile.ZipFile(out, "w", zipfile.ZIP_DEFLATED) as z:
16         z.writestr("manifest.json", json.dumps(manifest, indent=2))
17         for f in FILES:
18             z.write(ROOT / f, f)
19     print(out.relative_to(ROOT), out.stat().st_size, "bytes")
20 
21 manifest = json.loads((ROOT / "manifest.json").read_text(encoding="utf-8"))
22 pack("subread-firefox.zip", manifest)
23 pack("subread-chrome.zip", {k: v for k, v in manifest.items() if k != "browser_specific_settings"})