add cache
This commit is contained in:
parent
47e573c6d0
commit
21ea9856ee
|
@ -18,6 +18,7 @@ jobs:
|
||||||
- uses: actions/setup-python@v4
|
- uses: actions/setup-python@v4
|
||||||
with:
|
with:
|
||||||
python-version: '3.10'
|
python-version: '3.10'
|
||||||
|
cache: 'pip'
|
||||||
- name: Update data
|
- name: Update data
|
||||||
run: |
|
run: |
|
||||||
pip install -r requirements.txt
|
pip install -r requirements.txt
|
||||||
|
|
|
@ -49,7 +49,6 @@ def get_url_slug(kb_id):
|
||||||
except urllib.error.HTTPError as response:
|
except urllib.error.HTTPError as response:
|
||||||
if 'location' in response.headers:
|
if 'location' in response.headers:
|
||||||
l = response.headers['location']
|
l = response.headers['location']
|
||||||
print(l)
|
|
||||||
return l.split('/')[-1]
|
return l.split('/')[-1]
|
||||||
else:
|
else:
|
||||||
return None
|
return None
|
||||||
|
@ -66,18 +65,13 @@ def update_mapping(kb_ids):
|
||||||
for kb_id in kb_ids:
|
for kb_id in kb_ids:
|
||||||
i=i+1
|
i=i+1
|
||||||
if kb_id not in kb:
|
if kb_id not in kb:
|
||||||
print(kb_id)
|
|
||||||
slug = get_url_slug(kb_id)
|
slug = get_url_slug(kb_id)
|
||||||
if slug:
|
if slug:
|
||||||
print(slug)
|
|
||||||
new_data = parse_redirect(kb_id, slug)
|
new_data = parse_redirect(kb_id, slug)
|
||||||
print(new_data)
|
|
||||||
if new_data:
|
if new_data:
|
||||||
updated = True
|
updated = True
|
||||||
kb[kb_id] = new_data
|
kb[kb_id] = new_data
|
||||||
print(f"Status: {i}/{len(kb_ids)}")
|
print(f"Status: {i}/{len(kb_ids)}")
|
||||||
else:
|
|
||||||
print("no slug")
|
|
||||||
|
|
||||||
if updated:
|
if updated:
|
||||||
with open('data.json', 'w') as f:
|
with open('data.json', 'w') as f:
|
||||||
|
|
Loading…
Reference in New Issue