|
1 |
| -import sys, argparse, requests |
| 1 | +import sys, json, argparse, requests |
2 | 2 |
|
3 | 3 | import classes.class_gh as gh
|
4 | 4 | import classes.class_es as es
|
|
29 | 29 | 'Authorization': f'token {args.gh_token}'
|
30 | 30 | }
|
31 | 31 |
|
32 |
| - strict_fetch = ['images'] |
33 |
| - fetch_fix = ['images_sdk'] |
34 |
| - |
35 | 32 | err = False
|
36 | 33 | for indexed_item in es_instance.indexed_items:
|
37 | 34 | asset_status = requests.get(indexed_item['source']['download_link'], headers=headers)
|
38 | 35 | if es_instance.Status.ERROR.value == asset_status.status_code: ## code 404 - error, reindex with correct download link
|
39 | 36 | err = True
|
40 | 37 | print("%sERROR: Asset \"%s\" download link is incorrect. - %s" % (es_instance.Colors.FAIL, indexed_item['source']['name'], indexed_item['source']['download_link']))
|
41 | 38 | if not args.log_only:
|
42 |
| - loose = True |
43 |
| - if indexed_item['source']['name'] in strict_fetch: |
44 |
| - loose = False |
45 |
| - check_package = indexed_item['source']['name'] |
46 |
| - if indexed_item['source']['name'] in fetch_fix: |
47 |
| - check_package = indexed_item['source']['name'][:-4] |
48 |
| - url = gh_instance.asset_fetch_url_api(check_package, loose=loose) |
| 39 | + package_name = (json.loads(asset_status.text))['name'] |
| 40 | + url = gh_instance.asset_fetch_url_api(package_name, loose=False) |
49 | 41 | indexed_item['source']['download_link'] = url
|
50 | 42 | es_instance.update(indexed_item['doc']['type'], indexed_item['doc']['id'], indexed_item['source'])
|
51 | 43 | else: ## code 200 - success, no need to reindex
|
|
0 commit comments