Created
May 16, 2014 23:18
-
-
Save ToadKing/5507f4c59d5886cfa5d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import urllib2 | |
from base64 import b64encode | |
import os | |
import sys | |
###Change these to change what game to download for | |
gamecode = 'RSBE' | |
gamecode2 = 'RVL-RSBJ' | |
svc = '9001' | |
password = 'LeNKXTpZy9Y48swJ' | |
cfc = '7615213554627182' | |
csnum = 'LU591603598' | |
#gsbrcd = 'RSBJ3d384f4' | |
#gamecode = 'R2WP' | |
#gamecode2 = 'RVL-R2WP' | |
#svc = '9001' | |
#password = 'xusCH9M3gvWyL2RA' | |
#cfc = '4404585880805254' | |
#csnum = 'LEH107931900' | |
#gsbrcd = 'RSBJ3d384f4' | |
def b64_enc(x): | |
return b64encode(x).replace("=", "%2A") | |
###Get token | |
url = "http://nas.nintendowifi.net/ac" | |
headers = { 'User-Agent' : 'RVL SDK/1.0', 'Content-type' : 'application/x-www-form-urlencoded', 'HTTP_X_GAMECD' : gamecode } | |
#data = "action=bG9naW4%2A&gsbrcd=" + b64_enc(gsbrcd) + "&userid=MTc4NjY3MzgyNzQ5OA%2A%2A&ingamesn=&sdkver=MDAxMDAw&gamecd=" + b64_enc(gamecode) + "&makercd=MDE%2A&unitcd=MQ%2A%2A&macadr=MDAxN2FiMjkyM2Jl&lang=MDE%2A&devtime=MTQwMjI4MTYyNDU2&csnum=" + b64_enc(csnum) + "&cfc=" + b64_enc(cfc) + "®ion=MDE%2A" | |
#req = urllib2.Request(url, data, headers) | |
#response = urllib2.urlopen(req) | |
#the_page = response.read() | |
#open('out1.bin','w').write(the_page) | |
data = "action=c3ZjbG9j&svc=" + b64_enc(svc) + "&userid=MTc4NjY3MzgyNzQ5OA%2A%2A&sdkver=MDAxMDAw&gamecd=" + b64_enc(gamecode) + "&makercd=MDE%2A&unitcd=MQ%2A%2A&macadr=MDAxN2FiMjkyM2Jl&lang=MDE%2A&devtime=MTQwMjI4MTYyNDU3&csnum=" + b64_enc(csnum) + "&cfc=" + b64_enc(cfc) + "®ion=MDE%2A" | |
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('&')].replace("*", "%2A") | |
#Create output folder if it doesn't exist | |
if not os.path.exists('./'+gamecode2): | |
os.makedirs('./'+gamecode2) | |
url = "https://dls1.nintendowifi.net/download" | |
headers = { 'User-Agent' : 'RVL SDK/1.0', 'Content-type' : 'application/x-www-form-urlencoded'} | |
###List files | |
data = "gamecd=" + b64_enc(gamecode2) + "&rhgamecd=" + b64_enc(gamecode) + "&passwd=" + b64_enc(password) + "&token=" + token + "%2A%2A&cfc=" + b64_enc(cfc) + "&macadr=MDAxN2FiMjkyM2Jl®ion=MDE%2A&country=Q0g%2A&action=" + b64_enc('list') | |
req = urllib2.Request(url, data, headers) | |
response = urllib2.urlopen(req) | |
the_page = response.read() | |
open('./'+gamecode2+'/_list.txt','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 " + gamecode2 + ", quitting..." | |
sys.exit() | |
print "Game code " + gamecode2 + " has " + str(len(lines)) + " files to download.\n" | |
for line in lines: | |
fname = line[:line.find('\t')] | |
print "Downloading " + fname + "..." | |
data="gamecd=" + b64_enc(gamecode2) + "&rhgamecd=" + b64_enc(gamecode) + "&passwd=" + b64_enc(password) + "&token=" + token + "&cfc=" + b64_enc(cfc) + "&macadr=MDAxN2FiMjkyM2Jl®ion=MDE%2A&country=Q0g%2A&action=" + b64_enc('contents') + "&contents=" + b64_enc(fname) | |
req = urllib2.Request(url, data, headers) | |
response = urllib2.urlopen(req) | |
the_page = response.read() | |
open('./'+gamecode2+'/'+fname,'wb').write(the_page) | |
print "Done!\n" |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment