Docker container for the Unifi controller application
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.

getversions.py 984B

1234567891011121314151617181920212223242526272829
  1. #!/usr/bin/python3
  2. import json
  3. import requests
  4. from distutils.version import StrictVersion
  5. headers = {'Accept': 'application/json', 'X-Requested-With': 'XMLHttpRequest'}
  6. host = 'https://www.ubnt.com'
  7. address = host + '/download/?platform=unifi'
  8. r = requests.get(address, headers=headers)
  9. versions = []
  10. dls = [d for d in r.json()['downloads'] if d['filename'] == 'unifi_sysvinit_all.deb']
  11. for d in dls:
  12. version = StrictVersion(d['version'][1:] if d['version'][0] == 'v' else d['version'])
  13. changelog = d['changelog']
  14. uri = host + d['file_path']
  15. versions.append((version, changelog, uri))
  16. versions = sorted(versions, key=lambda x: x[0], reverse=True)
  17. labels = dict([('latest', versions[0])] + [(str(v[0]), v) for v in versions])
  18. for i in range(20):
  19. try:
  20. labels[str(i)] = next(v for v in versions if str(v[0])[0:2] == str(i) + '.')
  21. except StopIteration:
  22. pass
  23. for k, label in labels.items():
  24. print("%s %s" % (k, ' '.join(map(str, label))))