Browse Source

Add downloading videos counter

doc-issue-template
MrS0m30n3 10 years ago
parent
commit
8efcc2e26d
2 changed files with 16 additions and 8 deletions
  1. 20
      youtube_dl_gui/DownloadThread.py
  2. 4
      youtube_dl_gui/YoutubeDLGUI.py

20
youtube_dl_gui/DownloadThread.py

@ -38,12 +38,15 @@ class DownloadManager(Thread):
while self._running:
# If download list is not empty
if self.download_list:
url, index = self._extract_data()
dl_item = self.download_list[0]
index = dl_item['index']
url = dl_item['url']
self._check_download_queue()
if self._running:
self._download(url, index)
self.download_list.pop(0)
else:
if not self.downloading():
self._running = False
@ -69,6 +72,14 @@ class DownloadManager(Thread):
''' Add download item on download list '''
self.download_list.append(item)
def get_items_counter(self):
''' Return download videos counter '''
counter = 0
for thread in self._threads_lst:
if thread.is_alive():
counter += 1
return len(self.download_list) + counter
def close(self, kill=False):
self._callafter('closing')
self._running = False
@ -80,13 +91,6 @@ class DownloadManager(Thread):
dl_thread = DownloadThread(url, index, self.opt_manager, self.log_manager)
self._threads_lst.append(dl_thread)
def _extract_data(self):
''' Extract url, index from download list '''
data = self.download_list.pop(0)
url = data['url']
index = data['index']
return url, index
def _terminate_all(self):
''' Close down all download threads '''
for thread in self._threads_lst:

4
youtube_dl_gui/YoutubeDLGUI.py

@ -190,6 +190,10 @@ class MainFrame(wx.Frame):
topic = msg.topic[0]
data = msg.data
# Report downloading videos number
videos_no = self.download_thread.get_items_counter()
self.status_bar_write('Downloading %s videos' % videos_no)
if topic == 'download_thread':
self.status_list.write(data)

Loading…
Cancel
Save