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 deletions
—
download
Diffstat
Diff options
+2/-1
M scripts/xkcd/README
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
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
|
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
|