Skip to content

Commit

Permalink
Adds a script for updating CID.
Browse files Browse the repository at this point in the history
May be run at any time after generation. Correctly sets CID path on IPFS.
  • Loading branch information
Jon-Becker committed Mar 18, 2022
1 parent da22400 commit 2484046
Show file tree
Hide file tree
Showing 3 changed files with 44 additions and 0 deletions.
Binary file modified .DS_Store
Binary file not shown.
3 changes: 3 additions & 0 deletions .gitignore
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/
41 changes: 41 additions & 0 deletions update_cid.ipynb
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
}

0 comments on commit 2484046

Please sign in to comment.