forked from NinjaCheetah/NUSGet
Titles without tickets are now handled correctly
Entire UI is now locked out during downloads to prevent changing options and breaking things, and new titles cannot be selected from the list mid-download
This commit is contained in:
parent
1c2370b6cb
commit
ff3eea8d5e
79
NUSD-Py.py
79
NUSD-Py.py
@ -47,6 +47,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
self.ui.download_btn.clicked.connect(self.download_btn_pressed)
|
||||
self.ui.pack_wad_chkbox.clicked.connect(self.pack_wad_chkbox_toggled)
|
||||
|
||||
self.ui.log_text_browser.setText("NUSD-Py v1.0\nDeveloped by NinjaCheetah\nPowered by libWiiPy\n\n"
|
||||
"Select a title from the list on the left, or enter a Title ID to begin.")
|
||||
|
||||
tree = self.ui.title_tree
|
||||
self.tree_categories = []
|
||||
|
||||
@ -81,18 +84,20 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
|
||||
@Slot(QTreeWidgetItem, int)
|
||||
def onItemClicked(self, item, col):
|
||||
global regions
|
||||
region_names = []
|
||||
for region in regions:
|
||||
region_names.append(region[1])
|
||||
if item.parent() is not None and item.parent() not in self.tree_categories:
|
||||
category = item.parent().parent().parent().text(0)
|
||||
for title in wii_database[category]:
|
||||
if item.parent().parent().text(0) == (title["TID"] + " - " + title["Name"]):
|
||||
selected_title = title
|
||||
selected_version = item.text(0)
|
||||
selected_region = item.parent().text(0)
|
||||
self.load_title_data(selected_title, selected_version, selected_region)
|
||||
if self.ui.download_btn.isEnabled() is True:
|
||||
global regions
|
||||
region_names = []
|
||||
for region in regions:
|
||||
region_names.append(region[1])
|
||||
if (item.parent() is not None and item.parent() not in self.tree_categories
|
||||
and item.parent().parent() not in self.tree_categories):
|
||||
category = item.parent().parent().parent().text(0)
|
||||
for title in wii_database[category]:
|
||||
if item.parent().parent().text(0) == (title["TID"] + " - " + title["Name"]):
|
||||
selected_title = title
|
||||
selected_version = item.text(0)
|
||||
selected_region = item.parent().text(0)
|
||||
self.load_title_data(selected_title, selected_version, selected_region)
|
||||
|
||||
def update_log_text(self, new_text):
|
||||
self.log_text += new_text + "\n"
|
||||
@ -121,12 +126,22 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
danger_text = selected_title["Danger"]
|
||||
except KeyError:
|
||||
pass
|
||||
if selected_title["Ticket"] is False:
|
||||
danger_text = danger_text + ("\n\nNote: This Title does not have a Ticket available, so it cannot be "
|
||||
"packed into a WAD or decrypted.")
|
||||
self.log_text = (tid + " - " + selected_title["Name"] + "\n" + "Version: " + selected_version + "\n\n" +
|
||||
danger_text + "\n")
|
||||
self.ui.log_text_browser.setText(self.log_text)
|
||||
|
||||
def download_btn_pressed(self):
|
||||
self.ui.tid_entry.setEnabled(False)
|
||||
self.ui.version_entry.setEnabled(False)
|
||||
self.ui.download_btn.setEnabled(False)
|
||||
self.ui.pack_wad_chkbox.setEnabled(False)
|
||||
self.ui.keep_enc_chkbox.setEnabled(False)
|
||||
self.ui.create_dec_chkbox.setEnabled(False)
|
||||
self.ui.use_local_chkbox.setEnabled(False)
|
||||
self.ui.wad_file_entry.setEnabled(False)
|
||||
self.log_text = ""
|
||||
self.ui.log_text_browser.setText(self.log_text)
|
||||
|
||||
@ -154,7 +169,23 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
" title database, and that the provided version exists for the title you are"
|
||||
" attempting to download.")
|
||||
msgBox.exec()
|
||||
elif result == 1:
|
||||
msgBox.setIcon(QMessageBox.Icon.Warning)
|
||||
msgBox.setWindowTitle("Ticket Not Available")
|
||||
msgBox.setText("No Ticket is Available for the Requested Title!")
|
||||
msgBox.setInformativeText("A ticket could not be downloaded for the requested title, but you have selected "
|
||||
"\"Pack WAD\" or \"Create Decrypted Contents\". These options are not available "
|
||||
"for titles without a ticket. Only encrypted contents have been saved.")
|
||||
msgBox.exec()
|
||||
self.ui.tid_entry.setEnabled(True)
|
||||
self.ui.version_entry.setEnabled(True)
|
||||
self.ui.download_btn.setEnabled(True)
|
||||
self.ui.pack_wad_chkbox.setEnabled(True)
|
||||
self.ui.keep_enc_chkbox.setEnabled(True)
|
||||
self.ui.create_dec_chkbox.setEnabled(True)
|
||||
self.ui.use_local_chkbox.setEnabled(True)
|
||||
if self.ui.pack_wad_chkbox.isChecked() is True:
|
||||
self.ui.wad_file_entry.setEnabled(True)
|
||||
|
||||
def run_nus_download(self, progress_callback):
|
||||
tid = self.ui.tid_entry.text()
|
||||
@ -165,6 +196,9 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
except ValueError:
|
||||
version = None
|
||||
|
||||
pack_wad_enabled = self.ui.pack_wad_chkbox.isChecked()
|
||||
decrypt_contents_enabled = self.ui.create_dec_chkbox.isChecked()
|
||||
|
||||
title = libWiiPy.Title()
|
||||
|
||||
title_dir = pathlib.Path(os.path.join(out_folder, tid))
|
||||
@ -195,10 +229,15 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
tmd_out.close()
|
||||
|
||||
progress_callback.emit(" - Downloading and parsing Ticket...")
|
||||
title.load_ticket(libWiiPy.download_ticket(tid))
|
||||
ticket_out = open(os.path.join(version_dir, "tik"), "wb")
|
||||
ticket_out.write(title.ticket.dump())
|
||||
ticket_out.close()
|
||||
try:
|
||||
title.load_ticket(libWiiPy.download_ticket(tid))
|
||||
ticket_out = open(os.path.join(version_dir, "tik"), "wb")
|
||||
ticket_out.write(title.ticket.dump())
|
||||
ticket_out.close()
|
||||
except ValueError:
|
||||
progress_callback.emit(" - No Ticket is available!")
|
||||
pack_wad_enabled = False
|
||||
decrypt_contents_enabled = False
|
||||
|
||||
title.load_content_records()
|
||||
content_list = []
|
||||
@ -229,7 +268,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
enc_content_out.close()
|
||||
title.content.content_list = content_list
|
||||
|
||||
if self.ui.create_dec_chkbox.isChecked() is True:
|
||||
if decrypt_contents_enabled is True:
|
||||
for content in range(len(title.tmd.content_records)):
|
||||
progress_callback.emit(" - Decrypting content " + str(content + 1) + " of " +
|
||||
str(len(title.tmd.content_records)) + "...")
|
||||
@ -242,7 +281,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
dec_content_out.write(dec_content)
|
||||
dec_content_out.close()
|
||||
|
||||
if self.ui.pack_wad_chkbox.isChecked() is True:
|
||||
if pack_wad_enabled is True:
|
||||
progress_callback.emit(" - Building certificate...")
|
||||
title.wad.set_cert_data(libWiiPy.download_cert())
|
||||
|
||||
@ -258,6 +297,10 @@ class MainWindow(QMainWindow, Ui_MainWindow):
|
||||
file.close()
|
||||
|
||||
progress_callback.emit("Download complete!")
|
||||
if ((not pack_wad_enabled and self.ui.pack_wad_chkbox.isChecked()) or
|
||||
(not decrypt_contents_enabled and self.ui.create_dec_chkbox.isChecked())):
|
||||
return 1
|
||||
return 0
|
||||
|
||||
def pack_wad_chkbox_toggled(self):
|
||||
if self.ui.pack_wad_chkbox.isChecked() is True:
|
||||
|
@ -126,7 +126,7 @@ class Ui_MainWindow(object):
|
||||
MainWindow.setCentralWidget(self.centralwidget)
|
||||
self.menubar = QMenuBar(MainWindow)
|
||||
self.menubar.setObjectName(u"menubar")
|
||||
self.menubar.setGeometry(QRect(0, 0, 610, 30))
|
||||
self.menubar.setGeometry(QRect(0, 0, 610, 29))
|
||||
MainWindow.setMenuBar(self.menubar)
|
||||
self.statusbar = QStatusBar(MainWindow)
|
||||
self.statusbar.setObjectName(u"statusbar")
|
||||
@ -145,14 +145,12 @@ class Ui_MainWindow(object):
|
||||
self.label.setText(QCoreApplication.translate("MainWindow", u"v", None))
|
||||
self.version_entry.setPlaceholderText(QCoreApplication.translate("MainWindow", u"Version", None))
|
||||
self.download_btn.setText(QCoreApplication.translate("MainWindow", u"Start NUS Download!", None))
|
||||
self.log_text_browser.setMarkdown(QCoreApplication.translate("MainWindow", u"Select a title from the list on the left, or enter a Title ID to begin.\n"
|
||||
"\n"
|
||||
"", None))
|
||||
self.log_text_browser.setMarkdown("")
|
||||
self.log_text_browser.setHtml(QCoreApplication.translate("MainWindow", u"<!DOCTYPE HTML PUBLIC \"-//W3C//DTD HTML 4.0//EN\" \"http://www.w3.org/TR/REC-html40/strict.dtd\">\n"
|
||||
"<html><head><meta name=\"qrichtext\" content=\"1\" /><style type=\"text/css\">\n"
|
||||
"p, li { white-space: pre-wrap; }\n"
|
||||
"</style></head><body style=\" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;\">\n"
|
||||
"<p style=\" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\">Select a title from the list on the left, or enter a Title ID to begin.</p></body></html>", None))
|
||||
"</style></head><body style=\" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;\">\n"
|
||||
"<p style=\"-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;\"><br /></p></body></html>", None))
|
||||
self.pack_wad_chkbox.setText(QCoreApplication.translate("MainWindow", u"Pack WAD", None))
|
||||
self.wad_file_entry.setPlaceholderText(QCoreApplication.translate("MainWindow", u"File Name", None))
|
||||
self.keep_enc_chkbox.setText(QCoreApplication.translate("MainWindow", u"Keep Enc. Contents", None))
|
||||
|
@ -105,16 +105,14 @@
|
||||
<item>
|
||||
<widget class="QTextBrowser" name="log_text_browser">
|
||||
<property name="markdown">
|
||||
<string>Select a title from the list on the left, or enter a Title ID to begin.
|
||||
|
||||
</string>
|
||||
<string/>
|
||||
</property>
|
||||
<property name="html">
|
||||
<string><!DOCTYPE HTML PUBLIC "-//W3C//DTD HTML 4.0//EN" "http://www.w3.org/TR/REC-html40/strict.dtd">
|
||||
<html><head><meta name="qrichtext" content="1" /><style type="text/css">
|
||||
p, li { white-space: pre-wrap; }
|
||||
</style></head><body style=" font-family:'Noto Sans'; font-size:10pt; font-weight:400; font-style:normal;">
|
||||
<p style=" margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;">Select a title from the list on the left, or enter a Title ID to begin.</p></body></html></string>
|
||||
</style></head><body style=" font-family:'Sans Serif'; font-size:9pt; font-weight:400; font-style:normal;">
|
||||
<p style="-qt-paragraph-type:empty; margin-top:0px; margin-bottom:0px; margin-left:0px; margin-right:0px; -qt-block-indent:0; text-indent:0px;"><br /></p></body></html></string>
|
||||
</property>
|
||||
</widget>
|
||||
</item>
|
||||
@ -176,7 +174,7 @@ p, li { white-space: pre-wrap; }
|
||||
<x>0</x>
|
||||
<y>0</y>
|
||||
<width>610</width>
|
||||
<height>30</height>
|
||||
<height>29</height>
|
||||
</rect>
|
||||
</property>
|
||||
</widget>
|
||||
|
Loading…
x
Reference in New Issue
Block a user