Skip to content

Instantly share code, notes, and snippets.

@TheRightChoyce
Created February 8, 2022 23:40
Show Gist options
  • Save TheRightChoyce/5fb5836851516fe7fe1c4ea3fe44b6e3 to your computer and use it in GitHub Desktop.
Save TheRightChoyce/5fb5836851516fe7fe1c4ea3fe44b6e3 to your computer and use it in GitHub Desktop.
Update metadata on a whole collection
# OpenSea Refresher
# Best if run cooperatively, once or twice a day
# Worst if run individually, surely attracting attention
from unittest import result
import requests
import time
collection_addresses = [
'0x...',
]
start_index = 4001
end_index = 5000
for collection_address in collection_addresses:
url = "https://api.opensea.io/asset/" + collection_address + "/"
update_flag = "/?force_update=true"
ids = [i for i in range(start_index, end_index)]
results = []
error_count = 0
for i in ids:
success = False
req_url = url + str(i) + update_flag
r = requests.get(req_url)
print(i, r.status_code)
if r.status_code == 200 or r.status_code == 404:
success = True
error_count = 0
time.sleep(.5)
else:
while success == False and error_count < 5:
sleep_time = 60 + error_count * 60
error_count = error_count + 1
print(f' sleeping for -> {sleep_time}')
time.sleep(sleep_time)
r = requests.get(req_url)
print(i, r.status_code)
if r.status_code == 200 or r.status_code == 404:
success = True
error_count = 0
time.sleep(.3)
results.append({
'index': i,
'result': r.status_code
})
print(f'{collection_address} complete!')
print('')
time.sleep(2.5)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment