-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathupdate_versions.py
45 lines (31 loc) · 1.01 KB
/
update_versions.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
#!/usr/bin/python
import os
import sys
import json
import requests
from http import HTTPStatus
with open('./extensions.txt', 'r') as f:
extensions = f.read().splitlines()
base_url = 'https://extensions.gnome.org/api/v1/extensions'
wants = int(sys.argv[1])
for ext in extensions:
if ext.startswith('#'):
continue
print('-'*50)
not_found = False
target_ver, next_page = False, f'{base_url}/{ext}/versions'
while next_page and not target_ver:
print(f'Fetching page {next_page}')
r = requests.get(next_page)
if not r.content:
print(f'Skipping {ext}, (status: {r.status_code})')
not_found = True
break
jd = json.loads(r.content)
next_page = jd['next']
filtered = [item for item in jd['results'] if item['shell_versions'][-1]['major'] == wants ]
if len(filtered):
target_ver = filtered[-1]['version']
if not_found:
continue
print(f'{ext} -- {target_ver}')