diff --git a/tests/test_ditem.py b/tests/test_ditem.py index 5c9c62a..6c8176b 100644 --- a/tests/test_ditem.py +++ b/tests/test_ditem.py @@ -46,7 +46,9 @@ class TestItemInit(unittest.TestCase): "percent": "0%", "speed": "-", "eta": "-", - "status": "Queued"} + "status": "Queued", + "playlist_size": "", + "playlist_index": ""} ) @@ -144,7 +146,9 @@ class TestUpdateStats(unittest.TestCase): "speed": "200.00KiB/s", "eta": "00:38", "status": "Downloading", - "path": path}) + "path": path, + "playlist_size": "10", + "playlist_index": "1"}) self.assertEqual(self.ditem.path, path) self.assertEqual(self.ditem.filenames, ["somefilename"]) @@ -157,10 +161,14 @@ class TestUpdateStats(unittest.TestCase): "percent": "2.0%", "speed": "200.00KiB/s", "eta": "00:38", - "status": "Downloading"} + "status": "Downloading", + "playlist_size": "10", + "playlist_index": "1"} ) - self.ditem.update_stats({"filename": "someotherfilename", "extension": ".m4a"}) + self.ditem.update_stats({"filename": "someotherfilename", + "extension": ".m4a", + "playlist_index": "2"}) self.assertEqual(self.ditem.filenames, ["somefilename", "someotherfilename"]) self.assertEqual(self.ditem.extensions, [".mp4", ".m4a"]) @@ -172,7 +180,9 @@ class TestUpdateStats(unittest.TestCase): "percent": "2.0%", "speed": "200.00KiB/s", "eta": "00:38", - "status": "Downloading"} + "status": "Downloading", + "playlist_size": "10", + "playlist_index": "2"} ) def test_update_stats_invalid_input(self): @@ -185,7 +195,9 @@ class TestUpdateStats(unittest.TestCase): "percent": "", "speed": "", "eta": "", - "status": ""}) + "status": "", + "playlist_size": "", + "playlist_index": ""}) self.assertEqual( self.ditem.progress_stats, @@ -195,7 +207,9 @@ class TestUpdateStats(unittest.TestCase): "percent": "0%", "speed": "-", "eta": "-", - "status": "Queued"} + "status": "Queued", + "playlist_size": "", + "playlist_index": ""} ) def test_update_stats_not_string(self): @@ -246,7 +260,9 @@ class TestReset(unittest.TestCase): "percent": "100%", "speed": "-", "eta": "00:00", - "status": "Error" + "status": "Error", + "playlist_size": "10", + "playlist_index": "8" } self.ditem.reset() @@ -263,7 +279,9 @@ class TestReset(unittest.TestCase): "percent": "0%", "speed": "-", "eta": "-", - "status": "Queued"} + "status": "Queued", + "playlist_size": "", + "playlist_index": ""} ) def test_reset_paused_stage(self): diff --git a/youtube_dl_gui/downloadmanager.py b/youtube_dl_gui/downloadmanager.py index 809e621..f7168c8 100644 --- a/youtube_dl_gui/downloadmanager.py +++ b/youtube_dl_gui/downloadmanager.py @@ -129,7 +129,9 @@ class DownloadItem(object): "percent": "0%", "speed": "-", "eta": "-", - "status": self.stage + "status": self.stage, + "playlist_size": "", + "playlist_index": "" } self.progress_stats = dict(self.default_values) @@ -659,13 +661,13 @@ class Worker(Thread): # Build the playlist status if there is an update # REFACTOR re-implement this on DownloadItem or ListCtrl level? - if self._data['playlist_index'] is not None: - if 'status' in temp_dict or 'playlist_index' in temp_dict: - temp_dict['status'] = '{status} {index}/{size}'.format( - status=self._data['status'], - index=self._data['playlist_index'], - size=self._data['playlist_size'] - ) + #if self._data['playlist_index'] is not None: + #if 'status' in temp_dict or 'playlist_index' in temp_dict: + #temp_dict['status'] = '{status} {index}/{size}'.format( + #status=self._data['status'], + #index=self._data['playlist_index'], + #size=self._data['playlist_size'] + #) if len(temp_dict): self._talk_to_gui('send', temp_dict) diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index ba2720e..bec3a96 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -1234,10 +1234,20 @@ class ListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin): self._list_index += 1 def _update_from_item(self, row, download_item): - for key in download_item.progress_stats: + progress_stats = download_item.progress_stats + + for key in self.columns: column = self.columns[key][0] - self.SetStringItem(row, column, download_item.progress_stats[key]) + if key == "status" and progress_stats["playlist_index"]: + # Not the best place but we build the playlist status here + status = "{0} {1}/{2}".format(progress_stats["status"], + progress_stats["playlist_index"], + progress_stats["playlist_size"]) + + self.SetStringItem(row, column, status) + else: + self.SetStringItem(row, column, progress_stats[key]) def add_url(self, url): """Adds the given url in the ListCtrl.