From 48d1f8ea2b4ed6beb2156187abba6995af419605 Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Sat, 15 Oct 2016 20:03:54 +0300 Subject: [PATCH] Edit formats --- youtube_dl_gui/formats.py | 25 ++++++++++++++++++++----- youtube_dl_gui/mainframe.py | 17 +++++++---------- youtube_dl_gui/optionsframe.py | 8 +++----- youtube_dl_gui/optionsmanager.py | 4 ++-- 4 files changed, 32 insertions(+), 22 deletions(-) diff --git a/youtube_dl_gui/formats.py b/youtube_dl_gui/formats.py index 959f975..3955b04 100644 --- a/youtube_dl_gui/formats.py +++ b/youtube_dl_gui/formats.py @@ -10,11 +10,13 @@ OUTPUT_FORMATS = tdict([ (3, "Custom") ]) -DEFAULT_VIDEO_FORMATS = [ + +DEFAULT_FORMATS = tdict([ ("0", "default") -] +]) -NON_DEFAULT_VIDEO_FORMATS = [ + +VIDEO_FORMATS = tdict([ ("17", "3gp [176x144]"), ("36", "3gp [320x240]"), ("5", "flv [400x240]"), @@ -55,6 +57,19 @@ NON_DEFAULT_VIDEO_FORMATS = [ ("141", "m4a 256k (DASH AUDIO)"), ("171", "webm 48k (DASH AUDIO)"), ("172", "webm 256k (DASH AUDIO)") -] +]) + + +AUDIO_FORMATS = tdict([ + ("mp3", "mp3"), + ("wav", "wav"), + ("aac", "aac"), + ("m4a", "m4a"), + ("vorbis", "vorbis"), + ("opus", "opus") +]) + -VIDEO_FORMATS = tdict(DEFAULT_VIDEO_FORMATS + NON_DEFAULT_VIDEO_FORMATS) +FORMATS = DEFAULT_FORMATS.copy() +FORMATS.update(VIDEO_FORMATS) +FORMATS.update(AUDIO_FORMATS) diff --git a/youtube_dl_gui/mainframe.py b/youtube_dl_gui/mainframe.py index 60cf1b7..c721dd7 100644 --- a/youtube_dl_gui/mainframe.py +++ b/youtube_dl_gui/mainframe.py @@ -50,8 +50,8 @@ from .utils import ( ) from .formats import ( - DEFAULT_VIDEO_FORMATS, - VIDEO_FORMATS + DEFAULT_FORMATS, + FORMATS ) from .info import ( @@ -265,7 +265,7 @@ class MainFrame(wx.Frame): self._folder_icon = self._create_static_bitmap(self._bitmaps["folder"]) self._path_combobox = ExtComboBox(self._panel, 5, style=wx.CB_READONLY) - self._videoformat_combobox = ExtComboBox(self._panel, choices=list(VIDEO_FORMATS.values()), style=wx.CB_READONLY) + self._videoformat_combobox = ExtComboBox(self._panel, style=wx.CB_READONLY) self._download_text = self._create_statictext(self.DOWNLOAD_LIST_LABEL) self._status_list = ListCtrl(self.STATUSLIST_COLUMNS, @@ -431,18 +431,15 @@ class MainFrame(wx.Frame): self._buttons["pause"].SetBitmap(self._bitmaps["pause"], wx.TOP) def _update_videoformat_combobox(self): - video_formats = [] - - for _, label in DEFAULT_VIDEO_FORMATS: - video_formats.append(label) + video_formats = list(DEFAULT_FORMATS.values()) for vformat in self.opt_manager.options["selected_video_formats"]: - video_formats.append(VIDEO_FORMATS[vformat]) + video_formats.append(FORMATS[vformat]) self._videoformat_combobox.Clear() self._videoformat_combobox.AppendItems(video_formats) - current_index = self._videoformat_combobox.FindString(VIDEO_FORMATS[self.opt_manager.options["video_format"]]) + current_index = self._videoformat_combobox.FindString(FORMATS[self.opt_manager.options["video_format"]]) if current_index == wx.NOT_FOUND: self._videoformat_combobox.SetSelection(0) @@ -452,7 +449,7 @@ class MainFrame(wx.Frame): self._update_videoformat(None) def _update_videoformat(self, event): - self.opt_manager.options["video_format"] = VIDEO_FORMATS[self._videoformat_combobox.GetValue()] + self.opt_manager.options["video_format"] = FORMATS[self._videoformat_combobox.GetValue()] def _update_savepath(self, event): self.opt_manager.options["save_path"] = self._path_combobox.GetValue() diff --git a/youtube_dl_gui/optionsframe.py b/youtube_dl_gui/optionsframe.py index 0261a7b..87dd7d8 100644 --- a/youtube_dl_gui/optionsframe.py +++ b/youtube_dl_gui/optionsframe.py @@ -28,9 +28,9 @@ from .utils import ( ) from .formats import ( - NON_DEFAULT_VIDEO_FORMATS, OUTPUT_FORMATS, - VIDEO_FORMATS + VIDEO_FORMATS, + FORMATS ) #TODO Bind events #TODO Adjust layout @@ -335,10 +335,8 @@ class FormatsTab(TabPanel): def __init__(self, *args, **kwargs): super(FormatsTab, self).__init__(*args, **kwargs) - video_formats = [item[1] for item in NON_DEFAULT_VIDEO_FORMATS] - self.video_formats_label = self.crt_statictext("Video formats") - self.video_formats_checklistbox = self.crt_checklistbox(video_formats) + self.video_formats_checklistbox = self.crt_checklistbox(list(VIDEO_FORMATS.values())) self.audio_formats_label = self.crt_statictext("Audio formats") self.audio_formats_checklistbox = self.crt_checklistbox(self.AUDIO_FORMATS) diff --git a/youtube_dl_gui/optionsmanager.py b/youtube_dl_gui/optionsmanager.py index d2c1e04..903b86a 100644 --- a/youtube_dl_gui/optionsmanager.py +++ b/youtube_dl_gui/optionsmanager.py @@ -18,7 +18,7 @@ from .utils import ( from .formats import ( OUTPUT_FORMATS, - VIDEO_FORMATS + FORMATS ) @@ -323,7 +323,7 @@ class OptionsManager(object): # Check if each key has a valid value rules_dict = { - 'video_format': VIDEO_FORMATS.keys(), + 'video_format': FORMATS.keys(), 'second_video_format': VALID_VIDEO_FORMAT, 'audio_format': VALID_AUDIO_FORMAT, 'audio_quality': VALID_AUDIO_QUALITY,