-
Notifications
You must be signed in to change notification settings - Fork 0
/
readrepos.py
41 lines (37 loc) · 1000 Bytes
/
readrepos.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
import os
import pytz
import json
import datetime
import requests
import datetime
import dateutil.parser
token = os.environ['GITHUB_TOKEN']
page = 0
last_len = 1
repos = []
include_created_before = datetime.datetime(2024, 1, 19).replace(tzinfo=pytz.UTC)
while last_len != 0:
print(f'page = {page}')
res = requests.get(
'https://api.github.com/orgs/os3224/repos',
headers={
'Accept': 'application/vnd.github+json',
'Authorization': f'Bearer {token}',
},
params={
'sort': 'created',
'direction': 'asc',
'per_page': '100',
'page': str(page),
}
)
data =res.json()
for repo in data:
if include_created_before < dateutil.parser.parse(repo['created_at']):
continue
if repo['is_template'] is True:
continue
repos.append(repo['full_name'])
last_len = len(data)
page += 1
json.dump(repos, open('repos.json', 'w'))