Hacking NUSgrabber and JNUSTool Batch Download Tool

  • Thread starter Thread starter TheCyberQuake
  • Start date Start date
  • Views Views 7,215
  • Replies Replies 9
  • Likes Likes 5

TheCyberQuake

Certified Geek
Member
Joined
Dec 2, 2014
Messages
5,026
Reaction score
3,837
Trophies
2
Age
30
Location
Las Vegas, Nevada
XP
4,511
Country
United States
Finally decided to create a new thread for my batch file.
I based my work off of something @nolimits59 made, and after that they and @nexusmtz helped me implement additional features.
It's a batch file that allows you to batch-download multiple games at once using NUSGrabber.

Current Version: 1.2.0

Added in 1.2.0:

- Automatically moves game downloads from "install" to "GameBackups" before starting downloads. This is to clean the install folder between uses so each time you can simply copy-paste the install folder without re-copying the old downloads
- Added comments to the script to explain what each part does for anyone who is interested

Current Features:
- Batch download games with nusgrabber
- Automatically finds the correct title.tik from \tickets (requires downloading and unzipping tik database from that iso site)
- Automatically detects game name using the tik database folder system withing \tickets
- Can automatically grab updates for each game (program will ask for each title if you wish to also grab updates)
- Downloads will automatically be renamed and moved into \install, using the correct format for wupinstaller mod y. This means once you finish downloading you can simply copy the created install folder to the SD root and you can batch install using wupinstaller mod y

Code:
@echo off

::Set Current Directory, gets saved to variable "nusdir"
cd %~dp0
set nusdir=%~dp0

::Clear download.bat to remove the previous download list and commands
echo. > download.bat

::Create needed directories if they don't already exist
if not exist GameBackups md GameBackups
if not exist tickets (
md tickets
cls
echo "tickets" folder created. Please unzip the tik database from "that iso site" into the tickets folder.
pause
)

::Start of loop to create game download list
:setgamelist

::Make variables created within the loop only last during that loop
SETLOCAL
cls
echo Type -1 to begin downloads, or add more below.

::User input for title ID, gets saved to variable "id"
set /P id="Enter Title ID: "

::Check if user input is -1, and if so exits loop
if "%id%" == "-1" goto end

::User input to automatically download game updates, gets saved to variable "update"
set /p update="Download game updates? (y,n): "

::Attempts to find a folder within \tickets whose name matches the Title ID set earlier
for /d /r "%NusDir%\tickets" %%a in (*) do if /i %%~nxa==%id% set "tikLocation=%%a"

::Finds the name of the parent folder of the previously found folder to get game name, gets saved to variable "game"
for %%a in ("%tikLocation%\..") do set "game=%%~na"

::Writes download code to download.bat, to be called later
::If ticket was found, it will be moved to the game download folder
::If no ticket is found, it will ask for a game name
If not "%tikLocation%"=="" (
echo echo ----------------------------------------------- >> download.bat
echo echo Downloading %game% - %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo nusgrabber.exe %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo echo Grabbing Ticket File >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo copy "%TikLocation%\title.tik" "%id%" >> download.bat
) else (
echo Error: ticket not found. Skipping ticket transfer.
pause
cls
set /P game="Enter game name: "
echo echo ----------------------------------------------- >> download.bat
echo echo Downloading %game% - %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo nusgrabber.exe %id% >> download.bat
)

::Writes folder moving/renaming code to download.bat, to be called later
echo echo ----------------------------------------------- >> download.bat
echo echo Renaming Folder %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo MOVE %id% "install\%game%" >> download.bat

::Changes Title ID and game name to their Updater counterparts
set id=%id:00050000=0005000E%
set game=%game% Update

::Check if user input for automatic update download was yes.
::Input could be y, Y, yes, yeah, or anything starting with "y" and this will return true
if /i %update:~0,1%==y (

::Writes update download code to download.bat, to be called later
echo echo ----------------------------------------------- >> download.bat
echo echo Downloading %game% - %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo nusgrabber.exe %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo echo Renaming Folder %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo if exist %id% MOVE %id% "install\%game%" >> download.bat
)
ENDLOCAL

::Loop back to ask the user for another Title ID
goto setgamelist
:end

::Writes the last bit of code to download.bat for a clean finish
echo echo ----------------------------------------------- >> download.bat
echo echo Downloads Completed! >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo pause >> download.bat

