fix-qrcode-url.py 698 B

123456789101112131415161718192021
  1. """批量替换 api-config.json 中的 qrCodeUrl,UTF-8 安全"""
  2. import os, glob
  3. old = "authid=T0iOotHcDX"
  4. new = "user={{user}}&apigid={{apigid}}&fun_id=HOkkX72PMF"
  5. root = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
  6. pattern = os.path.join(root, "**", "api-config.json")
  7. count = 0
  8. for f in glob.glob(pattern, recursive=True):
  9. with open(f, "r", encoding="utf-8") as fh:
  10. content = fh.read()
  11. if old in content:
  12. content = content.replace(old, new)
  13. with open(f, "w", encoding="utf-8", newline="\n") as fh:
  14. fh.write(content)
  15. count += 1
  16. print(f"Updated: {os.path.relpath(f, root)}")
  17. print(f"\nTotal: {count} files updated")