You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

39 lines
889B

  1. import sys
  2. import os
  3. import glob
  4. import json
  5. import re
  6. import requests
  7. mg_filename = "ModularGrid-VCVLibrary.json"
  8. # with open(mg_filename) as f:
  9. # mg = json.load(f)
  10. mg = []
  11. for manifest_filename in glob.glob('manifests/*.json'):
  12. slug = os.path.splitext(os.path.basename(manifest_filename))[0]
  13. with open(manifest_filename) as f:
  14. plugin = json.load(f)
  15. for module in plugin.get("modules", []):
  16. mg_url = module.get("modularGridUrl")
  17. if not mg_url:
  18. continue
  19. r = requests.get(mg_url)
  20. m = re.search(r'data-module-id = "(\d+)"', r.text)
  21. mg_id = m.group(1)
  22. if not mg_id:
  23. continue
  24. mg_id = int(mg_id)
  25. library_url = f"https://library.vcvrack.com/{plugin['slug']}/{module['slug']}"
  26. module_data = {"mgModuleId": mg_id, "vcvUrl": library_url}
  27. mg.append(module_data)
  28. print(mg_id)
  29. print(library_url)
  30. with open(mg_filename, 'w') as f:
  31. json.dump(mg, f, indent=2)