keyguard-app-Bitwarden-Vaul.../.github/update_justgetmydata.py
2024-05-25 13:05:07 +03:00

36 lines
927 B
Python

import json
import requests
URL_JGMD = "https://raw.githubusercontent.com/daviddavo/jgmd/master/_data/sites.json"
response = requests.get(
URL_JGMD,
)
aggr = []
for site in response.json():
entry = {
'name': site['name'],
'domains': site.get('domains', []),
}
def append_if_not_empty(src_key, dst_key):
if src_key in site and site[src_key]:
entry[dst_key] = site[src_key]
append_if_not_empty('url', 'url')
append_if_not_empty('difficulty', 'difficulty')
append_if_not_empty('notes', 'notes')
# for the extra-asshole websites
append_if_not_empty('email', 'email')
append_if_not_empty('email_subject', 'email_subject')
append_if_not_empty('email_body', 'email_body')
aggr.append(entry)
aggr_text = json.dumps(aggr, indent=2)
with open('common/src/commonMain/composeResources/files/justgetmydata.json', 'w') as f:
f.write(aggr_text)