From 4cba365a3ffcd40f9db03f304dafc94cccb1782f Mon Sep 17 00:00:00 2001 From: MrS0m30n3 Date: Sat, 2 Aug 2014 20:28:20 +0300 Subject: [PATCH] Support more formats when mixing Now you can combine more video formats under Options>Video tab. --- youtube_dl_gui/OptionsFrame.py | 44 +++++++++++++++----------------- youtube_dl_gui/OptionsManager.py | 2 +- youtube_dl_gui/OptionsParser.py | 31 ++++++++++------------ youtube_dl_gui/utils.py | 5 ---- 4 files changed, 35 insertions(+), 47 deletions(-) diff --git a/youtube_dl_gui/OptionsFrame.py b/youtube_dl_gui/OptionsFrame.py index 31ad20f..ab2b944 100644 --- a/youtube_dl_gui/OptionsFrame.py +++ b/youtube_dl_gui/OptionsFrame.py @@ -10,8 +10,7 @@ from .LogManager import LogGUI from .version import __version__ from .utils import ( get_icon_path, - fix_path, - is_dash + fix_path ) from .data import ( @@ -32,8 +31,7 @@ AUDIO_FORMATS = [ "vorbis" ] -VIDEO_FORMATS = [ - "default", +FORMATS = [ "3gp [176x144]", "3gp [320x240]", "flv [400x240]", @@ -68,17 +66,17 @@ VIDEO_FORMATS = [ "mp4 1080p (3D)", "webm 360p (3D)", "webm 480p (3D)", - "webm 720p (3D)" + "webm 720p (3D)", + "m4a 48k (DASH AUDIO)", + "m4a 128k (DASH AUDIO)", + "m4a 256k (DASH AUDIO)", + "webm 48k (DASH AUDIO)", + "webm 256k (DASH AUDIO)" ] -DASH_AUDIO_FORMATS = [ - "none", - "m4a 48k (DASH)", - "m4a 128k (DASH)", - "m4a 256k (DASH)", - "webm 48k (DASH)", - "webm 256k (DASH)" -] +VIDEO_FORMATS = ["default"] + FORMATS + +SECOND_VIDEO_FORMATS = ["none"] + FORMATS SUBS_LANG = [ "English", @@ -566,19 +564,19 @@ class VideoPanel(wx.Panel): def __init__(self, parent): wx.Panel.__init__(self, parent) - self.video_format_combo = wx.ComboBox(self, choices=VIDEO_FORMATS, size=(180, 30)) - self.dash_audio_combo = wx.ComboBox(self, choices=DASH_AUDIO_FORMATS, size=(180, 30)) + self.video_format_combo = wx.ComboBox(self, choices=VIDEO_FORMATS, size=(200, 30)) + self.second_video_format_combo = wx.ComboBox(self, choices=SECOND_VIDEO_FORMATS, size=(200, 30)) main_sizer = wx.BoxSizer(wx.VERTICAL) - main_sizer.AddSpacer(20) + main_sizer.AddSpacer(30) main_sizer.Add(wx.StaticText(self, label='Video Format'), flag=wx.ALIGN_CENTER_HORIZONTAL) main_sizer.AddSpacer(5) main_sizer.Add(self.video_format_combo, flag=wx.ALIGN_CENTER_HORIZONTAL) main_sizer.AddSpacer(10) - main_sizer.Add(wx.StaticText(self, label='DASH Audio'), flag=wx.ALIGN_CENTER_HORIZONTAL) + main_sizer.Add(wx.StaticText(self, label='Mix Video Format'), flag=wx.ALIGN_CENTER_HORIZONTAL) main_sizer.AddSpacer(5) - main_sizer.Add(self.dash_audio_combo, flag=wx.ALIGN_CENTER_HORIZONTAL) + main_sizer.Add(self.second_video_format_combo, flag=wx.ALIGN_CENTER_HORIZONTAL) self.SetSizer(main_sizer) @@ -586,21 +584,21 @@ class VideoPanel(wx.Panel): def OnVideoFormatPick(self, event): ''' Event handler for self.video_format_combo. ''' - if is_dash(self.video_format_combo.GetValue()): - self.dash_audio_combo.Enable() + if self.video_format_combo.GetValue() != 'default': + self.second_video_format_combo.Enable() else: - self.dash_audio_combo.Disable() + self.second_video_format_combo.Disable() def load_options(self, opt_manager): ''' Load panel options from OptionsHandler object. ''' self.video_format_combo.SetValue(opt_manager.options['video_format']) - self.dash_audio_combo.SetValue(opt_manager.options['dash_audio_format']) + self.second_video_format_combo.SetValue(opt_manager.options['second_video_format']) self.OnVideoFormatPick(None) def save_options(self, opt_manager): ''' Save panel options to OptionsHandler object. ''' opt_manager.options['video_format'] = self.video_format_combo.GetValue() - opt_manager.options['dash_audio_format'] = self.dash_audio_combo.GetValue() + opt_manager.options['second_video_format'] = self.second_video_format_combo.GetValue() class OutputPanel(wx.Panel): diff --git a/youtube_dl_gui/OptionsManager.py b/youtube_dl_gui/OptionsManager.py index 5d6b980..fbbc986 100644 --- a/youtube_dl_gui/OptionsManager.py +++ b/youtube_dl_gui/OptionsManager.py @@ -57,7 +57,7 @@ class OptionsManager(object): self.options = { 'save_path': get_home(), 'video_format': 'default', - 'dash_audio_format': 'none', + 'second_video_format': 'none', 'to_audio': False, 'keep_video': False, 'audio_format': 'mp3', diff --git a/youtube_dl_gui/OptionsParser.py b/youtube_dl_gui/OptionsParser.py index 25c8a48..6b9f18f 100644 --- a/youtube_dl_gui/OptionsParser.py +++ b/youtube_dl_gui/OptionsParser.py @@ -3,8 +3,7 @@ ''' Parse OptionsManager.options. ''' from .utils import ( - fix_path, - is_dash + fix_path ) SUBS_LANG = { @@ -20,6 +19,7 @@ SUBS_LANG = { VIDEO_FORMATS = { "default": "0", + "none": "0", "3gp [176x144]": "17", "3gp [320x240]": "36", "flv [400x240]": "5", @@ -54,16 +54,12 @@ VIDEO_FORMATS = { "mp4 1080p (3D)": "85", "webm 360p (3D)": "100", "webm 480p (3D)": "101", - "webm 720p (3D)": "102" -} - -DASH_AUDIO_FORMATS = { - "none": "0", - "m4a 48k (DASH)": "139", - "m4a 128k (DASH)": "140", - "m4a 256k (DASH)": "141", - "webm 48k (DASH)": "171", - "webm 256k (DASH)": "172" + "webm 720p (3D)": "102", + "m4a 48k (DASH AUDIO)": "139", + "m4a 128k (DASH AUDIO)": "140", + "m4a 256k (DASH AUDIO)": "141", + "webm 48k (DASH AUDIO)": "171", + "webm 256k (DASH AUDIO)": "172" } AUDIO_QUALITY = { @@ -151,12 +147,11 @@ class OptionsParser(): self.options_list.append('-f') video_format = VIDEO_FORMATS[self._options['video_format']] - - if is_dash(self._options['video_format']): - if is_dash(self._options['dash_audio_format']): - dash_format = DASH_AUDIO_FORMATS[self._options['dash_audio_format']] - - video_format += '+' + dash_format + second_video_format = VIDEO_FORMATS[self._options['second_video_format']] + + if video_format != "0": + if second_video_format != "0": + video_format += '+' + second_video_format self.options_list.append(video_format) diff --git a/youtube_dl_gui/utils.py b/youtube_dl_gui/utils.py index b380899..6956a7f 100644 --- a/youtube_dl_gui/utils.py +++ b/youtube_dl_gui/utils.py @@ -7,11 +7,6 @@ import sys import subprocess -def is_dash(word): - ''' Return True if "DASH" in word. ''' - return "DASH" in word - - def path_seperator(): ''' Return path seperator for current OS. ''' return '\\' if os.name == 'nt' else '/'