Browse Source

Update format selection

doc-issue-template
MrS0m30n3 8 years ago
parent
commit
93de083712
3 changed files with 23 additions and 7 deletions
  1. 8
      youtube_dl_gui/mainframe.py
  2. 4
      youtube_dl_gui/optionsmanager.py
  3. 18
      youtube_dl_gui/parsers.py

8
youtube_dl_gui/mainframe.py

@ -470,14 +470,16 @@ class MainFrame(wx.Frame):
if selected_format in VIDEO_FORMATS:
self.opt_manager.options["video_format"] = selected_format
self.opt_manager.options["to_audio"] = False
#self.opt_manager.options["to_audio"] = False
self.opt_manager.options["audio_format"] = "" #NOTE Set to default value, check parsers.py
elif selected_format in AUDIO_FORMATS:
self.opt_manager.options["video_format"] = DEFAULT_FORMATS["default"]
self.opt_manager.options["audio_format"] = selected_format
self.opt_manager.options["to_audio"] = True
#self.opt_manager.options["to_audio"] = True
else:
self.opt_manager.options["video_format"] = DEFAULT_FORMATS["default"]
self.opt_manager.options["to_audio"] = False
self.opt_manager.options["audio_format"] = ""
#self.opt_manager.options["to_audio"] = False
def _update_savepath(self, event):
self.opt_manager.options["save_path"] = self._path_combobox.GetValue()

4
youtube_dl_gui/optionsmanager.py

@ -218,7 +218,7 @@ class OptionsManager(object):
'second_video_format': '0',
'to_audio': False,
'keep_video': False,
'audio_format': 'mp3',
'audio_format': '',
'audio_quality': '5',
'restrict_filenames': False,
'output_format': 1,
@ -303,7 +303,7 @@ class OptionsManager(object):
'264', '138', '242', '243', '244', '247', '248', '271', '272', '82',
'83', '84', '85', '100', '101', '102', '139', '140', '141', '171', '172')
VALID_AUDIO_FORMAT = ('mp3', 'wav', 'aac', 'm4a', 'vorbis', 'opus')
VALID_AUDIO_FORMAT = ('mp3', 'wav', 'aac', 'm4a', 'vorbis', 'opus', '')
VALID_AUDIO_QUALITY = ('0', '5', '9')

18
youtube_dl_gui/parsers.py

@ -97,7 +97,7 @@ class OptionsParser(object):
OptionHolder('save_path', '-o', ''),
OptionHolder('embed_subs', '--embed-subs', False, ['write_auto_subs', 'write_subs']),
OptionHolder('to_audio', '-x', False),
OptionHolder('audio_format', '--audio-format', '', ['to_audio']),
OptionHolder('audio_format', '--audio-format', ''),
OptionHolder('video_format', '-f', '0'),
OptionHolder('subs_lang', '--sub-lang', '', ['write_subs']),
OptionHolder('audio_quality', '--audio-quality', '5', ['to_audio'])
@ -128,7 +128,21 @@ class OptionsParser(object):
# Parse basic youtube-dl command line options
for option in self._ydl_options:
if option.check_requirements(options_dict):
#NOTE Special case should be removed
if option.name == "to_audio":
if options_dict["audio_format"] == "":
value = options_dict[option.name]
if value != option.default_value:
options_list.append(option.flag)
elif option.name == "audio_format":
value = options_dict[option.name]
if value != option.default_value:
options_list.append("-x")
options_list.append(option.flag)
options_list.append(to_string(value))
elif option.check_requirements(options_dict):
value = options_dict[option.name]
if value != option.default_value:

Loading…
Cancel
Save