diff --git a/scripts/xkcd/README b/scripts/xkcd/README index 8a82de2..bc021ad 100644 --- a/scripts/xkcd/README +++ b/scripts/xkcd/README @@ -1,4 +1,5 @@ Download XKCD comics. API is available at https://xkcd.com/json.html - mkdir nodes images + mkdir nodes + mkdir --parents images/xkcd/ START_NUMBER=1 END_NUMBER=10 ./xkcd.py diff --git a/scripts/xkcd/xkcd.py b/scripts/xkcd/xkcd.py index c37e4e6..211d7f3 100755 --- a/scripts/xkcd/xkcd.py +++ b/scripts/xkcd/xkcd.py @@ -44,7 +44,7 @@ for n in range(START_NUMBER, END_NUMBER + 1): node_id = f"xkcd_comic_{n}" - blob_filename = f'{node_id}{image_extension}' + blob_file = f'images/xkcd/{node_id}{image_extension}' node = { "@context": { @@ -68,14 +68,14 @@ for n in range(START_NUMBER, END_NUMBER + 1): "comicstrip:xkcd_alt": data['alt'], "comicstrip:number": data['num'], "blob:at": { - "@id": f"file:/images/{blob_filename}", + "@id": f"file:/{blob_file}", "blob:primary_source": data['img'], "blob:retrieval_date": f"{datetime.now().year}-{datetime.now().month}-{datetime.now().day}" } } # Download image - wget_ret = subprocess.run(['wget', '--quiet', '--output-document', f'images/{blob_filename}', data['img']]) + wget_ret = subprocess.run(['wget', '--quiet', '--output-document', blob_file, data['img']]) assert wget_ret.returncode == 0 # No errors # Save node to file