diff --git a/youtube_dl_gui/downloaders.py b/youtube_dl_gui/downloaders.py index 88a6361..6662237 100644 --- a/youtube_dl_gui/downloaders.py +++ b/youtube_dl_gui/downloaders.py @@ -14,6 +14,7 @@ Note: from __future__ import unicode_literals +import re import os import sys import locale @@ -136,11 +137,13 @@ class YoutubeDLDownloader(object): self._data = { 'playlist_index': None, 'playlist_size': None, + 'extension': None, 'filesize': None, 'filename': None, 'percent': None, 'status': None, 'speed': None, + 'path': None, 'eta': None } @@ -252,16 +255,9 @@ class YoutubeDLDownloader(object): def _reset(self): """Reset the data. """ self._return_code = self.OK - self._data = { - 'playlist_index': None, - 'playlist_size': None, - 'filesize': None, - 'filename': None, - 'percent': None, - 'status': None, - 'speed': None, - 'eta': None - } + + for key in self._data: + self._data[key] = None def _sync_data(self, data): """Synchronise self._data with data. It also filters some keys. @@ -273,10 +269,6 @@ class YoutubeDLDownloader(object): """ for key in data: - if key == 'filename': - # Keep only the filename on data['filename'] - data['filename'] = os.path.basename(data['filename']) - if key == 'status': if data['status'] == 'Already Downloaded': # Set self._return_code to already downloaded @@ -390,9 +382,16 @@ def extract_data(stdout): if stdout[0] == '[download]': data_dictionary['status'] = 'Downloading' - # Get filename + # Get path, filename & extension if stdout[1] == 'Destination:': - data_dictionary['filename'] = ' '.join(stdout[2:]) + path, fullname = os.path.split(' '.join(stdout[2:])) + filename, extension = os.path.splitext(fullname) + + data_dictionary['path'] = path + data_dictionary['extension'] = extension + # remove the format that youtube-dl adds during the merging + # process at end of the filename + data_dictionary['filename'] = re.sub('\.f[0-9]{1,3}$', '', filename) # Get progress info if '%' in stdout[1]: @@ -436,6 +435,10 @@ def extract_data(stdout): elif stdout[0] == '[ffmpeg]': data_dictionary['status'] = 'Post Processing' + # Get final extension after merging process + if stdout[1] == 'Merging': + data_dictionary['extension'] = os.path.splitext(' '.join(stdout[4:])[:-1])[1] + else: data_dictionary['status'] = 'Pre Processing' diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index b4987a3..27361eb 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -107,6 +107,7 @@ class MainFrame(wx.Frame): SHUTDOWN_MSG = _("Shutting down system") VIDEO_LABEL = _("Title") + EXTENSION_LABEL = _("Extension") SIZE_LABEL = _("Size") PERCENT_LABEL = _("Percent") ETA_LABEL = _("ETA") @@ -117,11 +118,12 @@ class MainFrame(wx.Frame): # (column_name, column_index, column_label, minimum_width, resizable) STATUSLIST_COLUMNS = ( ('filename', 0, VIDEO_LABEL, 150, True), - ('filesize', 1, SIZE_LABEL, 80, False), - ('percent', 2, PERCENT_LABEL, 65, False), - ('eta', 3, ETA_LABEL, 45, False), - ('speed', 4, SPEED_LABEL, 90, False), - ('status', 5, STATUS_LABEL, 160, False) + ('extension', 1, EXTENSION_LABEL, 60, False), + ('filesize', 2, SIZE_LABEL, 80, False), + ('percent', 3, PERCENT_LABEL, 65, False), + ('eta', 4, ETA_LABEL, 45, False), + ('speed', 5, SPEED_LABEL, 90, False), + ('status', 6, STATUS_LABEL, 160, False) ) def __init__(self, opt_manager, log_manager, parent=None): @@ -541,8 +543,7 @@ class ListCtrl(wx.ListCtrl, ListCtrlAutoWidthMixin): """ for column in self.columns: - column_key = column[0] - self._write_data(data[column_key], data['index'], column[1]) + self._write_data(data[column[0]], data['index'], column[1]) def load_urls(self, url_list, func=None): """Load URLs from the url_list on the ListCtrl widget.