24
24
dsiVersions = ["1.0 - 1.3 (USA, EUR, AUS, JPN)" , "1.4 - 1.4.5 (USA, EUR, AUS, JPN)" , "All versions (KOR, CHN)" ]
25
25
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" ]
26
26
27
- #Get link of latest pkmn-chest
28
- def getLatestPKMNchest ():
29
- release = json .loads (requests .get ("https://api.github.com/repos/Universal-Team/pkmn-chest/releases/latest" ).content )
30
- url = release ["assets" ][1 ]["browser_download_url" ]
31
- return url
32
-
33
- #Get link of latest DSEins
34
- def getLatestDSEins ():
35
- release = json .loads (requests .get ("https://api.github.com/repos/Universal-Team/3DEins/releases/latest" ).content )
36
- url = release ["assets" ][2 ]["browser_download_url" ]
37
- return url
38
-
39
- #Get link of latest Tic-Tac-DS
40
- def getLatestTicTacDS ():
41
- release = json .loads (requests .get ("https://api.github.com/repos/Jonatan6/Tic-Tac-DS/releases/latest" ).content )
42
- url = release ["assets" ][0 ]["browser_download_url" ]
43
- return url
44
-
45
- #Get link of latest Relaunch
46
- def getLatestRelaunch ():
47
- release = json .loads (requests .get ("https://api.github.com/repos/Universal-Team/Relaunch/releases/latest" ).content )
48
- url = release ["assets" ][0 ]["browser_download_url" ]
49
- return url
50
-
51
- #Get link of latest TWiLight Menu
52
- def getLatestTWLmenu ():
53
- release = json .loads (requests .get ("https://api.github.com/repos/DS-Homebrew/TWiLightMenu/releases/latest" ).content )
54
- url = release ["assets" ][0 ]["browser_download_url" ]
55
- return url
27
+ #Downloader
28
+ def downloadFile (link , destination ):
29
+ r = requests .get (link , allow_redirects = True )
30
+ if link .find ('/' ):
31
+ fileName = link .rsplit ('/' , 1 )[1 ]
32
+ downloadLocation = destination + fileName
33
+ open (downloadLocation , 'wb' ).write (r .content )
34
+ return downloadLocation
35
+
56
36
57
- #Get link of latest dumpTool
58
- def getLatestdumpTool ( ):
59
- release = json .loads (requests .get ("https://api.github.com/repos/zoogie/dumpTool /releases/latest" ).content )
60
- url = release ["assets" ][0 ]["browser_download_url" ]
37
+ #Get link of latest Github Release
38
+ def getLatestGitHub ( usernamerepo , assetNumber ):
39
+ release = json .loads (requests .get ("https://api.github.com/repos/" + usernamerepo + " /releases/latest" ).content )
40
+ url = release ["assets" ][assetNumber ]["browser_download_url" ]
61
41
return url
62
42
63
43
#Push text to output box
@@ -90,6 +70,21 @@ def validateDirectory(directory):
90
70
else :
91
71
return True
92
72
73
+ def unzipper (unzipped , destination ):
74
+ with zipfile .ZipFile (unzipped , 'r' ) as zip_ref :
75
+ zip_ref .extractall (destination )
76
+ zip_ref .close ()
77
+
78
+ def un7zipper (_7za , zipfile , destination ):
79
+ proc = Popen ([_7za ,"x" , "-aoa" , zipfile , '-o' + destination ])
80
+
81
+ ret_val = proc .wait ()
82
+
83
+ while True :
84
+ if ret_val == 0 :
85
+ break
86
+
87
+
93
88
94
89
def start ():
95
90
outputBox .delete (0 , tkinter .END )
@@ -159,17 +154,13 @@ def start():
159
154
#Download Memory Pit
160
155
memoryPitLocation = directory + "/private/ds/app/484E494A/"
161
156
Path (memoryPitLocation ).mkdir (parents = True , exist_ok = True )
162
- r = requests .get (memoryPitDownload , allow_redirects = True )
163
- memoryPitLocation = memoryPitLocation + "pit.bin"
164
- open (memoryPitLocation , 'wb' ).write (r .content )
157
+ downloadFile (memoryPitDownload , memoryPitLocation )
165
158
outputbox ("Memory Pit Downloaded " )
166
159
print ("Memory Pit Downloaded" )
167
160
168
161
if downloadtwlmenu .get () == 1 :
169
162
#Download TWiLight Menu
170
- r = requests .get (getLatestTWLmenu (), allow_redirects = True )
171
- TWLmenuLocation = cwdtemp + "TWiLightMenu.7z"
172
- open (TWLmenuLocation ,'wb' ).write (r .content )
163
+ TWLmenuLocation = downloadFile (getLatestGitHub ('DS-Homebrew/TWiLightMenu' , 0 ),cwdtemp )
173
164
outputbox ("TWiLight Menu ++ Downloaded " )
174
165
print ("TWiLight Menu ++ Downloaded" )
175
166
@@ -191,165 +182,70 @@ def start():
191
182
shutil .copy (cwdtemp + "DSi&3DS - SD card users/_nds/nds-bootstrap-hb-nightly.nds" , directory + "/_nds" )
192
183
shutil .copy (cwdtemp + "DSi&3DS - SD card users/_nds/nds-bootstrap-hb-release.nds" , directory + "/_nds" )
193
184
Path (directory + "/roms/" ).mkdir (parents = True ,exist_ok = True )
185
+
194
186
print ("TWiLight Menu ++ placed in" , directory )
195
187
outputbox ("TWiLight Menu ++ placed " )
196
188
197
189
#Download DeadSkullzJr's Cheat Database
198
190
Path (directory + "/_nds/TWiLightMenu/extras/" ).mkdir (parents = True ,exist_ok = True )
199
- r = requests .get ('https://bitbucket.org/DeadSkullzJr/nds-cheat-databases/raw/933c375545d3ff90854d1e210dcf4b3b31d9d585/Cheats/usrcheat.dat' , allow_redirects = True )
200
- downloadLocation = directory + "/_nds/TWiLightMenu/extras/usrcheat.dat"
201
- open (downloadLocation ,'wb' ).write (r .content )
191
+ downloadFile ('https://bitbucket.org/DeadSkullzJr/nds-cheat-databases/raw/933c375545d3ff90854d1e210dcf4b3b31d9d585/Cheats/usrcheat.dat' , directory + "/_nds/TWiLightMenu/extras/" )
202
192
print ("DeadSkullzJr's Cheat Database downloaded" )
203
193
204
194
205
195
if downloaddumptool .get () == 1 :
206
196
#Download dumpTool
207
- r = requests .get (getLatestdumpTool (), allow_redirects = True )
208
- dumpToolLocation = directory + "/dumpTool.nds"
209
- open (dumpToolLocation ,'wb' ).write (r .content )
197
+ downloadFile (getLatestGitHub ('zoogie/dumpTool' , 0 ), directory )
210
198
print ("dumpTool downloaded" )
211
199
outputbox ("dumpTool Downloaded " )
212
200
213
201
if unlaunchNeeded == 1 :
214
202
#Download Unlaunch
215
203
url = "https://problemkaputt.de/unlaunch.zip"
216
- r = requests .get (url , allow_redirects = True )
217
- unlaunchLocation = cwdtemp + "unlaunch.zip"
218
- open (unlaunchLocation ,'wb' ).write (r .content )
204
+ unlaunchLocation = downloadFile (url , cwdtemp )
219
205
print ("Unlaunch Downloaded" )
220
206
outputbox ("Unlaunch Downloaded " )
221
207
222
208
#Extract Unlaunch
223
- with zipfile .ZipFile (unlaunchLocation , 'r' ) as zip_ref :
224
- zip_ref .extractall (directory )
225
- zip_ref .close ()
226
-
227
- Path (directory + "/roms/nds/" ).mkdir (parents = True ,exist_ok = True )
228
- outputbox ("Downloading other homebrew " )
229
- if homebrewlinks [2 ][0 ].get () == 1 :
230
- r = requests .get (getLatestPKMNchest (), allow_redirects = True )
231
- downloadLocation = directory + "/roms/nds/pkmn-chest.nds"
232
- open (downloadLocation ,'wb' ).write (r .content )
233
- print ("Pokemon Chest downloaded to /roms/nds/" )
234
-
235
- if homebrewlinks [2 ][1 ].get () == 1 :
236
- r = requests .get (homebrewlinks [1 ][1 ], allow_redirects = True )
237
- downloadLocation = cwdtemp + "ASDS.zip"
238
- open (downloadLocation ,'wb' ).write (r .content )
239
- print ("ASDS.zip downloaded to" , cwdtemp )
240
-
241
- with zipfile .ZipFile (downloadLocation , 'r' ) as zip_ref :
242
- zip_ref .extractall (directory + "/roms/nds/" )
243
- zip_ref .close ()
244
- os .remove (directory + "/roms/nds/aperturecover.png" )
245
- print ("portalDS extracted to /roms/nds/" )
246
-
247
-
248
- if homebrewlinks [2 ][2 ].get () == 1 :
249
- r = requests .get (homebrewlinks [1 ][2 ], allow_redirects = True )
250
- downloadLocation = cwdtemp + "CBDS.zip"
251
- open (downloadLocation ,'wb' ).write (r .content )
252
- print ("CBDS.zip downloaded to" , cwdtemp )
253
-
254
- with zipfile .ZipFile (downloadLocation , 'r' ) as zip_ref :
255
- zip_ref .extractall (directory + "/roms/nds/" )
256
- zip_ref .close ()
257
- os .remove (directory + "/roms/nds/ComicBookDS.ds.gba" )
258
- os .remove (directory + "/roms/nds/ComicBookDS.sc.nds" )
259
- print ("ComicBookDS extacted to /roms/nds/" )
260
-
261
-
262
- if homebrewlinks [2 ][3 ].get () == 1 :
263
- r = requests .get (homebrewlinks [1 ][3 ], allow_redirects = True )
264
- downloadLocation = cwdtemp + "DSBible.zip"
265
- open (downloadLocation ,'wb' ).write (r .content )
266
- print ("DSBible.zip downloaded to" , cwdtemp )
267
-
268
- with zipfile .ZipFile (downloadLocation ,'r' ) as zip_ref :
269
- zip_ref .extractall (directory + "/roms/nds/" )
270
- zip_ref .close ()
271
- os .remove (directory + "/roms/nds/README.txt" )
272
- print ("DSBible has been extracted to /roms/nds/" )
273
-
274
- if homebrewlinks [2 ][4 ].get () == 1 :
275
- r = requests .get (getLatestDSEins (), allow_redirects = True )
276
- downloadLocation = directory + "/roms/nds/DSEins.nds"
277
- open (downloadLocation ,'wb' ).write (r .content )
278
- print ("DSEins downloaded to /roms/nds/" )
279
-
280
-
281
- if homebrewlinks [2 ][5 ].get () == 1 :
282
- r = requests .get (homebrewlinks [1 ][5 ], allow_redirects = True )
283
- downloadLocation = directory + "/roms/nds/DSDoom.nds"
284
- open (downloadLocation ,'wb' ).write (r .content )
285
-
286
- print ("DSDoom has been downloaded to /roms/nds" )
287
-
288
- if homebrewlinks [2 ][6 ].get () == 1 :
289
- r = requests .get (homebrewlinks [1 ][6 ], allow_redirects = True )
290
- downloadLocation = cwdtemp + "DSFTP.zip"
291
- open (downloadLocation ,'wb' ).write (r .content )
292
-
293
- with zipfile .ZipFile (downloadLocation , 'r' ) as zip_ref :
294
- zip_ref .extractall (directory + "/roms/nds/" )
295
- zip_ref .close ()
296
- print ("DSFTP has been placed in /roms/nds/DSFTP" )
297
-
209
+ unzipper (unlaunchLocation ,directory )
298
210
299
-
300
- if homebrewlinks [2 ][7 ].get () == 1 :
301
- r = requests .get (homebrewlinks [1 ][7 ], allow_redirects = True )
302
- downloadLocation = cwdtemp + "EverlastingTH.zip"
303
- open (downloadLocation ,'wb' ).write (r .content )
304
-
305
- with zipfile .ZipFile (downloadLocation , 'r' ) as zip_ref :
306
- zip_ref .extractall (directory + "/roms/nds/" )
307
- zip_ref .close ()
308
-
309
- print ("EverlastingTH.nds downloaded in /roms/nds/" )
310
-
311
- if homebrewlinks [2 ][8 ].get () == 1 :
312
- r = requests .get (homebrewlinks [1 ][8 ], allow_redirects = True )
313
- downloadLocation = cwdtemp + "NetHackDS-3.4.3r2.zip"
314
- open (downloadLocation ,'wb' ).write (r .content )
211
+ #Some Homebrew write to the _nds folder so it is better to clear it first
212
+ shutil .rmtree (cwdtemp + "_nds/" )
213
+ Path (cwdtemp + "_nds/" ).mkdir (parents = True ,exist_ok = True )
315
214
316
- with zipfile .ZipFile (downloadLocation , 'r' ) as zip_ref :
317
- zip_ref .extractall (directory + "/roms/nds/" )
318
- zip_ref .close ()
319
-
320
- if homebrewlinks [2 ][9 ].get () == 1 :
321
- r = requests .get (homebrewlinks [1 ][9 ], allow_redirects = True )
322
- downloadLocation = cwdtemp + "NitroTracker-v0.4.zip"
323
- open (downloadLocation ,'wb' ).write (r .content )
324
-
325
- with zipfile .ZipFile (downloadLocation , 'r' ) as zip_ref :
326
- zip_ref .extractall (directory + "/roms/nds/" )
327
- zip_ref .close ()
328
-
329
- if homebrewlinks [2 ][10 ].get () == 1 :
330
- r = requests .get (getLatestRelaunch (), allow_redirects = True )
331
- downloadLocation = cwdtemp + "Relaunch.7z"
332
- open (downloadLocation ,'wb' ).write (r .content )
333
-
334
- proc = Popen ([_7za ,"x" , "-aoa" , downloadLocation , '-o' + cwdtemp ])
335
-
336
- ret_val = proc .wait ()
215
+ #Creates roms/nds if it does not exist
216
+ roms = directory + "/roms/nds/"
217
+ Path (roms ).mkdir (parents = True ,exist_ok = True )
337
218
338
- while True :
339
- if ret_val == 0 :
340
- print ("Relaunch Extracted to" , cwdtemp )
341
- break
342
- distutils .dir_util .copy_tree (cwdtemp + "Relaunch/_nds/" , directory + "/_nds/" )
343
- shutil .copy (cwdtemp + "Relaunch/Relaunch.nds" , directory + "/roms/nds/" )
219
+ outputbox ("Downloading other homebrew " )
220
+ print ("Downloading other homebrew..." )
221
+
222
+
223
+ for count , item in enumerate (homebrewDB ):
224
+ if homebrewList [count ].get () == 1 :
225
+ print ("Downloading " + item ["title" ])
226
+ if item ["github" ] == "True" :
227
+ downloadlink = getLatestGitHub (item ["repo" ], int (item ["asset" ]))
228
+ else :
229
+ downloadlink = item ["link" ]
230
+ if item ["extension" ] == "nds" :
231
+ downloadFile (downloadlink , roms )
232
+ elif item ["extension" ] == "zip" :
233
+ downloadLocation = downloadFile (downloadlink , cwdtemp )
234
+ if item ["location" ]["roms" ] == "all" :
235
+ unzipper (downloadLocation , roms )
236
+ elif item ["extension" ] == "7z" :
237
+ downloadLocation = downloadFile (downloadlink , cwdtemp )
238
+ if item ["location" ]["roms" ] == "all" :
239
+ un7zipper (_7za , downloadLocation , roms )
240
+ else :
241
+ un7zipper (_7za , downloadLocation , cwdtemp )
242
+ if "root" in item ["location" ]:
243
+ distutils .dir_util .copy_tree (cwdtemp + item ["location" ]["root" ],directory + "/" + item ["location" ]["root" ])
244
+ if "roms" in item ["location" ]:
245
+ shutil .copy (cwdtemp + item ["location" ]["roms" ],roms )
246
+
344
247
345
248
346
- if homebrewlinks [2 ][11 ].get () == 1 :
347
- r = requests .get (getLatestTicTacDS (), allow_redirects = True )
348
- downloadLocation = directory + "/roms/nds/tic-tac-ds.nds"
349
- open (downloadLocation ,'wb' ).write (r .content )
350
- print ("Tic-Tac-DS downloaded to /roms/nds/" )
351
-
352
-
353
249
#Delete tmp folder
354
250
shutil .rmtree (cwdtemp )
355
251
@@ -375,8 +271,8 @@ def extraHomebrew():
375
271
homebrewWindowLabel2 = tkinter .Label (homebrewWindow , text = "Select additional homebrew for download then press OK" )
376
272
homebrewWindowLabel2 .pack (anchor = "w" )
377
273
378
- for x in range ( len ( homebrewlinks [ 0 ]) ):
379
- l = tkinter .Checkbutton (homebrewWindow , text = homebrewlinks [ 0 ][ x ] , variable = homebrewlinks [ 2 ][ x ])
274
+ for count , x in enumerate ( homebrewDB ):
275
+ l = tkinter .Checkbutton (homebrewWindow , text = x [ "title" ] , variable = homebrewList [ count ])
380
276
l .pack (anchor = "w" )
381
277
382
278
okButton = tkinter .Button (homebrewWindow , text = "OK" , font = ("Verdana" ,12 ,"bold" ), command = lambda :okButtonPress (homebrewWindow ))
@@ -395,18 +291,13 @@ def extraHomebrew():
395
291
396
292
397
293
#Homebrew Links
294
+ #Homebrew Database
295
+ homebrewDB = json .loads (requests .get ('https://raw.githubusercontent.com/YourKalamity/just-a-dsi-DB/master/just-a-dsi-DB.json' ).content )
296
+ homebrewList = []
297
+ for x in homebrewDB :
298
+ homebrewList .append (tkinter .IntVar ())
398
299
399
- homebrewlinks = [
400
- ['Pokémon-Chest' ,'Aperture Science DS (portalDS)' , 'ComicBookDS' ,'DSBible' ,'DSEins' ,'DSDoom' ,'DSFTP v2.6' ,'Everlasting Love : Tomorrow Hill' ,'NetHackDS' ,
401
- 'NitroTrackerDS' ,'Relaunch' ,'Tic-Tac-DS' ],
402
- ['' ,'https://github.com/smealum/portalDS/releases/download/r1/ASDS_r1.zip' ,'http://cbds.free.fr/Softwares/ComicBookDS/Fichiers/ComicBookDS_V3.0.zip' ,
403
- 'https://www.gamebrew.org/images/a/ac/Dsbible251.zip' ,
404
- '' ,'https://github.com/RocketRobz/dsdoom/releases/download/1.2.1-fix/dsdoom.nds' ,'https://www.gamebrew.org/images/5/50/DSFTP26.zip' ,
405
- 'http://beyondds.free.fr/projects/Everlasting/EverlastingTH.zip' ,'https://github.com/fancypantalons/nethackds/releases/download/3.4.3r2/NetHackDS-3.4.3r2.zip' ,
406
- 'http://web.archive.org/web/20190122024458/http://nitrotracker.tobw.net/NitroTracker-v0.4.zip' ,'' ,'' ],
407
- [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 )]
408
- ]
409
-
300
+ homebrewList [0 ] = tkinter .IntVar (value = 1 )
410
301
411
302
# Title and Author
412
303
appTitle = tkinter .Label (text = "Lazy DSi file downloader" ,font = ('Verdana' , 14 ), fg = "white" , bg = "black" )
0 commit comments