Will now use a local Ticket if use local files is checked and it exists

This commit is contained in:
Campbell 2024-04-19 23:53:15 -04:00
parent 0c11c2f290
commit 529107b280
Signed by: NinjaCheetah
GPG Key ID: B547958AF96ED344
3 changed files with 43 additions and 27 deletions

View File

@ -171,6 +171,14 @@ class MainWindow(QMainWindow, Ui_MainWindow):
" title database, and that the provided version exists for the title you are" " title database, and that the provided version exists for the title you are"
" attempting to download.") " attempting to download.")
msgBox.exec() msgBox.exec()
elif result == -3:
msgBox.setWindowTitle("Content Decryption Failed")
msgBox.setText("Content decryption was not successful! Decrypted contents could not be created.")
msgBox.setInformativeText("Your TMD or Ticket may be damaged, or they may not correspond with the content "
"being decrypted. If you have checked \"Use local files, if they exist\", try "
"disabling that option before trying the download again to fix potential issues "
"with local data.")
msgBox.exec()
elif result == 1: elif result == 1:
msgBox.setIcon(QMessageBox.Icon.Warning) msgBox.setIcon(QMessageBox.Icon.Warning)
msgBox.setWindowTitle("Ticket Not Available") msgBox.setWindowTitle("Ticket Not Available")
@ -230,6 +238,11 @@ class MainWindow(QMainWindow, Ui_MainWindow):
tmd_out.write(title.tmd.dump()) tmd_out.write(title.tmd.dump())
tmd_out.close() tmd_out.close()
if self.ui.use_local_chkbox.isChecked() is True and os.path.exists(os.path.join(version_dir, "tik")):
progress_callback.emit(" - Parsing local copy of Ticket...")
local_ticket = open(os.path.join(version_dir, "tik"), "rb")
title.load_ticket(local_ticket.read())
else:
progress_callback.emit(" - Downloading and parsing Ticket...") progress_callback.emit(" - Downloading and parsing Ticket...")
try: try:
title.load_ticket(libWiiPy.download_ticket(tid)) title.load_ticket(libWiiPy.download_ticket(tid))
@ -271,6 +284,7 @@ class MainWindow(QMainWindow, Ui_MainWindow):
title.content.content_list = content_list title.content.content_list = content_list
if decrypt_contents_enabled is True: if decrypt_contents_enabled is True:
try:
for content in range(len(title.tmd.content_records)): for content in range(len(title.tmd.content_records)):
progress_callback.emit(" - Decrypting content " + str(content + 1) + " of " + progress_callback.emit(" - Decrypting content " + str(content + 1) + " of " +
str(len(title.tmd.content_records)) + "...") str(len(title.tmd.content_records)) + "...")
@ -282,6 +296,8 @@ class MainWindow(QMainWindow, Ui_MainWindow):
dec_content_out = open(os.path.join(version_dir, content_file_name), "wb") dec_content_out = open(os.path.join(version_dir, content_file_name), "wb")
dec_content_out.write(dec_content) dec_content_out.write(dec_content)
dec_content_out.close() dec_content_out.close()
except ValueError:
return -3
if pack_wad_enabled is True: if pack_wad_enabled is True:
progress_callback.emit(" - Building certificate...") progress_callback.emit(" - Building certificate...")

View File

@ -156,8 +156,8 @@ class Ui_MainWindow(object):
"<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; font-family:'Sans Serif'; font-size:9pt;\"><br /></p></body></html>", None)) "<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; font-family:'Sans Serif'; font-size:9pt;\"><br /></p></body></html>", None))
self.pack_wad_chkbox.setText(QCoreApplication.translate("MainWindow", u"Pack WAD", 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.wad_file_entry.setPlaceholderText(QCoreApplication.translate("MainWindow", u"File Name", None))
self.keep_enc_chkbox.setText(QCoreApplication.translate("MainWindow", u"Keep Enc. Contents", None)) self.keep_enc_chkbox.setText(QCoreApplication.translate("MainWindow", u"Keep encrypted contents", None))
self.create_dec_chkbox.setText(QCoreApplication.translate("MainWindow", u"Create Decrypted Contents (*.app)", None)) self.create_dec_chkbox.setText(QCoreApplication.translate("MainWindow", u"Create decrypted contents (*.app)", None))
self.use_local_chkbox.setText(QCoreApplication.translate("MainWindow", u"Use Local Files If They Exist", None)) self.use_local_chkbox.setText(QCoreApplication.translate("MainWindow", u"Use local files, if they exist", None))
# retranslateUi # retranslateUi

View File

@ -149,7 +149,7 @@ p, li { white-space: pre-wrap; }
<item> <item>
<widget class="QCheckBox" name="keep_enc_chkbox"> <widget class="QCheckBox" name="keep_enc_chkbox">
<property name="text"> <property name="text">
<string>Keep Enc. Contents</string> <string>Keep encrypted contents</string>
</property> </property>
<property name="checked"> <property name="checked">
<bool>true</bool> <bool>true</bool>
@ -159,7 +159,7 @@ p, li { white-space: pre-wrap; }
<item> <item>
<widget class="QCheckBox" name="create_dec_chkbox"> <widget class="QCheckBox" name="create_dec_chkbox">
<property name="text"> <property name="text">
<string>Create Decrypted Contents (*.app)</string> <string>Create decrypted contents (*.app)</string>
</property> </property>
</widget> </widget>
</item> </item>
@ -169,7 +169,7 @@ p, li { white-space: pre-wrap; }
<bool>true</bool> <bool>true</bool>
</property> </property>
<property name="text"> <property name="text">
<string>Use Local Files If They Exist</string> <string>Use local files, if they exist</string>
</property> </property>
</widget> </widget>
</item> </item>