-
Notifications
You must be signed in to change notification settings - Fork 0
/
vscode_updater.py
executable file
·63 lines (53 loc) · 1.97 KB
/
vscode_updater.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
#!/bin/env python3
import json
from urllib import request
def get_extensions():
with open("jonas/desktop/vscodium/extensions.json") as extensions:
return json.load(extensions)
def get_updates(extensions):
for extension in extensions:
name = extension['name']
publisher = extension['publisher']
current_version = extension['version']
req = request.Request('https://marketplace.visualstudio.com/_apis/public/gallery/extensionquery', method='POST')
req.add_header('Content-Type', 'application/json')
req.add_header('Accept', 'application/json;api-version=7.2-preview.1;excludeUrls=true')
data = {
"assetTypes": None,
"filters": [
{
"criteria": [
{
"filterType": 7,
"value": "{0}.{1}".format(publisher, name)
}
],
"direction": 2,
"pageSize": 3,
"pageNumber": 1,
"sortBy": 0,
"sortOrder": 0,
"pagingToken": None
}
],
"flags": 2151
}
data = json.dumps(data)
data = data.encode()
response = request.urlopen(req, data=data)
payload = json.load(response)
versions = payload['results'][0]['extensions'][0]['versions']
get_condensed_version = list(map(lambda i: {
'publisher': publisher,
'name': name,
'versions': {
'current': current_version,
'latest': i['version'],
'update_available': current_version != i['version']
}
}, versions))
# TODO: Create option to only list extensions with available updates.
print(get_condensed_version[0])
if __name__ == '__main__':
extensions = get_extensions()
get_updates(extensions)