Browse Source

Do not show 'Total Progress' message while updating

The code looks pretty bad i should come back and change
all this stuff on the refactor phase
doc-issue-template
MrS0m30n3 8 years ago
parent
commit
53ccf5f67c
2 changed files with 19 additions and 13 deletions
  1. 9
      youtube_dl_gui/downloadmanager.py
  2. 23
      youtube_dl_gui/mainframe.py

9
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:

23
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)

Loading…
Cancel
Save