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