Ejemplo n.º 1
0
    def search(self, button: urwid.Button):
        """
        Starts searching with the configured options

        :param button: The Button that called this method
        :return:       None
        """
        if not self.searching:

            self.searching = True

            search_engine = list(
                filter(lambda x: x.get_state(),
                       self.search_engine_options))[0].get_label()
            searcher = PackSearcher() if search_engine == "All" \
                else PackSearcher([search_engine])
            search_term = self.search_term_edit.get_edit_text()

            def do_search():
                self.spin_buttons(search=True)
                self.search_results = searcher.search(search_term)
                self.refresh_ui()
                self.searching = False

            Thread(target=do_search).start()
Ejemplo n.º 2
0
    def search(self):
        """
        Starts the XDCC search

        :return: None
        """
        if not self.searching:

            self.searching = True

            search_term = self.search_term_edit.text()
            search_engine = self.search_engine_combo_box.currentText()
            search_engines = [search_engine] if search_engine != "All" else\
                PackSearcher.get_available_pack_searchers()

            searcher = PackSearcher(search_engines)

            # noinspection PyUnresolvedReferences
            def search_thread():

                self.spinner_start_signal.emit("search")
                self.search_results = searcher.search(search_term)
                self.refresh_search_results_signal.emit("")
                self.searching = False

            Thread(target=search_thread).start()
Ejemplo n.º 3
0
    def test_getting_searchers(self):

        procedures = PackSearcher.get_available_pack_searchers()
        searcher = PackSearcher()

        for procedure in procedures:
            self.assertTrue(
                PackSearcher.procedure_map[procedure] in searcher.procedures)
Ejemplo n.º 4
0
    def test_search_and_download_namibsun(self):

        searcher = PackSearcher(["namibsun"])
        packs = searcher.search("1_test.txt") + searcher.search("2_test.txt")

        XDCCDownloader(packs[0].get_server(), "random").download(packs)

        self.assertTrue(os.path.isfile("1_test.txt"))
        self.assertTrue(os.path.isfile("2_test.txt"))
Ejemplo n.º 5
0
    def test_selected_searchers(self):

        searcher = PackSearcher(["nibl", "namibsun"])
        self.assertEqual(
            len(searcher.search("AHQ Official Dragon Ball Z Releases.txt")), 1)

        for procedure in PackSearcher.get_available_pack_searchers():

            if procedure not in ["nibl", "namibsun"]:
                self.assertFalse(PackSearcher.procedure_map[procedure] in
                                 searcher.procedures)
Ejemplo n.º 6
0
    def __init__(self):
        """
        Initializes the TUI's various widgets
        """
        self.upper_body = []
        self.upper_middle_body = []
        self.middle_body = []
        self.lower_middle_body = []
        self.lower_body = []

        self.loop = None
        self.top = None
        self.list_walker = None

        self.downloading = False
        self.searching = False

        self.downloader = None

        self.search_results = []
        self.search_results_checks = []
        self.download_queue = []
        self.download_queue_checks = []

        self.gpl_notice = urwid.Text(
            "XDCC Downloader V " + version + "\n"
            "Copyright (C) 2016-2017 Hermann Krumrey\n\n"
            "This program comes with ABSOLUTELY NO WARRANTY.\n"
            "This is free software, and you are welcome to redistribute it\n"
            "under certain conditions.")
        self.message_edit = urwid.Edit(caption="XDCC Message: ", edit_text="")
        self.server_edit = urwid.Edit(caption="Server: ",
                                      edit_text="irc.rizon.net")
        self.add_pack_button = urwid.Button("Add Pack")

        self.search_engine_label = urwid.Text("Search Engines")
        self.search_engine_options = []
        for search_engine in ["All"] + \
                PackSearcher.get_available_pack_searchers():
            urwid.RadioButton(self.search_engine_options, search_engine)

        self.search_term_edit = urwid.Edit(caption="Search Term: ",
                                           edit_text="")
        self.search_button = urwid.Button("Search")
        self.search_results_label = urwid.Text("Search Results:")
        self.add_search_result_button = urwid.Button("Add Selected Packs")

        self.download_queue_label = urwid.Text("Download_Queue")
        self.remove_pack_button = urwid.Button("Remove Selected Packs")

        self.destination_edit = urwid.Edit(caption="Destination Directory: ",
                                           edit_text=os.getcwd())
        self.download_button = urwid.Button("Download")
        self.single_progress_bar = urwid.ProgressBar("Progress", "Total")
        self.total_progress_bar = urwid.ProgressBar("Progress", "Total")

        self.connect_widgets()
        self.lay_out()
Ejemplo n.º 7
0
    def test_all_searchers(self):

        # Subject to change when real-world stuff changes
        for term, amount in {
                "AHQ Official Dragon Ball Z Releases.txt": 2,
                "Gin.txt": 1,
                "mashiro.txt": 1,
                "1_test.txt": 1
        }.items():
            results = PackSearcher().search(term)
            self.assertEqual(len(results), amount)
Ejemplo n.º 8
0
    def __init__(self, parent: QMainWindow = None):
        """
        Sets up the interactive UI elements

        :param parent: the parent window
        """
        super().__init__(parent)
        self.setupUi(self)

        header = self.search_result_tree_widget.header()
        header.hideSection(header.logicalIndex(header.visualIndex(0)))

        self.spinner_start_signal.connect(lambda x: self.start_spinner(x))
        self.refresh_search_results_signal.connect(self.refresh_search_results)
        self.refresh_download_queue_signal.connect(self.refresh_download_queue)
        self.progress_update_signal.connect(self.progress_update)
        self.spinner_updater_signal.connect(
            lambda x, y: self.update_spinner(x, y))
        self.show_download_complete_message_signal.connect(
            self.show_download_complete_message)

        self.searching = False
        self.downloading = False
        self.downloader = None

        self.search_results = []
        self.download_queue = []

        for searcher in ["All"] + PackSearcher.get_available_pack_searchers():
            self.search_engine_combo_box.addItem(searcher)
        self.destination_edit.setText(os.getcwd())

        self.search_button.clicked.connect(self.search)
        self.download_button.clicked.connect(self.download)
        self.add_button.clicked.connect(self.add_pack)

        self.search_term_edit.returnPressed.connect(self.search)

        self.up_arrow_button.clicked.connect(lambda: self.move_packs(up=True))
        self.left_arrow_button.clicked.connect(self.remove_packs_from_queue)
        self.rigth_arrow_button.clicked.connect(self.add_packs_to_queue)
        self.down_arrow_button.clicked.connect(
            lambda: self.move_packs(down=True))