From 6ad14cab599b05a658756fef47d3837281429da7 Mon Sep 17 00:00:00 2001 From: Philipp Hagemeister Date: Mon, 2 Dec 2013 13:37:05 +0100 Subject: [PATCH] Add --socket-timeout option --- youtube_dl/YoutubeDL.py | 4 +++- youtube_dl/__init__.py | 4 ++++ 2 files changed, 7 insertions(+), 1 deletion(-) diff --git a/youtube_dl/YoutubeDL.py b/youtube_dl/YoutubeDL.py index b7393fd79..b68b110a4 100644 --- a/youtube_dl/YoutubeDL.py +++ b/youtube_dl/YoutubeDL.py @@ -971,7 +971,9 @@ class YoutubeDL(object): write_string(u'[debug] Proxy map: ' + compat_str(proxy_map) + u'\n') def _setup_opener(self): - timeout = float(self.params.get('socket_timeout', 600)) + timeout_val = self.params.get('socket_timeout') + timeout = 600 if timeout_val is None else float(timeout_val) + opts_cookiefile = self.params.get('cookiefile') opts_proxy = self.params.get('proxy') diff --git a/youtube_dl/__init__.py b/youtube_dl/__init__.py index 92e583744..799eca566 100644 --- a/youtube_dl/__init__.py +++ b/youtube_dl/__init__.py @@ -198,6 +198,9 @@ def parseOpts(overrideArguments=None): general.add_option( '--no-cache-dir', action='store_const', const=None, dest='cachedir', help='Disable filesystem caching') + general.add_option( + '--socket-timeout', dest='socket_timeout', + type=float, default=None, help=optparse.SUPPRESS_HELP) selection.add_option('--playlist-start', @@ -652,6 +655,7 @@ def _real_main(argv=None): 'cookiefile': opts.cookiefile, 'nocheckcertificate': opts.no_check_certificate, 'proxy': opts.proxy, + 'socket_timeout': opts.socket_timeout, } with YoutubeDL(ydl_opts) as ydl: -- 2.22.2