From cc146247917e67c703aa201d993d12bbaa611687 Mon Sep 17 00:00:00 2001 From: Nabil Hanna Date: Wed, 12 Aug 2009 06:54:09 +0000 Subject: [PATCH] -added new configuration: Restart failed after 10 minutes -do not count already added links from lists into log-file -log also not valid lists --- rsdownloader/src/plugin.py | 21 +++++++++++++++++---- 1 file changed, 17 insertions(+), 4 deletions(-) diff --git a/rsdownloader/src/plugin.py b/rsdownloader/src/plugin.py index c2cbd6f5..0ec80b81 100644 --- a/rsdownloader/src/plugin.py +++ b/rsdownloader/src/plugin.py @@ -51,6 +51,7 @@ config.plugins.RSDownloader.download_sunday = ConfigYesNo(default=True) config.plugins.RSDownloader.count_downloads = ConfigInteger(default=3, limits=(1, 6)) config.plugins.RSDownloader.write_log = ConfigYesNo(default=True) config.plugins.RSDownloader.reconnect_fritz = ConfigYesNo(default=False) +config.plugins.RSDownloader.autorestart_failed = ConfigYesNo(default=False) ############################################################################## @@ -198,6 +199,8 @@ class RSDownload(): self.freeDownloadTimer.callback.append(self.freeDownloadStart) self.checkTimer = eTimer() self.checkTimer.callback.append(self.doCheckTimer) + self.restartFailedTimer = eTimer() + self.restartFailedTimer.callback.append(self.restartFailedCheck) self.finishCallbacks = [] @@ -268,11 +271,18 @@ class RSDownload(): def doCheckTimer(self): if self.size == 0: self.status = _("Failed") + if config.plugins.RSDownloader.autorestart_failed.value: + self.restartFailedTimer.start(10000*60, 1) elif self.progress == 100: self.status = _("Finished") self.downloading = False self.execFinishCallbacks() + def restartFailedCheck(self): + if self.status == _("Failed"): # check if user didn't restart already + self.download = None + self.status = _("Waiting") + def execFinishCallbacks(self): for x in self.finishCallbacks: x() @@ -419,15 +429,17 @@ class RS(): count = 0 for l in f: if l.startswith("http://"): - self.addDownload(l.replace("\n", "").replace("\r", "")) - count += 1 + if (self.addDownload(l.replace("\n", "").replace("\r", ""))) == True: + count += 1 f.close() if count == 0: - writeLog("Empty list: %s"%list) + writeLog("Empty list or downloads already in download list: %s"%list) else: writeLog("Added %d files from list %s..."%(count, list)) except: writeLog("Error while reading list %s!"%list) + else: + writeLog("No *.txt file: %s!"%list) def cleanLists(self): writeLog("Cleaning lists...") @@ -578,7 +590,8 @@ class RSConfig(ConfigListScreen, ChangedScreen): getConfigListEntry(_("Don't download after:"), config.plugins.RSDownloader.end_time), getConfigListEntry(_("Maximal downloads:"), config.plugins.RSDownloader.count_downloads), getConfigListEntry(_("Write log:"), config.plugins.RSDownloader.write_log), - getConfigListEntry(_("Reconnect fritz.Box before downloading:"), config.plugins.RSDownloader.reconnect_fritz)]) + getConfigListEntry(_("Reconnect fritz.Box before downloading:"), config.plugins.RSDownloader.reconnect_fritz), + getConfigListEntry(_("Restart failed after 10 minutes:"), config.plugins.RSDownloader.autorestart_failed)]) self["actions"] = ActionMap(["OkCancelActions", "ColorActions"], {"green": self.save, "cancel": self.exit}, -1) -- 2.20.1