diff --git a/scripts/compare.py b/scripts/compare.py new file mode 100644 index 0000000..28d7764 --- /dev/null +++ b/scripts/compare.py @@ -0,0 +1,7 @@ +import hashlib + +with open('public/tags/index.xml') as file: + data = hashlib.sha1(file.read().encode('utf-8')) + +remote = '99d66a9e171feaf11be88b831bc69c55d85c1b4b' +print(remote == data.hexdigest()) diff --git a/scripts/neocities.py b/scripts/neocities.py new file mode 100644 index 0000000..150f2e0 --- /dev/null +++ b/scripts/neocities.py @@ -0,0 +1,29 @@ +from os import environ +from requests import get +from json import dumps + +def request(key: str, uri: str): + url = f'https://neocities.org{uri}' + headers = { 'Authorization': f'Bearer {key}' } + response = get(url, headers=headers) + return response.json() + +def get_new_content(key: str): + ''' + Fetches a list of all files on neocities + ''' + # First fetch the hashes of all our files + response = request(key, '/api/list') + remote_files = response['files'] + + # COmpare remote hashes to local hashes + + +if __name__ == '__main__': + key = environ.get('NEOCITIES_API_KEY') + if key is None: + print('Check to ensure NEOCITIES_API_KEY is set in the env vars') + exit(1) + else: + get_public_contents(key) +