Skip to content

Instantly share code, notes, and snippets.

@sonya75
Last active November 22, 2022 16:12
Show Gist options
  • Save sonya75/7e982258187820a409c7ff598abfd63c to your computer and use it in GitHub Desktop.
Save sonya75/7e982258187820a409c7ff598abfd63c to your computer and use it in GitHub Desktop.
ACCOUNTFILE="accounts.txt"
PROXYFILE="proxies.txt"
MAXTHREADS=50
OUTPUTFILE="entries.txt"
PRODUCTID="cdcb1066-2c38-5ec7-990a-b9cdf6387269" # US OW release
MININTERVAL=1
try:
PROXYLIST=open(PROXYFILE,'r').read().split("\n")
PROXYLIST=[p.strip() for p in PROXYLIST if p.strip()!=""]
except:
PROXYLIST=[None]
from timedqueue import TimedQueue
allLocks={}
for p in PROXYLIST:
m=TimedQueue()
allLocks[p]=m
m.put(1)
import Queue
import random
PROXYQUEUE=Queue.Queue()
random.shuffle(PROXYLIST)
for p in PROXYLIST:
PROXYQUEUE.put(p)
def getproxy():
v=PROXYQUEUE.get()
PROXYQUEUE.put(v)
return v
def getLock(prox):
allLocks[prox].get()
allLocks[prox].put(1,MININTERVAL)
import requests
from requests.packages.urllib3.exceptions import InsecureRequestWarning,SubjectAltNameWarning
requests.packages.urllib3.disable_warnings(InsecureRequestWarning)
requests.packages.urllib3.disable_warnings(SubjectAltNameWarning)
sess=requests.session()
sess.headers.update({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Accept-Language":"en-US,en;q=0.9,ms;q=0.8"})
LAUNCHID=sess.get("https://api.nike.com/launch/launch_views/v2?filter=productId("+PRODUCTID+")",proxies={"https":random.choice(PROXYLIST)},verify=False,timeout=30).json()["objects"][0]["id"]
print "Launch ID: {0}".format(LAUNCHID)
skudata=sess.get("https://api.nike.com/merch/skus/v2/?filter=productId("+PRODUCTID+")").json()
SKUS={}
for p in skudata["objects"]:
SKUS[p["id"]]=p["merchGroup"]+" "+p["nikeSize"]
print "SKUID {0}: {1}".format(p['id'],p['merchGroup']+" "+p["nikeSize"])
del sess
def checkacc(x):
v=x.split(":")
sess=requests.session()
prox=getproxy()
m_login_data = {'keepMeLoggedIn':True, 'client_id':'PbCREuPr3iaFANEDjtiEzXooFl7mXGQ7','ux_id':'com.nike.commerce.snkrs.droid','grant_type':'password','username':v[0],'password':v[1]}
sess.headers.update({"User-Agent":"Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36","Accept":"*/*","Accept-Encoding":"gzip, deflate, br","Accept-Language":"en-US,en;q=0.9,ms;q=0.8"})
getLock(prox)
e=sess.post('https://api.nike.com/idn/shim/oauth/2.0/token',proxies={"https":prox},json=m_login_data,verify=False,timeout=30)
TOKEN=e.json()["access_token"]
getLock(prox)
ee=sess.get("https://api.nike.com/launch/entries/v2",headers={"Authorization":("Bearer "+TOKEN)},proxies={"https":prox}).json()
for ps in ee["objects"]:
if ps["launchId"]!=LAUNCHID:
continue
with globallock:
sku=ps["skuId"]
if sku in SKUS:
sku=SKUS[sku]
vb=open(OUTPUTFILE,'a')
vb.write(x+"\t"+sku+"\t"+ps['result']['status']+"\t"+str(ps["result"].get("reason"))+"\n")
vb.close()
print ee
vl=open(ACCOUNTFILE,'r').read().split("\n")
import Queue
vq=Queue.Queue()
for pl in vl:
pl=pl.strip()
if pl!="":
vq.put(pl)
def dochecks():
while True:
try:
b=vq.get_nowait()
except:
return
try:
checkacc(b)
except Exception as e:
print e
vq.put(b)
from threading import Thread,Lock
globallock=Lock()
for i in range(0,MAXTHREADS):
Thread(target=dochecks).start()
@anenger
Copy link

anenger commented Apr 28, 2018

What is the "TimedQueue" module? Cannot find it using pip and cannot run the script without it.

@sonya75
Copy link
Author

sonya75 commented Apr 30, 2018

Get it from the NikeAccountGenerator repo. There is a file named timedqueue.py there.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment