diff --git a/youtube_dl_gui/downloadmanager.py b/youtube_dl_gui/downloadmanager.py index 5c50216..33fbf88 100644 --- a/youtube_dl_gui/downloadmanager.py +++ b/youtube_dl_gui/downloadmanager.py @@ -335,8 +335,9 @@ class DownloadManager(Thread): WAIT_TIME = 0.1 - def __init__(self, download_list, opt_manager, log_manager=None): + def __init__(self, parent, download_list, opt_manager, log_manager=None): super(DownloadManager, self).__init__() + self.parent = parent self.opt_manager = opt_manager self.log_manager = log_manager self.download_list = download_list @@ -473,8 +474,10 @@ class DownloadManager(Thread): def _check_youtubedl(self): """Check if youtube-dl binary exists. If not try to download it. """ - if not os_path_exists(self._youtubedl_path()): - UpdateThread(self.opt_manager.options['youtubedl_path'], True).join() + if not os_path_exists(self._youtubedl_path()) and self.parent.update_thread is None: + self.parent.update_thread = UpdateThread(self.opt_manager.options['youtubedl_path'], True) + self.parent.update_thread.join() + self.parent.update_thread = None def _get_worker(self): for worker in self._workers: diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index a6abe99..8709403 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -435,7 +435,10 @@ class MainFrame(wx.Frame): total_percentage /= active + completed + error + queued msg = self.URL_REPORT_MSG.format(total_percentage, queued, paused, active, completed, error) - self._status_bar_write(msg) + + if self.update_thread is None: + # Dont overwrite the update messages + self._status_bar_write(msg) def _update_pause_button(self, event): selected_rows = self._status_list.get_all_selected() @@ -658,15 +661,15 @@ class MainFrame(wx.Frame): self._update_pause_button(None) def _on_start(self, event): - if self.update_thread is not None and self.update_thread.is_alive(): - self._create_popup(_("Update in progress. Please wait for the update to complete"), - self.WARNING_LABEL, - wx.OK | wx.ICON_EXCLAMATION) - else: - if self.download_manager is None: - self._start_download() + if self.download_manager is None: + if self.update_thread is not None and self.update_thread.is_alive(): + self._create_popup(_("Update in progress. Please wait for the update to complete"), + self.WARNING_LABEL, + wx.OK | wx.ICON_EXCLAMATION) else: - self.download_manager.stop_downloads() + self._start_download() + else: + self.download_manager.stop_downloads() def _on_savepath(self, event): dlg = wx.DirDialog(self, self.CHOOSE_DIRECTORY, self._path_combobox.GetStringSelection(), wx.DD_CHANGE_DIR) @@ -977,7 +980,7 @@ class MainFrame(wx.Frame): wx.OK | wx.ICON_EXCLAMATION) else: self._app_timer.Start(100) - self.download_manager = DownloadManager(self._download_list, self.opt_manager, self.log_manager) + self.download_manager = DownloadManager(self, self._download_list, self.opt_manager, self.log_manager) self._status_bar_write(self.DOWNLOAD_STARTED) self._buttons["start"].SetLabel(self.STOP_LABEL)