::If install folder doesn't exist, create that folder
::If it does, move everything from within that folder to \GameBackups
if not exist install (
md install
) else (
FOR /d %%i IN (install\*) DO move "%%i" GameBackups
)

::Calls download.bat, which now has the code to download every game and update the user input
call download.bat
Download:
https://mega.nz/#!YJlCHS7a!7Nr6I2OCb6m6emZ0PLBqQ5seti4AyU0_gwVXsauOkk8

This version was made to work with NUSGrabber:
http://wupinstaller.com/NUSGrabber.rar

Code:
@echo off

::Set Current Directory, gets saved to variable "nusdir"
cd %~dp0
set nusdir=%~dp0

::Clear download.bat to remove the previous download list and commands
echo. > download.bat

::Create needed directories if they don't already exist
if not exist GameBackups md GameBackups
if not exist tickets (
md tickets
cls
echo "tickets" folder created. Please unzip the tik database from "that iso site" into the tickets folder.
pause
)

::Start of loop to create game download list
:setgamelist

::Make variables created within the loop only last during that loop
SETLOCAL
cls
echo Type -1 to begin downloads, or add more below.

::User input for title ID, gets saved to variable "id"
set /P id="Enter Title ID: "

::Check if user input is -1, and if so exits loop
if "%id%" == "-1" goto end

::User input to automatically download game updates, gets saved to variable "update"
set /p update="Download game updates? (y,n): "

::Attempts to find a folder within \tickets whose name matches the Title ID set earlier
for /d /r "%NusDir%\tickets" %%a in (*) do if /i %%~nxa==%id% set "tikLocation=%%a"

::Finds the name of the parent folder of the previously found folder to get game name, gets saved to variable "game"
for %%a in ("%tikLocation%\..") do set "game=%%~na"

::Writes download code to download.bat, to be called later
::If ticket was found, it will be moved to the game download folder
::If no ticket is found, it will ask for a game name
If not "%tikLocation%"=="" (
echo echo ----------------------------------------------- >> download.bat
echo echo Downloading %game% - %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo java -jar JNUSTool.jar %id% -dlEncrypted >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo echo Grabbing Ticket File >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo copy "%TikLocation%\title.tik" "%id%" >> download.bat
) else (
echo Error: ticket not found. Skipping ticket transfer.
pause
cls
set /P game="Enter game name: "
echo echo ----------------------------------------------- >> download.bat
echo echo Downloading %game% - %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo java -jar JNUSTool.jar %id% -dlEncrypted >> download.bat
)

::Writes folder moving/renaming code to download.bat, to be called later
echo echo ----------------------------------------------- >> download.bat
echo echo Renaming Folder %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo MOVE tmp_%id% "install\%game%" >> download.bat

::Changes Title ID and game name to their Updater counterparts
set id=%id:00050000=0005000E%
set game=%game% Update

::Check if user input for automatic update download was yes.
::Input could be y, Y, yes, yeah, or anything starting with "y" and this will return true
if /i %update:~0,1%==y (

::Writes update download code to download.bat, to be called later
echo echo ----------------------------------------------- >> download.bat
echo echo Downloading %game% - %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo java -jar JNUSTool.jar %id% -dlEncrypted >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo echo Renaming Folder %id% >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo if exist tmp_%id% MOVE tmp_%id% "install\%game%" >> download.bat
)
ENDLOCAL

::Loop back to ask the user for another Title ID
goto setgamelist
:end

::Writes the last bit of code to download.bat for a clean finish
echo echo ----------------------------------------------- >> download.bat
echo echo Downloads Completed! >> download.bat
echo echo ----------------------------------------------- >> download.bat
echo pause >> download.bat

::If install folder doesn't exist, create that folder
::If it does, move everything from within that folder to \GameBackups
if not exist install (
md install
) else (
FOR /d %%i IN (install\*) DO move "%%i" GameBackups
)

::Calls download.bat, which now has the code to download every game and update the user input
call download.bat
Download:
https://mega.nz/#!NYNzHZ6a!b0AcfymBdHDMbv-5zyc7xAg_tnlM44n0AsAURhX_b0A

This version was made to work with JNUSTool:
https://gbatemp.net/threads/jnustool-nusgrabber-and-cdecrypt-combined.413179/

It's one of the few ways I've seen to really batch download games + updates.
 
