Browse Source

Change options system

Now youtubedlg stores the non-string part of the options
into settings.json. This way we only need a TwoWayOrderedDict
on the optionsframe.py module to store the options(video_format,
 audio_quality, etc..) instead of using a dictionary on the parsers.py
module and a list with all the available values on the optionsframe.py
module. This change also helps us to keep all the GUI strings on the
GUI modules making it easier to translate the GUI.

NOTE
=====
Youtubedlg will reset all the stored options on the first usage of the
new system due to compatibility issues with the old settings.json.

CHANGES
=======

optionsframe.py
  Store the values into a TwoWayOrderedDict and map their values-keys
  on the load-save_options methods.

optionsmanager.py
  Enable the value check system on the _settings_are_valid() method.

parsers.py
  Remove all the module attributes and some of the options_build methods.
doc-issue-template
MrS0m30n3 9 years ago
parent
commit
c9e7fee8dc
3 changed files with 131 additions and 265 deletions
  1. 196
      youtube_dl_gui/optionsframe.py
  2. 70
      youtube_dl_gui/optionsmanager.py
  3. 130
      youtube_dl_gui/parsers.py

196
youtube_dl_gui/optionsframe.py

@ -16,6 +16,8 @@ from .info import (
__author__
)
from .utils import TwoWayOrderedDict as twodict
class OptionsFrame(wx.Frame):
@ -90,8 +92,6 @@ class OptionsFrame(wx.Frame):
self.Bind(wx.EVT_CLOSE, self._on_close)
self.load_all_options()
def _on_close(self, event):
"""Event handler for wx.EVT_CLOSE event.
@ -720,24 +720,17 @@ class AudioTab(TabPanel):
"""Options frame audio tab.
Attributes:
AUDIO_QUALITY (list): Contains audio qualities. See AUDIO_QUALITY
attribute of the parsers module for available values.
AUDIO_QUALITY (TwoWayOrderedDict): Contains audio qualities.
AUDIO_FORMATS (list): Contains audio formats.
See optionsmanager.OptionsManager 'audio_format' option for available
values.
See optionsmanager.OptionsManager 'audio_format' option
for available values.
*_LABEL (string): Constant string label for the widgets.
"""
AUDIO_QUALITY = ['high', 'mid', 'low']
AUDIO_FORMATS = [
"mp3",
"wav",
"aac",
"m4a",
"vorbis"
]
AUDIO_QUALITY = twodict([("0", "high"), ("5", "mid"), ("9", "low")])
AUDIO_FORMATS = ["mp3", "wav", "aac", "m4a", "vorbis"]
TO_AUDIO_LABEL = "Convert to Audio"
KEEP_VIDEO_LABEL = "Keep Video"
@ -750,7 +743,7 @@ class AudioTab(TabPanel):
self.to_audio_checkbox = self.create_checkbox(self.TO_AUDIO_LABEL, self._on_audio_check)
self.keep_video_checkbox = self.create_checkbox(self.KEEP_VIDEO_LABEL)
self.audioformat_combo = self.create_combobox(self.AUDIO_FORMATS, (160, 30))
self.audioquality_combo = self.create_combobox(self.AUDIO_QUALITY, (80, 25))
self.audioquality_combo = self.create_combobox(self.AUDIO_QUALITY.values(), (80, 25))
self.audioformat_text = self.create_statictext(self.AUDIO_FORMAT_LABEL)
self.audioquality_text = self.create_statictext(self.AUDIO_QUALITY_LABEL)
@ -784,14 +777,14 @@ class AudioTab(TabPanel):
self.to_audio_checkbox.SetValue(self.opt_manager.options['to_audio'])
self.keep_video_checkbox.SetValue(self.opt_manager.options['keep_video'])
self.audioformat_combo.SetValue(self.opt_manager.options['audio_format'])
self.audioquality_combo.SetValue(self.opt_manager.options['audio_quality'])
self.audioquality_combo.SetValue(self.AUDIO_QUALITY[self.opt_manager.options['audio_quality']])
self._on_audio_check(None)
def save_options(self):
self.opt_manager.options['to_audio'] = self.to_audio_checkbox.GetValue()
self.opt_manager.options['keep_video'] = self.keep_video_checkbox.GetValue()
self.opt_manager.options['audio_format'] = self.audioformat_combo.GetValue()
self.opt_manager.options['audio_quality'] = self.audioquality_combo.GetValue()
self.opt_manager.options['audio_quality'] = self.AUDIO_QUALITY[self.audioquality_combo.GetValue()]
class VideoTab(TabPanel):
@ -799,10 +792,9 @@ class VideoTab(TabPanel):
"""Options frame video tab.
Attributes:
FORMATS (list): Contains video formats. This list contains all the
available video formats without the 'default' and 'none' options.
See VIDEO_FORMATS attribute of the parsers module for available
values.
FORMATS (TwoWayOrderedDict): Contains video formats. This list
contains all the available video formats without the 'default'
and 'none' options.
VIDEO_FORMATS (list): List that contains all the video formats
plus the 'default' one.
@ -817,51 +809,51 @@ class VideoTab(TabPanel):
"""
FORMATS = [
"3gp [176x144]",
"3gp [320x240]",
"flv [400x240]",
"flv [640x360]",
"flv [854x480]",
"webm [640x360]",
"webm [854x480]",
"webm [1280x720]",
"webm [1920x1080]",
"mp4 [640x360]",
"mp4 [1280x720]",
"mp4 [1920x1080]",
"mp4 [4096x3072]",
"mp4 144p (DASH)",
"mp4 240p (DASH)",
"mp4 360p (DASH)",
"mp4 480p (DASH)",
"mp4 720p (DASH)",
"mp4 1080p (DASH)",
"mp4 1440p (DASH)",
"mp4 2160p (DASH)",
"webm 240p (DASH)",
"webm 360p (DASH)",
"webm 480p (DASH)",
"webm 720p (DASH)",
"webm 1080p (DASH)",
"webm 1440p (DASH)",
"webm 2160p (DASH)",
"mp4 360p (3D)",
"mp4 480p (3D)",
"mp4 720p (3D)",
"mp4 1080p (3D)",
"webm 360p (3D)",
"webm 480p (3D)",
"webm 720p (3D)",
"m4a 48k (DASH AUDIO)",
"m4a 128k (DASH AUDIO)",
"m4a 256k (DASH AUDIO)",
"webm 48k (DASH AUDIO)",
"webm 256k (DASH AUDIO)"
]
FORMATS = twodict([
("17", "3gp [176x144]"),
("36", "3gp [320x240]"),
("5", "flv [400x240]"),
("34", "flv [640x360]"),
("35", "flv [854x480]"),
("43", "webm [640x360]"),
("44", "webm [854x480]"),
("45", "webm [1280x720]"),
("46", "webm [1920x1080]"),
("18", "mp4 [640x360]"),
("22", "mp4 [1280x720]"),
("37", "mp4 [1920x1080]"),
("38", "mp4 [4096x3072]"),
("160", "mp4 144p (DASH)"),
("133", "mp4 240p (DASH)"),
("134", "mp4 360p (DASH)"),
("135", "mp4 480p (DASH)"),
("136", "mp4 720p (DASH)"),
("137", "mp4 1080p (DASH)"),
("264", "mp4 1440p (DASH)"),
("138", "mp4 2160p (DASH)"),
("242", "webm 240p (DASH)"),
("243", "webm 360p (DASH)"),
("244", "webm 480p (DASH)"),
("247", "webm 720p (DASH)"),
("248", "webm 1080p (DASH)"),
("271", "webm 1440p (DASH)"),
("272", "webm 2160p (DASH)"),
("82", "mp4 360p (3D)"),
("83", "mp4 480p (3D)"),
("84", "mp4 720p (3D)"),
("85", "mp4 1080p (3D)"),
("100", "webm 360p (3D)"),
("101", "webm 480p (3D)"),
("102", "webm 720p (3D)"),
("139", "m4a 48k (DASH AUDIO)"),
("140", "m4a 128k (DASH AUDIO)"),
("141", "m4a 256k (DASH AUDIO)"),
("171", "webm 48k (DASH AUDIO)"),
("172", "webm 256k (DASH AUDIO)")
])
VIDEO_FORMATS = ["default"] + FORMATS
SECOND_VIDEO_FORMATS = ["none"] + FORMATS
VIDEO_FORMATS = ["default"] + FORMATS.values()
SECOND_VIDEO_FORMATS = ["none"] + FORMATS.values()
COMBOBOX_SIZE = (200, 30)
@ -902,13 +894,13 @@ class VideoTab(TabPanel):
self.sec_videoformat_combo.Enable(condition)
def load_options(self):
self.videoformat_combo.SetValue(self.opt_manager.options['video_format'])
self.sec_videoformat_combo.SetValue(self.opt_manager.options['second_video_format'])
self.videoformat_combo.SetValue(self.FORMATS.get(self.opt_manager.options['video_format'], 'default'))
self.sec_videoformat_combo.SetValue(self.FORMATS.get(self.opt_manager.options['second_video_format'], 'none'))
self._on_videoformat(None)
def save_options(self):
self.opt_manager.options['video_format'] = self.videoformat_combo.GetValue()
self.opt_manager.options['second_video_format'] = self.sec_videoformat_combo.GetValue()
self.opt_manager.options['video_format'] = self.FORMATS.get(self.videoformat_combo.GetValue(), '0')
self.opt_manager.options['second_video_format'] = self.FORMATS.get(self.sec_videoformat_combo.GetValue(), '0')
class OutputTab(TabPanel):
@ -1004,24 +996,23 @@ class FilesystemTab(TabPanel):
"""Options frame filesystem tab.
Attributes:
FILESIZES (list): Contains filesize units. See FILESIZE_UNITS attribute
of the parsers module for available values.
FILESIZES (TwoWayOrderedDict): Contains filesize units.
*_LABEL (string): Constant string label for the widgets.
"""
FILESIZES = [
'Bytes',
'Kilobytes',
'Megabytes',
'Gigabytes',
'Terabytes',
'Petabytes',
'Exabytes',
'Zettabytes',
'Yottabytes'
]
FILESIZES = twodict([
("", "Bytes"),
("k", "Kilobytes"),
("m", "Megabytes"),
("g", "Gigabytes"),
("t", "Terabytes"),
("p", "Petabytes"),
("e", "Exabytes"),
("z", "Zettabytes"),
("y", "Yottabytes")
])
IGN_ERR_LABEL = "Ignore Errors"
OPEN_DIR_LABEL = "Open destination folder"
@ -1043,8 +1034,8 @@ class FilesystemTab(TabPanel):
self.min_filesize_spinner = self.create_spinctrl((0, 1024))
self.max_filesize_spinner = self.create_spinctrl((0, 1024))
self.min_filesize_combo = self.create_combobox(self.FILESIZES)
self.max_filesize_combo = self.create_combobox(self.FILESIZES)
self.min_filesize_combo = self.create_combobox(self.FILESIZES.values())
self.max_filesize_combo = self.create_combobox(self.FILESIZES.values())
self.min_text = self.create_statictext(self.MIN_LABEL)
self.max_text = self.create_statictext(self.MAX_LABEL)
@ -1117,8 +1108,8 @@ class FilesystemTab(TabPanel):
self.write_thumbnail_checkbox.SetValue(self.opt_manager.options['write_thumbnail'])
self.min_filesize_spinner.SetValue(self.opt_manager.options['min_filesize'])
self.max_filesize_spinner.SetValue(self.opt_manager.options['max_filesize'])
self.min_filesize_combo.SetValue(self.opt_manager.options['min_filesize_unit'])
self.max_filesize_combo.SetValue(self.opt_manager.options['max_filesize_unit'])
self.min_filesize_combo.SetValue(self.FILESIZES[self.opt_manager.options['min_filesize_unit']])
self.max_filesize_combo.SetValue(self.FILESIZES[self.opt_manager.options['max_filesize_unit']])
def save_options(self):
self.opt_manager.options['write_thumbnail'] = self.write_thumbnail_checkbox.GetValue()
@ -1128,8 +1119,8 @@ class FilesystemTab(TabPanel):
self.opt_manager.options['open_dl_dir'] = self.open_dir_checkbox.GetValue()
self.opt_manager.options['min_filesize'] = self.min_filesize_spinner.GetValue()
self.opt_manager.options['max_filesize'] = self.max_filesize_spinner.GetValue()
self.opt_manager.options['min_filesize_unit'] = self.min_filesize_combo.GetValue()
self.opt_manager.options['max_filesize_unit'] = self.max_filesize_combo.GetValue()
self.opt_manager.options['min_filesize_unit'] = self.FILESIZES[self.min_filesize_combo.GetValue()]
self.opt_manager.options['max_filesize_unit'] = self.FILESIZES[self.max_filesize_combo.GetValue()]
class SubtitlesTab(TabPanel):
@ -1137,22 +1128,21 @@ class SubtitlesTab(TabPanel):
"""Options frame subtitles tab.
Attributes:
SUBS_LANG (list): Contains subtitles languages. See SUBS_LANG attribute
of the parsers module for available values.
SUBS_LANG (TwoWayOrderedDict): Contains subtitles languages.
*_LABEL (string): Constant string label for the widgets.
"""
SUBS_LANG = [
"English",
"Greek",
"Portuguese",
"French",
"Italian",
"Russian",
"Spanish",
"German"
]
SUBS_LANG = twodict([
("en", "English"),
("gr", "Greek"),
("pt", "Portuguese"),
("fr", "French"),
("it", "Italian"),
("ru", "Russian"),
("es", "Spanish"),
("de", "German")
])
DL_SUBS_LABEL = "Download subtitle file by language"
DL_ALL_SUBS_LABEL = "Download all available subtitles"
@ -1167,7 +1157,7 @@ class SubtitlesTab(TabPanel):
self.write_all_subs_checkbox = self.create_checkbox(self.DL_ALL_SUBS_LABEL, self._on_subs_pick)
self.write_auto_subs_checkbox = self.create_checkbox(self.DL_AUTO_SUBS_LABEL, self._on_subs_pick)
self.embed_subs_checkbox = self.create_checkbox(self.EMBED_SUBS_LABEL)
self.subs_lang_combo = self.create_combobox(self.SUBS_LANG, (140, 30))
self.subs_lang_combo = self.create_combobox(self.SUBS_LANG.values(), (140, 30))
self.subs_lang_text = self.create_statictext(self.SUBS_LANG_LABEL)
@ -1223,7 +1213,7 @@ class SubtitlesTab(TabPanel):
self.write_auto_subs_checkbox.Enable()
def load_options(self):
self.subs_lang_combo.SetValue(self.opt_manager.options['subs_lang'])
self.subs_lang_combo.SetValue(self.SUBS_LANG[self.opt_manager.options['subs_lang']])
self.write_subs_checkbox.SetValue(self.opt_manager.options['write_subs'])
self.embed_subs_checkbox.SetValue(self.opt_manager.options['embed_subs'])
self.write_all_subs_checkbox.SetValue(self.opt_manager.options['write_all_subs'])
@ -1231,7 +1221,7 @@ class SubtitlesTab(TabPanel):
self._on_subs_pick(None)
def save_options(self):
self.opt_manager.options['subs_lang'] = self.subs_lang_combo.GetValue()
self.opt_manager.options['subs_lang'] = self.SUBS_LANG[self.subs_lang_combo.GetValue()]
self.opt_manager.options['write_subs'] = self.write_subs_checkbox.GetValue()
self.opt_manager.options['embed_subs'] = self.embed_subs_checkbox.GetValue()
self.opt_manager.options['write_all_subs'] = self.write_all_subs_checkbox.GetValue()

70
youtube_dl_gui/optionsmanager.py

@ -55,14 +55,12 @@ class OptionsManager(object):
save_path (string): Path where youtube-dl should store the
downloaded file. Default is $HOME.
video_format (string): Video format to download. For available
video formats see 'parsers' module (VIDEO_FORMATS attribute).
When this options is set to 'default' youtube-dl will choose
video_format (string): Video format to download.
When this options is set to '0' youtube-dl will choose
the best video format available for the given URL.
second_video_format (string): Video format to mix with the first
one. (-f 18+17). For available video formats see 'video_format'
option.
one (-f 18+17).
to_audio (boolean): If True youtube-dl will post process the
video file.
@ -74,7 +72,8 @@ class OptionsManager(object):
Available values are "mp3", "wav", "aac", "m4a", "vorbis".
audio_quality (string): Audio quality of the post processed file.
Available values are "low", "mid", "high".
Available values are "9", "5", "0". The lowest the value the
better the quality.
restrict_filenames (boolean): If True youtube-dl will restrict
the downloaded file filename to ASCII characters only.
@ -84,8 +83,7 @@ class OptionsManager(object):
'id' -> '%(id)s.%(ext)s'
'title' -> '%(title)s.%(ext)s'
'custom' -> Loads the template from the 'output_template'
option.
'custom' -> Use 'output_template' as output template.
output_template (string): Can be any output template supported
by youtube-dl.
@ -106,28 +104,25 @@ class OptionsManager(object):
youtube-dl will abort the download process.
min_filesize_unit (string): Minimum file size unit.
Available values: 'Bytes', 'Kilobytes', 'Megabytes',
'Gigabytes', 'Terabytes', 'Petabytes', 'Exabytes',
'Zettabytes', 'Yottabytes'.
Available values: '', 'k', 'm', 'g', 'y', 'p', 'e', 'z', 'y'.
max_filesize_unit (string): Maximum file size unit.
See 'min_filesize_unit' option for available values.
write_subs (boolean): If True youtube-dl will try downloading
write_subs (boolean): If True youtube-dl will try to download
the subtitles file for the given URL.
write_all_subs (boolean): If True youtube-dl will try downloading
write_all_subs (boolean): If True youtube-dl will try to download
all the available subtitles files for the given URL.
write_auto_subs (boolean): If True youtube-dl will try downloading
write_auto_subs (boolean): If True youtube-dl will try to download
the automatic subtitles file for the given URL.
embed_subs (boolean): If True youtube-dl will merge the subtitles
file with the video. (ONLY mp4 files).
subs_lang (string): Language of the subtitles file to download.
Needs 'write_subs' option. For available subtitles see
'parsers' module. (SUBS_LANG attribute).
Needs 'write_subs' option.
ignore_errors (boolean): If True youtube-dl will ignore the errors
and continue the download process.
@ -184,12 +179,12 @@ class OptionsManager(object):
"""
self.options = {
'save_path': os.path.expanduser('~'),
'video_format': 'default',
'second_video_format': 'none',
'video_format': '0',
'second_video_format': '0',
'to_audio': False,
'keep_video': False,
'audio_format': 'mp3',
'audio_quality': 'mid',
'audio_quality': '5',
'restrict_filenames': False,
'output_format': 'title',
'output_template': '%(uploader)s/%(title)s.%(ext)s',
@ -198,13 +193,13 @@ class OptionsManager(object):
'max_downloads': 0,
'min_filesize': 0,
'max_filesize': 0,
'min_filesize_unit': 'Bytes',
'max_filesize_unit': 'Bytes',
'min_filesize_unit': '',
'max_filesize_unit': '',
'write_subs': False,
'write_all_subs': False,
'write_auto_subs': False,
'embed_subs': False,
'subs_lang': 'English',
'subs_lang': 'en',
'ignore_errors': True,
'open_dl_dir': True,
'write_description': False,
@ -280,22 +275,21 @@ class OptionsManager(object):
if key not in settings_dictionary:
return False
## Check if each key has a valid value
#rules_dict = {
#'video_format': VALID_VIDEO_FORMAT,
#'second_video_format': VALID_VIDEO_FORMAT,
#'audio_format': VALID_AUDIO_FORMAT,
#'audio_quality': VALID_AUDIO_QUALITY,
#'output_format': VALID_OUTPUT_FORMAT,
#'min_filesize_unit': VALID_FILESIZE_UNIT,
#'max_filesize_unit': VALID_FILESIZE_UNIT,
#'subs_lang': VALID_SUB_LANGUAGE
#}
#for key, valid_list in rules_dict.items():
#if settings_dictionary[key] not in valid_list:
#print key, valid_list
#return False
# Check if each key has a valid value
rules_dict = {
'video_format': VALID_VIDEO_FORMAT,
'second_video_format': VALID_VIDEO_FORMAT,
'audio_format': VALID_AUDIO_FORMAT,
'audio_quality': VALID_AUDIO_QUALITY,
'output_format': VALID_OUTPUT_FORMAT,
'min_filesize_unit': VALID_FILESIZE_UNIT,
'max_filesize_unit': VALID_FILESIZE_UNIT,
'subs_lang': VALID_SUB_LANGUAGE
}
for key, valid_list in rules_dict.items():
if settings_dictionary[key] not in valid_list:
return False
return True

130
youtube_dl_gui/parsers.py

@ -1,94 +1,11 @@
#!/usr/bin/env python2
"""Youtubedlg module to parse the options.
Note:
OUT_OF_DATE
If you want to add new values on the module attributes
e.g. (SUBS_LANG, VIDEO_FORMATS, etc..) you also need to add the
values on the optionsframe module in order for them to be
visible from the GUI.
"""
"""Youtubedlg module responsible for parsing the options. """
import os.path
from .utils import remove_shortcuts
SUBS_LANG = {
"English": "en",
"Greek": "gr",
"Portuguese": "pt",
"French": "fr",
"Italian": "it",
"Russian": "ru",
"Spanish": "es",
"German": "de"
}
VIDEO_FORMATS = {
"default": "0",
"none": "0",
"3gp [176x144]": "17",
"3gp [320x240]": "36",
"flv [400x240]": "5",
"flv [640x360]": "34",
"flv [854x480]": "35",
"webm [640x360]": "43",
"webm [854x480]": "44",
"webm [1280x720]": "45",
"webm [1920x1080]": "46",
"mp4 [640x360]": "18",
"mp4 [1280x720]": "22",
"mp4 [1920x1080]": "37",
"mp4 [4096x3072]": "38",
"mp4 144p (DASH)": "160",
"mp4 240p (DASH)": "133",
"mp4 360p (DASH)": "134",
"mp4 480p (DASH)": "135",
"mp4 720p (DASH)": "136",
"mp4 1080p (DASH)": "137",
"mp4 1440p (DASH)": "264",
"mp4 2160p (DASH)": "138",
"webm 240p (DASH)": "242",
"webm 360p (DASH)": "243",
"webm 480p (DASH)": "244",
"webm 720p (DASH)": "247",
"webm 1080p (DASH)": "248",
"webm 1440p (DASH)": "271",
"webm 2160p (DASH)": "272",
"mp4 360p (3D)": "82",
"mp4 480p (3D)": "83",
"mp4 720p (3D)": "84",
"mp4 1080p (3D)": "85",
"webm 360p (3D)": "100",
"webm 480p (3D)": "101",
"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 = {
"high": "0",
"mid": "5",
"low": "9"
}
FILESIZE_UNITS = {
'Bytes': '',
'Kilobytes': 'k',
'Megabytes': 'm',
'Gigabytes': 'g',
'Terabytes': 't',
'Petabytes': 'p',
'Exabytes': 'e',
'Zettabytes': 'z',
'Yottabytes': 'y'
}
class OptionHolder(object):
@ -175,7 +92,7 @@ class OptionsParser(object):
OptionHolder('embed_subs', '--embed-subs', False, ['write_auto_subs', 'write_subs']),
OptionHolder('to_audio', '-x', False),
OptionHolder('audio_format', '--audio-format', '', ['to_audio']),
OptionHolder('video_format', '-f', ''),
OptionHolder('video_format', '-f', '0'),
OptionHolder('subs_lang', '--sub-lang', '', ['write_subs']),
OptionHolder('audio_quality', '--audio-quality', '5', ['to_audio'])
]
@ -200,9 +117,7 @@ class OptionsParser(object):
options_dict = options_dictionary.copy()
self._build_savepath(options_dict)
self._build_subslang(options_dict)
self._build_videoformat(options_dict)
self._build_audioquality(options_dict)
self._build_filesizes(options_dict)
# Parse basic youtube-dl command line options
@ -253,39 +168,8 @@ class OptionsParser(object):
options_dict (dictionary): Copy of the original options dictionary.
"""
first_vf = VIDEO_FORMATS[options_dict['video_format']]
second_vf = VIDEO_FORMATS[options_dict['second_video_format']]
if first_vf != '0' and second_vf != '0':
options_dict['video_format'] = first_vf + '+' + second_vf
elif first_vf != '0' and second_vf == '0':
options_dict['video_format'] = first_vf
else:
options_dict['video_format'] = ''
def _build_subslang(self, options_dict):
"""Build the subtitles language option value.
We use this method to build the value of the 'subs_lang' option and
store it back to the options dictionary.
Args:
options_dict (dictionary): Copy of the original options dictionary.
"""
options_dict['subs_lang'] = SUBS_LANG[options_dict['subs_lang']]
def _build_audioquality(self, options_dict):
"""Build the audio quality option value.
We use this method to build the value of the 'audio_quality' option and
store it back to the options dictionary.
Args:
options_dict (dictionary): Copy of the original options dictionary.
"""
options_dict['audio_quality'] = AUDIO_QUALITY[options_dict['audio_quality']]
if options_dict['video_format'] != '0' and options_dict['second_video_format'] != '0':
options_dict['video_format'] = options_dict['video_format'] + '+' + options_dict['second_video_format']
def _build_filesizes(self, options_dict):
"""Build the filesize options values.
@ -298,9 +182,7 @@ class OptionsParser(object):
"""
if options_dict['min_filesize']:
size_unit = FILESIZE_UNITS[options_dict['min_filesize_unit']]
options_dict['min_filesize'] = str(options_dict['min_filesize']) + size_unit
options_dict['min_filesize'] = str(options_dict['min_filesize']) + options_dict['min_filesize_unit']
if options_dict['max_filesize']:
size_unit = FILESIZE_UNITS[options_dict['max_filesize_unit']]
options_dict['max_filesize'] = str(options_dict['max_filesize']) + size_unit
options_dict['max_filesize'] = str(options_dict['max_filesize']) + options_dict['max_filesize_unit']
Loading…
Cancel
Save