Skip to content

Instantly share code, notes, and snippets.

@zwrawr
Created October 4, 2021 22:31
Show Gist options
  • Save zwrawr/b2f11dbb48e8a039f63a075b0a427707 to your computer and use it in GitHub Desktop.
Save zwrawr/b2f11dbb48e8a039f63a075b0a427707 to your computer and use it in GitHub Desktop.
import requests
import time
import sys
i = 10 # starting shrub id
API = "https://api.ldjam.com/"
GET = "vx/node2/get/"
JAMMER = "https://static.jam.vg/"
INC_SIZE = 100
SMALL_IMG = ".64x64.fit.png"
def buildrequesturl(base , amount):
url = API + GET
for x in range(0,amount):
if (x!=0):
url+="+"
url+=str(base+x)
return url
with open("brokenimg.txt", "a") as file:
while True:
session = requests.Session()
nodes = session.get(buildrequesturl(i,INC_SIZE)).json()
if ('node' in nodes and len(nodes['node']) > 0):
for n in nodes['node'] :
if ('type' in n and n['type'] == 'user') :
desc = str(n['id']) + ", " + n['slug'] + ", " + n['path']
if (('meta' in n) and ('avatar' in n['meta']) and n['meta']['avatar']):
desc += ", " + JAMMER + n['meta']['avatar'][3:]
small = JAMMER + n['meta']['avatar'][3:] + SMALL_IMG
desc += ", " + small
hasimg = True
try:
hasimg = session.head(small).ok # use HEAD method so we don't have to actually download the imgs
except:
hasimg = False
if hasimg == False :
file.write(desc + "\n")
desc = "[ERR] "+desc+" \n"## attempts to remove the last line fully
sys.stdout.flush()
print(desc, end=" \r")
time.sleep(0.01) ## the requests package is synchronus so there is already delay from the request round trip time
i+=INC_SIZE
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment