-
Notifications
You must be signed in to change notification settings - Fork 127
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
May be run at any time after generation. Correctly sets CID path on IPFS.
- Loading branch information
1 parent
da22400
commit 2484046
Showing
3 changed files
with
44 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,2 +1,5 @@ | ||
.python-version | ||
workspace.code-workspace | ||
metadata/*.json | ||
images/*.png | ||
.ipynb_checkpoints/ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
{ | ||
"cells": [ | ||
{ | ||
"cell_type": "code", | ||
"execution_count": null, | ||
"metadata": {}, | ||
"outputs": [], | ||
"source": [ | ||
"from IPython.display import display \n", | ||
"from PIL import Image\n", | ||
"import random\n", | ||
"import json\n", | ||
"import os\n", | ||
"\n", | ||
"f = open('./metadata/all-objects.json')\n", | ||
"all_images = json.load(f)\n", | ||
"\n", | ||
"cid = input(\"IPFS Image CID (): \")\n", | ||
"if len(cid) > 0:\n", | ||
" if not cid.startswith(\"ipfs://\"):\n", | ||
" cid = \"ipfs://{}\".format(cid)\n", | ||
" if cid.endswith(\"/\"):\n", | ||
" cid = cid[:-1]\n", | ||
" for i, item in enumerate(all_images):\n", | ||
" with open('./metadata/' + str(item[\"tokenId\"]) + '.json', 'r') as infile:\n", | ||
" original_json = json.loads(infile.read())\n", | ||
" original_json[\"image\"] = original_json[\"image\"] = f'{cid}/{str(item[\"tokenId\"])}.png'\n", | ||
" with open('./metadata/' + str(item[\"tokenId\"]) + '.json', 'w') as outfile:\n", | ||
" json.dump(original_json, outfile, indent=4)" | ||
] | ||
} | ||
], | ||
"metadata": { | ||
"language_info": { | ||
"name": "python" | ||
}, | ||
"orig_nbformat": 4 | ||
}, | ||
"nbformat": 4, | ||
"nbformat_minor": 2 | ||
} |