diff --git a/lib/gui.py b/lib/gui.py index bf96387..7b50799 100644 --- a/lib/gui.py +++ b/lib/gui.py @@ -116,6 +116,9 @@ def setupUi(self, MainWindow) -> None: self.pushButton_4 = QtWidgets.QPushButton(self.centralwidget) self.pushButton_4.setGeometry(QtCore.QRect(120, 370, 75, 23)) self.pushButton_4.setObjectName("pushButton_4") + self.checkBox_2 = QtWidgets.QCheckBox(self.centralwidget) + self.checkBox_2.setGeometry(QtCore.QRect(340, 50, 101, 17)) + self.checkBox_2.setObjectName("checkBox_2") MainWindow.setCentralWidget(self.centralwidget) self.menubar = QtWidgets.QMenuBar(MainWindow) self.menubar.setGeometry(QtCore.QRect(0, 0, 800, 21)) @@ -149,10 +152,9 @@ def retranslateUi(self, MainWindow) -> None: _translate = QtCore.QCoreApplication.translate MainWindow.setWindowTitle(_translate("MainWindow", "NyaaDownloader")) self.label.setText(_translate("MainWindow", "Uploaders:")) - self.lineEdit.setText(_translate("MainWindow", "Erai-raws;SubsPlease")) self.lineEdit.setPlaceholderText( _translate( - "MainWindow", "Separate them with semicolon (e.g Erai-raws;SubsPlease)" + "MainWindow", "Empty=all, else use semicolon like Erai-raws;SubsPlease" ) ) self.label_2.setText(_translate("MainWindow", "Anime Title:")) @@ -179,6 +181,7 @@ def retranslateUi(self, MainWindow) -> None: self.pushButton_2.setText(_translate("MainWindow", "Open folder")) self.pushButton_3.setText(_translate("MainWindow", "Save logs as .txt")) self.pushButton_4.setText(_translate("MainWindow", "Stop")) + self.checkBox_2.setText(_translate("MainWindow", "Allow untrusted")) self.menuTranslator.setTitle(_translate("MainWindow", "Translator")) self.actionGet_translation_of_an_anime_title.setText( _translate("MainWindow", "Get translation of an anime title") @@ -353,10 +356,6 @@ def is_everything_good(self) -> None: everything_good = True self.pushButton.setEnabled(False) - if self.lineEdit.text() == "": - self.show_error_popup("You need to input at least 1 uploader name.") - everything_good = False - if self.lineEdit_2.text() == "": self.show_error_popup("You need to input your anime title.") everything_good = False @@ -379,11 +378,15 @@ def is_everything_good(self) -> None: # Setting proper values if everything_good: - global uploaders, anime_name, start_end, quality, option, path + global uploaders, anime_name, start_end, quality, option, untrusted_option, path uploaders = [ u.strip() for u in self.lineEdit.text().strip().split(";") if u != "" ] + + if not uploaders: + uploaders = [""] + anime_name = " ".join(self.lineEdit_2.text().strip().split()) start_end = ( (int(self.spinBox.text()), 10000) @@ -392,7 +395,8 @@ def is_everything_good(self) -> None: ) quality = int(self.comboBox.currentText()[:-1]) option = 1 if self.radioButton.isChecked() else 2 - + untrusted_option = True if self.radioButton_2.isChecked() else False + folder_name = anime_name for c in unhandled_characters: folder_name = folder_name.replace(c, "") @@ -426,8 +430,8 @@ def worker_finished(self) -> None: verbal_base (str): [description] """ - self.notify(f"The anime {anime_name} has been fully checked!") self.set_widget_after_check() + self.notify(f"The anime {anime_name} has been fully checked!") def append_to_logs(self, text: str) -> None: """Appends a text to the logs widget @@ -459,9 +463,9 @@ def run(self) -> None: # Will break if "END" found in title (Erai-raws) while not unexpected_end and episode <= start_end[1] and fails_in_a_row < 10: for uploader in uploaders: - torrent = nyaa.find_torrent(uploader, anime_name, episode, quality) + torrent = nyaa.find_torrent(uploader, anime_name, episode, quality, untrusted_option) - if torrent is not None: + if torrent: fails_in_a_row = 0 if option == 1: diff --git a/lib/nyaa.py b/lib/nyaa.py index bc19985..3f8e520 100644 --- a/lib/nyaa.py +++ b/lib/nyaa.py @@ -24,7 +24,7 @@ def is_in_database(anime_name: str) -> bool: if ( len( NyaaPy.Nyaa.search( - keyword=anime_name, category=1, subcategory=2, filters=2 + keyword=anime_name, category=1, subcategory=2, filters=0 ) ) == 0 @@ -73,7 +73,7 @@ def transfer(torrent: dict) -> bool: return True -def find_torrent(uploader: str, anime_name: str, episode: int, quality: int) -> dict: +def find_torrent(uploader: str, anime_name: str, episode: int, quality: int, untrusted_option: bool) -> dict: """Find if the torrent is already in the database. If not, download it. Args: uploader (str): The name of the uploader. @@ -95,8 +95,14 @@ def find_torrent(uploader: str, anime_name: str, episode: int, quality: int) -> keyword=f"[{uploader}] {anime_name} - {episode} [{quality}p]", category=1, subcategory=2, - filters=2, + filters=0 if untrusted_option else 2, + ) + NyaaPy.Nyaa.search( + keyword=f"[{uploader}] {anime_name} - {episode} ({quality}p)", + category=1, + subcategory=2, + filters=0 if untrusted_option else 2, ) + try: # We take the very closest title to what we are looking for. torrent = None @@ -122,6 +128,6 @@ def find_torrent(uploader: str, anime_name: str, episode: int, quality: int) -> # The only exception possible is that no torrent have been found when NyaaPy.Nyaa.search() # (we are doing dict operations on a None object => raise an exception) except: - return None + return {} return torrent diff --git a/pyqt-ui/base.ui b/pyqt-ui/base.ui index ff4030c..175be9f 100644 --- a/pyqt-ui/base.ui +++ b/pyqt-ui/base.ui @@ -344,6 +344,19 @@ Cancel + + + + 340 + 50 + 101 + 17 + + + + Allow untrusted + +