Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- import urllib2
- from base64 import b64encode
- import os
- import sys
- import time
- today = time.strftime('%Y-%m-%d_%H-%M-%S')
- with open('nwfcdlc.txt') as file:
- codes = file.readlines()
- for line in codes:
- line = line.split('#')[0] # remove comments
- data = line.split()
- try:
- gamecode = data[0]
- realgamecode = data[1]
- password = data[2]
- except:
- continue
- ###Get token
- url = "http://nas.nintendowifi.net/ac"
- headers = { 'User-Agent' : 'Nitro WiFi SDK/3.1', 'Content-type' : 'application/x-www-form-urlencoded', 'HTTP_X_GAMECD' : gamecode }
- data = "action=bG9naW4*&gsbrcd=QzZQRTBjdTdvaGs*&sdkver=MDAzMDAx&userid=Nzg4MTk4NjAyOTYzMQ**&passwd=Mjk3&bssid=MDBmMDFhMmIzYzRk&apinfo=MDA6MDAwMDAwMC0wMA**&gamecd=" + b64encode(gamecode) + "&makercd=MDE*&unitcd=MA**&macadr=MDAxNjU2ODMzMWY5&lang=MDE*&birth=MDcwYw**&devtime=MTQwNDI5MTkyMjEx&devname=UABhAFIAYQBEAG8AWAA*"
- req = urllib2.Request(url, data, headers)
- response = urllib2.urlopen(req)
- the_page = response.read()
- #open('out1.bin','w').write(the_page)
- data = "sdkver=MDAzMDAx&userid=Nzg4MTk4NjAyOTYzMQ**&passwd=Mjk3&bssid=MDBmMDFhMmIzYzRk&apinfo=MDA6MDAwMDAwMC0wMA**&gamecd=" + b64encode(gamecode) + "&makercd=MDE*&unitcd=MA**&macadr=MDAxNjU2ODMzMWY5&lang=MDE*&birth=MDcwYw**&devtime=MTQwNDI5MTkyMjE5&devname=UABhAFIAYQBEAG8AWAA*&action=U1ZDTE9D&svc=OTAwMA**"
- req = urllib2.Request(url, data, headers)
- response = urllib2.urlopen(req)
- the_page = response.read()
- #open('out2.bin','w').write(the_page)
- token = the_page[the_page.find('vicetoken')+10:] #'servicetoken'
- token = token[:token.find('&')]
- #Create output folder if it doesn't exist
- if not os.path.exists('./' + today ):
- os.makedirs('./'+today)
- if not os.path.exists('./'+today+'/'+realgamecode):
- os.makedirs('./'+today+'/'+realgamecode)
- url = "https://dls1.nintendowifi.net/download"
- headers = { 'User-Agent' : 'Nitro WiFi SDK/3.1', 'Content-type' : 'application/x-www-form-urlencoded'}
- ###List files
- data="gamecd=" + b64encode(gamecode) + "&rhgamecd=" + b64encode(realgamecode) + "&passwd=" + b64encode(password) + "&token=" + token + "&macadr=MDAxNjU2ODMzMWY5&action=" + b64encode('list') + "&apinfo=MDA6MDAwMDAwMC0wMA%2A%2A&offset=" + b64encode('0') + "&num=" + b64encode('999999')
- req = urllib2.Request(url, data, headers)
- response = urllib2.urlopen(req)
- the_page = response.read()
- open('./'+today+'/'+realgamecode+'/___listing___.bin','w').write(the_page) #Save the listing, it sometimes has additional data the game may need
- ###Download files
- lines = the_page[:-1].split('\n')
- if len(lines) == 0:
- print "No files to download for game code " + realgamecode + ", quitting..."
- sys.exit()
- print "Game code " + realgamecode + " has " + str(len(lines)) + " files to download.\n"
- for line in lines:
- fname = line[:line.find('\t')]
- if fname == '':
- continue
- print "Downloading " + fname + "..."
- data="gamecd=" + b64encode(gamecode) + "&rhgamecd=" + b64encode(realgamecode) + "&passwd=" + b64encode(password) + "&token=" + token + "&userid=Nzg4MTk4NjAyOTYzMQ%2A%2A&macadr=MDAxNjU2ODMzMWY5&action=" + b64encode('contents') + "&apinfo=MDA6MDAwMDAwMC0wMA%2A%2A&contents=" + b64encode(fname)
- req = urllib2.Request(url, data, headers)
- response = urllib2.urlopen(req)
- the_page = response.read()
- open('./'+today+'/'+realgamecode+'/'+fname,'wb').write(the_page)
- print "Done!\n"
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement