aboutsummaryrefslogtreecommitdiff
path: root/youtube_dl/__init__.py
diff options
context:
space:
mode:
authorJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-08-23 18:34:57 +0200
committerJaime Marquínez Ferrándiz <jaime.marquinez.ferrandiz@gmail.com>2013-08-23 18:34:57 +0200
commitaa6a10c44a8e2e86f709c5301f9ea6ac3f01f002 (patch)
tree14848da1dc4711b236d6cbc8c163f910027dc990 /youtube_dl/__init__.py
parent9af73dc4fc7dc54def861f94f9db4399b8bf928e (diff)
Allow to specify multiple subtitles languages separated by commas (closes #518)
Diffstat (limited to 'youtube_dl/__init__.py')
-rw-r--r--youtube_dl/__init__.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py
index 441ca6b6a..614429073 100644
--- a/youtube_dl/__init__.py
+++ b/youtube_dl/__init__.py
@@ -83,6 +83,9 @@ def parseOpts(overrideArguments=None):
return "".join(opts)
+ def _comma_separated_values_options_callback(option, opt_str, value, parser):
+ setattr(parser.values, option.dest, value.split(','))
+
def _find_term_columns():
columns = os.environ.get('COLUMNS', None)
if columns:
@@ -206,9 +209,10 @@ def parseOpts(overrideArguments=None):
subtitles.add_option('--sub-format',
action='store', dest='subtitlesformat', metavar='FORMAT',
help='subtitle format (default=srt) ([sbv/vtt] youtube only)', default='srt')
- subtitles.add_option('--sub-lang', '--srt-lang',
- action='store', dest='subtitleslang', metavar='LANG',
- help='language of the subtitles to download (optional) use IETF language tags like \'en\'')
+ subtitles.add_option('--sub-lang', '--sub-langs', '--srt-lang',
+ action='callback', dest='subtitleslang', metavar='LANGS', type='str',
+ default=[], callback=_comma_separated_values_options_callback,
+ help='languages of the subtitles to download (optional) separated by commas, use IETF language tags like \'en,pt\'')
downloader.add_option('-r', '--rate-limit',
dest='ratelimit', metavar='LIMIT', help='maximum download rate (e.g. 50k or 44.6m)')
@@ -573,7 +577,7 @@ def _real_main(argv=None):
'allsubtitles': opts.allsubtitles,
'listsubtitles': opts.listsubtitles,
'subtitlesformat': opts.subtitlesformat,
- 'subtitleslang': opts.subtitleslang,
+ 'subtitleslangs': opts.subtitleslang,
'matchtitle': decodeOption(opts.matchtitle),
'rejecttitle': decodeOption(opts.rejecttitle),
'max_downloads': opts.max_downloads,