mirror of
https://github.com/thewesker/lazy-dsi-file-downloader.git
synced 2025-12-20 04:21:09 -05:00
made more efficient
This commit is contained in:
29
main.py
29
main.py
@@ -80,6 +80,9 @@ def start():
|
||||
sysname = platform.system()
|
||||
_7za = os.path.join(sysname, '7za')
|
||||
_7z = None
|
||||
if sysname == "Darwin" :
|
||||
import stat
|
||||
os.chmod(_7za, stat.S_IRWXU)
|
||||
if sysname == "Windows":
|
||||
from winreg import OpenKey, QueryValueEx, HKEY_LOCAL_MACHINE, KEY_READ, KEY_WOW64_64KEY
|
||||
print('Searching for 7-Zip in the Windows registry...')
|
||||
@@ -125,7 +128,8 @@ def start():
|
||||
memoryPitDownload = memoryPitLinks[0]
|
||||
|
||||
temp = directory + "/tmp/"
|
||||
Path(temp).mkdir(parents=True,exist_ok=True)
|
||||
cwdtemp = os.getcwd() + "/lazy-dsi-file-downloader-tmp/"
|
||||
Path(cwdtemp).mkdir(parents=True,exist_ok=True)
|
||||
|
||||
if downloadmemorypit.get() == 1:
|
||||
#Download Memory Pit
|
||||
@@ -140,14 +144,14 @@ def start():
|
||||
if downloadtwlmenu.get() == 1:
|
||||
#Download TWiLight Menu
|
||||
r = requests.get(getLatestTWLmenu(), allow_redirects=True)
|
||||
TWLmenuLocation = temp + "TWiLightMenu.7z"
|
||||
TWLmenuLocation = cwdtemp + "TWiLightMenu.7z"
|
||||
open(TWLmenuLocation,'wb').write(r.content)
|
||||
outputbox("TWiLight Menu ++ Downloaded ")
|
||||
print("TWiLight Menu ++ Downloaded")
|
||||
print(TWLmenuLocation)
|
||||
|
||||
#Extract TWiLight Menu
|
||||
proc = Popen([ _7za, 'x', TWLmenuLocation, '-y' , '-o' + temp, '_nds', 'DSi - CFW users',
|
||||
'DSi&3DS - SD card users', 'roms' ])
|
||||
proc = Popen([_7za,"x", "-aoa", TWLmenuLocation, '-o'+cwdtemp, 'DSi - CFW users/SDNAND root/', '_nds', 'DSi&3DS - SD card users', 'roms', 'BOOT.NDS'])
|
||||
ret_val = proc.wait()
|
||||
|
||||
while True:
|
||||
@@ -157,12 +161,12 @@ def start():
|
||||
break
|
||||
|
||||
#Move TWiLight Menu
|
||||
shutil.copy(temp + "DSi&3DS - SD card users/BOOT.NDS", directory)
|
||||
distutils.dir_util.copy_tree(temp + "_nds/" , directory +"/_nds/")
|
||||
distutils.dir_util.copy_tree(temp + "DSi - CFW users/SDNAND root/hiya", directory+"/hiya/")
|
||||
distutils.dir_util.copy_tree(temp + "DSi - CFW users/SDNAND root/title", directory+"/title/")
|
||||
shutil.copy(temp + "DSi&3DS - SD card users/_nds/nds-bootstrap-hb-nightly.nds", directory + "/_nds")
|
||||
shutil.copy(temp + "DSi&3DS - SD card users/_nds/nds-bootstrap-hb-release.nds", directory + "/_nds")
|
||||
shutil.copy(cwdtemp + "DSi&3DS - SD card users/BOOT.NDS", directory)
|
||||
distutils.dir_util.copy_tree(cwdtemp + "_nds/" , directory +"/_nds/")
|
||||
distutils.dir_util.copy_tree(cwdtemp + "DSi - CFW users/SDNAND root/hiya", directory+"/hiya/")
|
||||
distutils.dir_util.copy_tree(cwdtemp + "DSi - CFW users/SDNAND root/title", directory+"/title/")
|
||||
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 ")
|
||||
@@ -179,7 +183,7 @@ def start():
|
||||
#Download Unlaunch
|
||||
url = "https://problemkaputt.de/unlaunch.zip"
|
||||
r = requests.get(url, allow_redirects=True)
|
||||
unlaunchLocation = temp + "unlaunch.zip"
|
||||
unlaunchLocation = cwdtemp + "unlaunch.zip"
|
||||
open(unlaunchLocation,'wb').write(r.content)
|
||||
print("Unlaunch Downloaded")
|
||||
outputbox("Unlaunch Downloaded ")
|
||||
@@ -191,7 +195,8 @@ def start():
|
||||
|
||||
|
||||
#Delete tmp folder
|
||||
shutil.rmtree(directory + '/tmp')
|
||||
shutil.rmtree(cwdtemp)
|
||||
|
||||
print("Done!")
|
||||
outputbox("Done!")
|
||||
|
||||
|
||||
Reference in New Issue
Block a user