connected to just-a-dsi-DB now!

This commit is contained in:
Kalam :p
2020-07-03 23:17:07 +01:00
parent e9a5104669
commit f3be82ba27
2 changed files with 560 additions and 188 deletions

267
main.py
View File

@@ -24,40 +24,20 @@ from distutils import dir_util
dsiVersions = ["1.0 - 1.3 (USA, EUR, AUS, JPN)", "1.4 - 1.4.5 (USA, EUR, AUS, JPN)", "All versions (KOR, CHN)"]
memoryPitLinks = ["https://github.com/YourKalamity/just-a-dsi-cfw-installer/raw/master/assets/files/memoryPit/256/pit.bin","https://github.com/YourKalamity/just-a-dsi-cfw-installer/raw/master/assets/files/memoryPit/768_1024/pit.bin"]
#Get link of latest pkmn-chest
def getLatestPKMNchest():
release = json.loads(requests.get("https://api.github.com/repos/Universal-Team/pkmn-chest/releases/latest").content)
url = release["assets"][1]["browser_download_url"]
return url
#Downloader
def downloadFile(link, destination):
r = requests.get(link, allow_redirects=True)
if link.find('/'):
fileName = link.rsplit('/', 1)[1]
downloadLocation = destination + fileName
open(downloadLocation, 'wb').write(r.content)
return downloadLocation
#Get link of latest DSEins
def getLatestDSEins():
release = json.loads(requests.get("https://api.github.com/repos/Universal-Team/3DEins/releases/latest").content)
url = release["assets"][2]["browser_download_url"]
return url
#Get link of latest Tic-Tac-DS
def getLatestTicTacDS():
release = json.loads(requests.get("https://api.github.com/repos/Jonatan6/Tic-Tac-DS/releases/latest").content)
url = release["assets"][0]["browser_download_url"]
return url
#Get link of latest Relaunch
def getLatestRelaunch():
release = json.loads(requests.get("https://api.github.com/repos/Universal-Team/Relaunch/releases/latest").content)
url = release["assets"][0]["browser_download_url"]
return url
#Get link of latest TWiLight Menu
def getLatestTWLmenu():
release = json.loads(requests.get("https://api.github.com/repos/DS-Homebrew/TWiLightMenu/releases/latest").content)
url = release["assets"][0]["browser_download_url"]
return url
#Get link of latest dumpTool
def getLatestdumpTool():
release = json.loads(requests.get("https://api.github.com/repos/zoogie/dumpTool/releases/latest").content)
url = release["assets"][0]["browser_download_url"]
#Get link of latest Github Release
def getLatestGitHub(usernamerepo, assetNumber):
release = json.loads(requests.get("https://api.github.com/repos/"+usernamerepo+"/releases/latest").content)
url = release["assets"][assetNumber]["browser_download_url"]
return url
#Push text to output box
@@ -90,6 +70,21 @@ def validateDirectory(directory):
else:
return True
def unzipper(unzipped, destination):
with zipfile.ZipFile(unzipped, 'r') as zip_ref:
zip_ref.extractall(destination)
zip_ref.close()
def un7zipper(_7za, zipfile, destination):
proc = Popen([_7za,"x", "-aoa", zipfile, '-o'+destination])
ret_val = proc.wait()
while True:
if ret_val == 0:
break
def start():
outputBox.delete(0, tkinter.END)
@@ -159,17 +154,13 @@ def start():
#Download Memory Pit
memoryPitLocation = directory + "/private/ds/app/484E494A/"
Path(memoryPitLocation).mkdir(parents=True, exist_ok=True)
r = requests.get(memoryPitDownload, allow_redirects=True)
memoryPitLocation = memoryPitLocation + "pit.bin"
open(memoryPitLocation, 'wb').write(r.content)
downloadFile(memoryPitDownload, memoryPitLocation)
outputbox("Memory Pit Downloaded ")
print("Memory Pit Downloaded")
if downloadtwlmenu.get() == 1:
#Download TWiLight Menu
r = requests.get(getLatestTWLmenu(), allow_redirects=True)
TWLmenuLocation = cwdtemp + "TWiLightMenu.7z"
open(TWLmenuLocation,'wb').write(r.content)
TWLmenuLocation = downloadFile(getLatestGitHub('DS-Homebrew/TWiLightMenu', 0),cwdtemp)
outputbox("TWiLight Menu ++ Downloaded ")
print("TWiLight Menu ++ Downloaded")
@@ -191,164 +182,69 @@ def start():
shutil.copy(cwdtemp + "DSi&3DS - SD card users/_nds/nds-bootstrap-hb-nightly.nds", directory + "/_nds")
shutil.copy(cwdtemp + "DSi&3DS - SD card users/_nds/nds-bootstrap-hb-release.nds", directory + "/_nds")
Path(directory + "/roms/").mkdir(parents=True,exist_ok=True)
print("TWiLight Menu ++ placed in", directory)
outputbox("TWiLight Menu ++ placed ")
#Download DeadSkullzJr's Cheat Database
Path(directory + "/_nds/TWiLightMenu/extras/").mkdir(parents=True,exist_ok=True)
r = requests.get('https://bitbucket.org/DeadSkullzJr/nds-cheat-databases/raw/933c375545d3ff90854d1e210dcf4b3b31d9d585/Cheats/usrcheat.dat', allow_redirects=True)
downloadLocation = directory + "/_nds/TWiLightMenu/extras/usrcheat.dat"
open(downloadLocation,'wb').write(r.content)
downloadFile('https://bitbucket.org/DeadSkullzJr/nds-cheat-databases/raw/933c375545d3ff90854d1e210dcf4b3b31d9d585/Cheats/usrcheat.dat', directory + "/_nds/TWiLightMenu/extras/")
print("DeadSkullzJr's Cheat Database downloaded")
if downloaddumptool.get() == 1:
#Download dumpTool
r = requests.get(getLatestdumpTool(), allow_redirects=True)
dumpToolLocation = directory + "/dumpTool.nds"
open(dumpToolLocation,'wb').write(r.content)
downloadFile(getLatestGitHub('zoogie/dumpTool', 0), directory)
print("dumpTool downloaded")
outputbox("dumpTool Downloaded ")
if unlaunchNeeded == 1 :
#Download Unlaunch
url = "https://problemkaputt.de/unlaunch.zip"
r = requests.get(url, allow_redirects=True)
unlaunchLocation = cwdtemp + "unlaunch.zip"
open(unlaunchLocation,'wb').write(r.content)
unlaunchLocation = downloadFile(url, cwdtemp)
print("Unlaunch Downloaded")
outputbox("Unlaunch Downloaded ")
#Extract Unlaunch
with zipfile.ZipFile(unlaunchLocation, 'r') as zip_ref:
zip_ref.extractall(directory)
zip_ref.close()
Path(directory +"/roms/nds/").mkdir(parents=True,exist_ok=True)
unzipper(unlaunchLocation,directory)
#Some Homebrew write to the _nds folder so it is better to clear it first
shutil.rmtree(cwdtemp +"_nds/")
Path(cwdtemp +"_nds/").mkdir(parents=True,exist_ok=True)
#Creates roms/nds if it does not exist
roms = directory +"/roms/nds/"
Path(roms).mkdir(parents=True,exist_ok=True)
outputbox("Downloading other homebrew ")
if homebrewlinks[2][0].get() == 1:
r = requests.get(getLatestPKMNchest(), allow_redirects=True)
downloadLocation = directory + "/roms/nds/pkmn-chest.nds"
open(downloadLocation,'wb').write(r.content)
print("Pokemon Chest downloaded to /roms/nds/")
print("Downloading other homebrew...")
for count, item in enumerate(homebrewDB):
if homebrewList[count].get() == 1:
print("Downloading "+item["title"])
if item["github"] == "True":
downloadlink = getLatestGitHub(item["repo"], int(item["asset"]))
else:
downloadlink = item["link"]
if item["extension"] == "nds":
downloadFile(downloadlink, roms)
elif item["extension"] == "zip":
downloadLocation = downloadFile(downloadlink, cwdtemp)
if item["location"]["roms"] == "all":
unzipper(downloadLocation, roms)
elif item["extension"] == "7z":
downloadLocation = downloadFile(downloadlink, cwdtemp)
if item["location"]["roms"] == "all":
un7zipper(_7za, downloadLocation, roms)
else:
un7zipper(_7za, downloadLocation, cwdtemp)
if "root" in item["location"]:
distutils.dir_util.copy_tree(cwdtemp+item["location"]["root"],directory+"/"+item["location"]["root"])
if "roms" in item["location"]:
shutil.copy(cwdtemp+item["location"]["roms"],roms)
if homebrewlinks[2][1].get() == 1:
r = requests.get(homebrewlinks[1][1], allow_redirects=True)
downloadLocation = cwdtemp + "ASDS.zip"
open(downloadLocation,'wb').write(r.content)
print("ASDS.zip downloaded to", cwdtemp)
with zipfile.ZipFile(downloadLocation, 'r') as zip_ref:
zip_ref.extractall(directory + "/roms/nds/")
zip_ref.close()
os.remove(directory+"/roms/nds/aperturecover.png")
print("portalDS extracted to /roms/nds/")
if homebrewlinks[2][2].get() == 1:
r = requests.get(homebrewlinks[1][2], allow_redirects=True)
downloadLocation = cwdtemp + "CBDS.zip"
open(downloadLocation,'wb').write(r.content)
print("CBDS.zip downloaded to", cwdtemp)
with zipfile.ZipFile(downloadLocation, 'r') as zip_ref:
zip_ref.extractall(directory + "/roms/nds/")
zip_ref.close()
os.remove(directory+"/roms/nds/ComicBookDS.ds.gba")
os.remove(directory+"/roms/nds/ComicBookDS.sc.nds")
print("ComicBookDS extacted to /roms/nds/")
if homebrewlinks[2][3].get() == 1:
r = requests.get(homebrewlinks[1][3], allow_redirects=True)
downloadLocation = cwdtemp + "DSBible.zip"
open(downloadLocation,'wb').write(r.content)
print("DSBible.zip downloaded to", cwdtemp)
with zipfile.ZipFile(downloadLocation,'r') as zip_ref:
zip_ref.extractall(directory + "/roms/nds/")
zip_ref.close()
os.remove(directory + "/roms/nds/README.txt")
print("DSBible has been extracted to /roms/nds/")
if homebrewlinks[2][4].get() == 1:
r = requests.get(getLatestDSEins(), allow_redirects=True)
downloadLocation = directory + "/roms/nds/DSEins.nds"
open(downloadLocation,'wb').write(r.content)
print("DSEins downloaded to /roms/nds/")
if homebrewlinks[2][5].get() == 1:
r = requests.get(homebrewlinks[1][5], allow_redirects=True)
downloadLocation = directory + "/roms/nds/DSDoom.nds"
open(downloadLocation,'wb').write(r.content)
print("DSDoom has been downloaded to /roms/nds")
if homebrewlinks[2][6].get() == 1:
r = requests.get(homebrewlinks[1][6], allow_redirects=True)
downloadLocation = cwdtemp + "DSFTP.zip"
open(downloadLocation,'wb').write(r.content)
with zipfile.ZipFile(downloadLocation, 'r') as zip_ref:
zip_ref.extractall(directory + "/roms/nds/")
zip_ref.close()
print("DSFTP has been placed in /roms/nds/DSFTP")
if homebrewlinks[2][7].get() == 1:
r = requests.get(homebrewlinks[1][7], allow_redirects=True)
downloadLocation = cwdtemp + "EverlastingTH.zip"
open(downloadLocation,'wb').write(r.content)
with zipfile.ZipFile(downloadLocation, 'r') as zip_ref:
zip_ref.extractall(directory + "/roms/nds/")
zip_ref.close()
print("EverlastingTH.nds downloaded in /roms/nds/")
if homebrewlinks[2][8].get() == 1:
r = requests.get(homebrewlinks[1][8], allow_redirects=True)
downloadLocation = cwdtemp + "NetHackDS-3.4.3r2.zip"
open(downloadLocation,'wb').write(r.content)
with zipfile.ZipFile(downloadLocation, 'r') as zip_ref:
zip_ref.extractall(directory + "/roms/nds/")
zip_ref.close()
if homebrewlinks[2][9].get() == 1:
r = requests.get(homebrewlinks[1][9], allow_redirects=True)
downloadLocation = cwdtemp + "NitroTracker-v0.4.zip"
open(downloadLocation,'wb').write(r.content)
with zipfile.ZipFile(downloadLocation, 'r') as zip_ref:
zip_ref.extractall(directory + "/roms/nds/")
zip_ref.close()
if homebrewlinks[2][10].get() == 1:
r = requests.get(getLatestRelaunch(), allow_redirects=True)
downloadLocation = cwdtemp + "Relaunch.7z"
open(downloadLocation,'wb').write(r.content)
proc = Popen([_7za,"x", "-aoa", downloadLocation, '-o'+cwdtemp])
ret_val = proc.wait()
while True:
if ret_val == 0:
print("Relaunch Extracted to", cwdtemp)
break
distutils.dir_util.copy_tree(cwdtemp + "Relaunch/_nds/" , directory +"/_nds/")
shutil.copy(cwdtemp + "Relaunch/Relaunch.nds", directory+"/roms/nds/")
if homebrewlinks[2][11].get() == 1:
r = requests.get(getLatestTicTacDS(), allow_redirects=True)
downloadLocation = directory + "/roms/nds/tic-tac-ds.nds"
open(downloadLocation,'wb').write(r.content)
print("Tic-Tac-DS downloaded to /roms/nds/")
#Delete tmp folder
shutil.rmtree(cwdtemp)
@@ -375,8 +271,8 @@ def extraHomebrew():
homebrewWindowLabel2 = tkinter.Label(homebrewWindow, text="Select additional homebrew for download then press OK")
homebrewWindowLabel2.pack(anchor = "w")
for x in range(len(homebrewlinks[0])):
l = tkinter.Checkbutton(homebrewWindow, text=homebrewlinks[0][x], variable=homebrewlinks[2][x])
for count, x in enumerate(homebrewDB):
l = tkinter.Checkbutton(homebrewWindow, text=x["title"], variable=homebrewList[count])
l.pack(anchor = "w")
okButton = tkinter.Button(homebrewWindow, text = "OK", font=("Verdana",12,"bold"), command=lambda:okButtonPress(homebrewWindow))
@@ -395,18 +291,13 @@ window.sourceFile = ''
#Homebrew Links
#Homebrew Database
homebrewDB = json.loads(requests.get('https://raw.githubusercontent.com/YourKalamity/just-a-dsi-DB/master/just-a-dsi-DB.json').content)
homebrewList = []
for x in homebrewDB:
homebrewList.append(tkinter.IntVar())
homebrewlinks = [
['Pokémon-Chest','Aperture Science DS (portalDS)', 'ComicBookDS','DSBible','DSEins','DSDoom','DSFTP v2.6','Everlasting Love : Tomorrow Hill','NetHackDS',
'NitroTrackerDS','Relaunch','Tic-Tac-DS'],
['','https://github.com/smealum/portalDS/releases/download/r1/ASDS_r1.zip','http://cbds.free.fr/Softwares/ComicBookDS/Fichiers/ComicBookDS_V3.0.zip',
'https://www.gamebrew.org/images/a/ac/Dsbible251.zip',
'','https://github.com/RocketRobz/dsdoom/releases/download/1.2.1-fix/dsdoom.nds','https://www.gamebrew.org/images/5/50/DSFTP26.zip',
'http://beyondds.free.fr/projects/Everlasting/EverlastingTH.zip','https://github.com/fancypantalons/nethackds/releases/download/3.4.3r2/NetHackDS-3.4.3r2.zip',
'http://web.archive.org/web/20190122024458/http://nitrotracker.tobw.net/NitroTracker-v0.4.zip','',''],
[tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=0),tkinter.IntVar(value=1)]
]
homebrewList[0] = tkinter.IntVar(value=1)
# Title and Author
appTitle = tkinter.Label(text="Lazy DSi file downloader",font=('Verdana', 14), fg="white", bg="black")