Last edited by TheCyberQuake,
Don't know why anyone has replied yet. Sounds very interesting and usefull if it really works that easy (if someone needs it at least, because i am still waiting for a response from ninty). Nice job and thanks for sharing
 
...but people really like GUI tools
I think you'll find that what people like is having a choice. GUI tools don't work when you remote shell or schedule tasks. Personally, I tend to prefer tools which provide both a GUI and command-line functionality. That way the same code can be used whether I'm local, remote, interactive or batch.

Also, your post sounds more like an ad than a reply. It comes across as "Yeah, whatever. Mine's better because you can click it."
 
Last edited by nexusmtz,
  • Like
Reactions: ajd4096
I think you'll find that what people like is having a choice. GUI tools don't work when you remote shell or schedule tasks. Peronally, I tend to prefer tools which provide both a GUI and command-line functionality. That way the same code can be used whether I'm local, remote, interactive or batch.

Also, your post sounds more like an ad than a reply. It comes across as "Yeah, whatever. Mine's better because you can click it."

Didn't mean to come across that way...

I understand people like having command line tools... In the end I guess it's just whatever people want to use...

I'm not sure if you can do this in a batch file but the title ID is also stored inside the tik file if you're able to read the binary data... you could use that to let people input tik files instead of game IDs... just a thought...
 
Last edited by DanTheMan827,
Didn't mean to come across that way...

I understand people like having command line tools... In the end I guess it's just whatever people want to use...

I'm not sure if you can do this in a batch file but the title ID is also stored inside the tik file if you're able to read the binary data
AFAIK not straight from a batch file, but I could probably place another CLI .exe program and can call it to read ticket hex data. I could potentially have it populate a list of each game by ID that has a ticket and then save that list, and then pull game names. If not in batch I could probably do it in VB. I have yet to really learn any other useful languages and I don't have time to learn those right now (I have school and work that take up most of my time right now) and I was taught VB in high school freshman year.
 
AFAIK not straight from a batch file, but I could probably place another CLI .exe program and can call it to read ticket hex data. I could potentially have it populate a list of each game by ID that has a ticket and then save that list, and then pull game names. If not in batch I could probably do it in VB. I have yet to really learn any other useful languages and I don't have time to learn those right now (I have school and work that take up most of my time right now) and I was taught VB in high school freshman year.
VB or VB.NET?

If it's VB.NET you could use System.IO.File.ReadAllBytes to read the file and this function to get the ID

I can't help you if you're talking about VB6...

Here's a small command line program that would take ticket files and give you the ID for each of them on their own line

Code:
Module Module1

    Sub Main()
        Dim args As String() = Environment.GetCommandLineArgs()

        For Each arg As String In args.Skip(1)
            Dim data As Byte() = System.IO.File.ReadAllBytes(arg)
            Console.WriteLine(getTitleIDFromTicket(data))
        Next
    End Sub

    Public Function getTitleIDFromTicket(ticket As Byte()) As String
        Dim hexID As String = ""

        For i As Integer = &H1DC To &H1DC + 7
            hexID += String.Format("{0:X2}", ticket(i))
        Next
        Return hexID
    End Function
End Module
 
Finally got a chance to really put this script to the test after formatting my USB and sysNAND to test WiiUBru's redNAND implementation.
I downloaded 4 games and their updates, which means 8 titles in total. I then copied them to my SD and used the latest wupinstaller mod y to batch install (you can just push + to select every game from the install folder). Unfortunately I had to let it run overnight. I just got around to testing all of the games I installed. So far the only issue I had was that the Star Fox Update seem to have not installed properly. I went back and reinstalled without touching the files on the SD and it now is working properly, so the issue was with wupinstaller mod y and not with my script.
Also to note I used the NUSgrabber version, I haven't tested the JNUSTool version fully yet but I'm going to assume it would be exactly the same as both script are identical except for the parts relevant to each program (the single command that starts the download for each, along with the folder name that gets searched for to rename and move).
 
Well I started trying to add a system where each time you start downloads, it will move all the folders within "install" into "Game Backups", that way you can keep games downloaded if you want to keep backups, while also cleaning the install folder so that it can simply be copy-pasted each time without having to either delete it or manually move games.
I failed however, and ended up somehow breaking everything to the point where the script would crash no matter what game you put in and what reply was input for auto-updates. I'll look back into it tomorrow to see if I can figure out how to move everything properly since I don't work tomorrow.
 

Site & Scene News

Popular threads in this forum