home » zplus/dokk.git
Author zPlus <zplus@peers.community> 2024-12-25 11:47:00
Committer zPlus <zplus@peers.community> 2024-12-25 11:47:00
Commit 92ed601 (patch)
Tree e4396d7
Parent(s)

[XKCD] Change images folder.


commits diff: eef7389..92ed601
2 files changed, 5 insertions, 4 deletionsdownload


Diffstat
-rw-r--r-- scripts/xkcd/README 3
-rwxr-xr-x scripts/xkcd/xkcd.py 6

Diff options
View
Side
Whitespace
Context lines
Inter-hunk lines
+2/-1 M   scripts/xkcd/README
index 8a82de2..bc021ad
old size: 136B - new size: 162B
@@ -1,4 +1,5 @@
1 1 Download XKCD comics. API is available at https://xkcd.com/json.html
2 2
3 - mkdir nodes images
3 + mkdir nodes
4 + mkdir --parents images/xkcd/
4 5 START_NUMBER=1 END_NUMBER=10 ./xkcd.py

+3/-3 M   scripts/xkcd/xkcd.py
index c37e4e6..211d7f3
old size: 3K - new size: 3K
@@ -44,7 +44,7 @@ for n in range(START_NUMBER, END_NUMBER + 1):
44 44
45 45 node_id = f"xkcd_comic_{n}"
46 46
47 - blob_filename = f'{node_id}{image_extension}'
47 + blob_file = f'images/xkcd/{node_id}{image_extension}'
48 48
49 49 node = {
50 50 "@context": {
@@ -68,14 +68,14 @@ for n in range(START_NUMBER, END_NUMBER + 1):
68 68 "comicstrip:xkcd_alt": data['alt'],
69 69 "comicstrip:number": data['num'],
70 70 "blob:at": {
71 - "@id": f"file:/images/{blob_filename}",
71 + "@id": f"file:/{blob_file}",
72 72 "blob:primary_source": data['img'],
73 73 "blob:retrieval_date": f"{datetime.now().year}-{datetime.now().month}-{datetime.now().day}"
74 74 }
75 75 }
76 76
77 77 # Download image
78 - wget_ret = subprocess.run(['wget', '--quiet', '--output-document', f'images/{blob_filename}', data['img']])
78 + wget_ret = subprocess.run(['wget', '--quiet', '--output-document', blob_file, data['img']])
79 79 assert wget_ret.returncode == 0 # No errors
80 80
81 81 # Save node to file