Skip to content

Commit

Permalink
Implemented --undupe-rename
Browse files Browse the repository at this point in the history
  • Loading branch information
nicoboss committed Dec 17, 2020
1 parent ef0fc74 commit d89ebac
Show file tree
Hide file tree
Showing 3 changed files with 39 additions and 0 deletions.
23 changes: 23 additions & 0 deletions nsz.sln
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@

Microsoft Visual Studio Solution File, Format Version 12.00
# Visual Studio Version 16
VisualStudioVersion = 16.0.30611.23
MinimumVisualStudioVersion = 10.0.40219.1
Project("{888888A0-9F3D-457C-B088-3A5042F75D52}") = "nsz", "nsz.pyproj", "{39FABC12-415B-4DEB-BFAE-38AC2D1FC72C}"
EndProject
Global
GlobalSection(SolutionConfigurationPlatforms) = preSolution
Debug|Any CPU = Debug|Any CPU
Release|Any CPU = Release|Any CPU
EndGlobalSection
GlobalSection(ProjectConfigurationPlatforms) = postSolution
{39FABC12-415B-4DEB-BFAE-38AC2D1FC72C}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
{39FABC12-415B-4DEB-BFAE-38AC2D1FC72C}.Release|Any CPU.ActiveCfg = Release|Any CPU
EndGlobalSection
GlobalSection(SolutionProperties) = preSolution
HideSolutionNode = FALSE
EndGlobalSection
GlobalSection(ExtensibilityGlobals) = postSolution
SolutionGuid = {0DA4C9E6-8453-4BC1-8767-77E66EDEF7B6}
EndGlobalSection
EndGlobal
1 change: 1 addition & 0 deletions nsz/ParseArguments.py
Original file line number Diff line number Diff line change
Expand Up @@ -26,6 +26,7 @@ def parse():
parser.add_argument('--titlekeys', action='store_true', default=False, help="Extracts titlekeys from your NSP/NSZ files and adds missing keys to ./titlekeys.txt and JSON files inside ./titledb/ (obtainable from https://github.com/blawar/titledb). Titlekeys can be used to unlock updates using NUT OG (OG fork obtainable from https://github.com/plato79/nut). There is currently no publicly known way of optioning NSX files. To MitM: Apply disable_ca_verification & disable_browser_ca_verification patches, use your device's nx_tls_client_cert.pfx (Password: switch, Install to OS and import for Fiddler or import into Charles/OWASP ZAP). Use it for aauth-lp1.ndas.srv.nintendo.net:443, dauth-lp1.ndas.srv.nintendo.net:443 and app-b01-lp1.npns.srv.nintendo.net:443. Try with your WiiU first as there you won't get banned if you mess up.")
parser.add_argument('--undupe', action='store_true', help="Deleted all duplicates (games with same ID and Version). The Files folder will get parsed in order so the later in the argument list the more likely the file is to be deleted")
parser.add_argument('--undupe-dryrun' , action='store_true', help="Shows what files would get deleted using --undupe")
parser.add_argument('--undupe-rename' , action='store_true', help="Renames files to minimal standard")
parser.add_argument('--undupe-prioritylist', type=str, default="", help='Regex specifying which dublicates delegtion should be prioritized before following the normal deletion order. Example: "^.*\.(nsp|xci)$"')
parser.add_argument('--undupe-whitelist', type=str, default="", help='Regex specifying which dublicates should under no circumstances be deleted. Example: "^.*\.(nsz|xcz)$"')
parser.add_argument('--undupe-blacklist', type=str, default="", help='Regex specifying which files should always be deleted - even if they are not even a dublicate! Be careful! Example: "^.*\.(nsp|xci)$"')
Expand Down
15 changes: 15 additions & 0 deletions nsz/undupe.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,3 +74,18 @@ def undupe(args):
os.remove(version_value[0])
Print.info("[DELETED] [DUPE]: " + version_value[0])
Print.info("Keeping " + file)
if args.undupe_rename:
for file in version_value:
if not isOnWhitelist(args, file):
newName = str(Path(file).parent.joinpath("["+titleID_key+"][v"+str(version_key)+"].nsz"))
if file == newName:
#Print.info("[RENAME] [SKIPPED] " + newName)
pass
elif Path(newName).is_file():
Print.info("[RENAME] [ERROR_ALREADY_EXIST] " + newName)
else:
if args.undupe_dryrun:
Print.info("[DRYRUN] [RENAME]: " + "os.rename(" + file + ", " + newName)
else:
Print.info("[RENAME]: " + "os.rename(" + file+ ", " + newName)
os.rename(file, newName)

0 comments on commit d89ebac

Please sign in to comment.