Example #1
0
    def execute_once_search_tokyotosho(self, anime):
        """
        Executes search on this site.

        :type anime: db.Anime
        :param anime: Contains search terms.
        """
        self.log = LoggerManager().get_logger("Downloader-Once-TT")
        self.network = Network()
        tokyotosho = Tokyotosho(self.network)
        self.stopping_thread = False
        self.runningSearch.emit()

        dict_tokyotosho = None
        if anime.check_tokyotosho and not self.stopping_thread:
            dict_tokyotosho = tokyotosho.search(anime.search_terms)
        self.searchResult.emit(dict_tokyotosho)
        self.finish.emit()
Example #2
0
    def execute_once_search_anime_index(self, anime):
        """
        Executes search on this site.

        :type anime: db.Anime
        :param anime: Contains search terms.
        """
        self.log = LoggerManager().get_logger("Downloader-Once-AI")
        self.network = Network()
        anime_index = AnimeIndex(self.network)
        self.stopping_thread = False
        self.runningSearch.emit()

        dict_anime_index = None
        if anime.check_anime_index and not self.stopping_thread:
            dict_anime_index = anime_index.search(anime.search_terms)
        self.searchResult.emit(dict_anime_index)
        self.finish.emit()
Example #3
0
    def execute_once_search_nyaa(self, anime):
        """
        Executes search on this site.

        :type anime: db.Anime
        :param anime: Contains search terms.
        """
        self.log = LoggerManager().get_logger("Downloader-Once-NY")
        self.network = Network()
        if DBManager().get_config().prefer_rss:
            nyaa = NyaaRSS(self.network)
        else:
            nyaa = Nyaa(self.network)
        self.stopping_thread = False
        self.runningSearch.emit()

        dict_nyaa = None
        if anime.check_nyaa and not self.stopping_thread:
            dict_nyaa = nyaa.search(anime.search_terms)
        self.searchResult.emit(dict_nyaa)
        self.finish.emit()
Example #4
0
    def execute_once(self):
        """
        Initializes variables necessary to search for new episodes.
        """
        self.log = LoggerManager().get_logger("Downloader")
        self.log.debug("#####################")

        self.dbManager = DBManager()
        self.animeList = self.dbManager.get_anime_list()
        self.config = self.dbManager.get_config()

        self.network = Network()
        self.anime_index = AnimeIndex(self.network)
        self.anime_tosho = AnimeTosho(self.network)
        self.anirena = Anirena(self.network)
        if self.config.prefer_rss:
            self.nyaa = NyaaRSS(self.network)
        else:
            self.nyaa = Nyaa(self.network)
        self.tokyotosho = Tokyotosho(self.network)

        self.stopping_thread = False

        self.timer = QtCore.QTimer()

        self.running.emit()

        self.log.debug("****************************")
        number_of_downloaded_episodes = self.__search_new_episodes()
        msg = "No" if number_of_downloaded_episodes == 0 else str(
            number_of_downloaded_episodes)
        if not self.stopping_thread:
            self.log.info("%s episodes downloaded, sleeping for %s seconds" %
                          (msg, self.config.sleep_time))
            self.restart.emit()
        else:
            self.log.info("%s episodes downloaded, stopping downloader" % msg)
            self.finish.emit()
Example #5
0
 def __init__(self):
     self.log = LoggerManager().get_logger("Network")
     self.stopping_thread = False
Example #6
0
 def __init__(self, network):
     self.log = LoggerManager().get_logger("AnimeTosho")
     self.network = network
Example #7
0
 def __init__(self, network):
     self.log = LoggerManager().get_logger("Nyaa")
     self.network = network
Example #8
0
    def __init__(self):
        QtCore.QObject.__init__(self)

        # Make sure the required folders/files exist
        if not os.path.isdir(constant.DATA_PATH):
            os.makedirs(constant.DATA_PATH)
        self.log = LoggerManager().get_logger("MAIN")
        try:
            if not os.path.isfile(constant.DB_PATH):
                shutil.copyfile("dbTemplate.db", constant.DB_PATH)
        except (shutil.Error, IOError) as error:
            self.log.print_traceback(error, self.log.critical)
            sys.exit(1)
        try:
            if not os.path.isdir(constant.DEFAULT_TORRENTS_PATH):
                os.makedirs(constant.DEFAULT_TORRENTS_PATH)
        except Exception as error:
            self.log.print_traceback(error, self.log.critical)
            sys.exit(1)

        self.app = QtSingleApplication(constant.GUID, sys.argv)
        self.log.info("---STARTING APPLICATION---")
        if self.app.isRunning():
            self.log.warning(
                "---The launch of another instance of this application will be cancelled---"
            )
            self.app.sendMessage()
            sys.exit(0)
        self.app.messageReceived.connect(self.another_instance_opened)
        self.app.setQuitOnLastWindowClosed(False)

        self.window = None
        self.tray_icon = None

        self.thread = None
        self.downloader = None
        self.timer = None
        self.downloader_is_running = False
        self.downloader_is_restarting = False
        self.downloader_is_stopping = False

        try:
            self.window = WindowMain(self)
            self.tray_icon = SystemTrayIcon(self, self.window)
            self.tray_icon.show()

            show_gui = "-nogui" not in sys.argv
            if show_gui:
                if self.downloader_is_running:
                    self.window.downloader_started()
                else:
                    self.window.downloader_stopped()
                self.window.show()
            elif not self.window.is_visible():
                self.log.info("STARTING DOWNLOADER")
                self.start_downloader()
            self.app.exec_()
        except Exception as unforeseenError:
            self.log.critical("UNFORESEEN ERROR")
            self.log.print_traceback(unforeseenError, self.log.critical)
            if self.tray_icon is not None:
                self.show_tray_message("Unforeseen error occurred...")
            exit()