diff --git a/lbrynet/cryptstream/client/CryptStreamDownloader.py b/lbrynet/cryptstream/client/CryptStreamDownloader.py index 72e10d60c..19a565f1f 100644 --- a/lbrynet/cryptstream/client/CryptStreamDownloader.py +++ b/lbrynet/cryptstream/client/CryptStreamDownloader.py @@ -75,6 +75,9 @@ class CryptStreamDownloader(object): self.points_paid = 0.0 + def __str__(self): + return str(self.stream_name) + def toggle_running(self): if self.stopped is True: return self.start() diff --git a/lbrynet/lbryfile/client/LBRYFileDownloader.py b/lbrynet/lbryfile/client/LBRYFileDownloader.py index 3780192d2..a65f49484 100644 --- a/lbrynet/lbryfile/client/LBRYFileDownloader.py +++ b/lbrynet/lbryfile/client/LBRYFileDownloader.py @@ -172,8 +172,15 @@ class LBRYFileSaver(LBRYFileDownloader): stream_info_manager, payment_rate_manager, wallet, upload_allowed) self.download_directory = download_directory self.file_name = file_name + self.file_written_to = None self.file_handle = None + def __str__(self): + if self.file_written_to is not None: + return str(self.file_written_to) + else: + return str(self.file_name) + def set_stream_info(self): d = LBRYFileDownloader.set_stream_info(self) @@ -210,6 +217,7 @@ class LBRYFileSaver(LBRYFileDownloader): file_name = file_name + "_" + str(ext_num) try: self.file_handle = open(os.path.join(self.download_directory, file_name), 'wb') + self.file_written_to = os.path.join(self.download_directory, file_name) except IOError: log.error(traceback.format_exc()) raise ValueError("Failed to open %s. Make sure you have permission to save files to that" diff --git a/lbrynet/lbrynet_console/ControlHandlers.py b/lbrynet/lbrynet_console/ControlHandlers.py index 78a8dee33..926b96f39 100644 --- a/lbrynet/lbrynet_console/ControlHandlers.py +++ b/lbrynet/lbrynet_console/ControlHandlers.py @@ -481,7 +481,6 @@ class AddStream(CommandHandler): self.options_chosen = [] self.current_option = None self.current_choice = None - self.downloader = None self.got_options_response = False self.loading_failed = False self.payment_rate_manager = PaymentRateManager(base_payment_rate_manager) @@ -764,10 +763,19 @@ class AddStream(CommandHandler): def _start_download(self): d = self._make_downloader() - d.addCallback(lambda stream_downloader: stream_downloader.start()) + + def do_download(stream_downloader): + d = stream_downloader.start() + d.addCallback(lambda _: self._download_succeeded(stream_downloader)) + return d + + d.addCallback(do_download) d.addErrback(self._handle_download_error) return d + def _download_succeeded(self, stream_downloader): + self.console.sendLine("%s has successfully downloaded." % str(stream_downloader)) + def _handle_download_error(self, err): if err.check(InsufficientFundsError): self.console.sendLine("Download stopped due to insufficient funds.")