From 717216b0930c742dab5bbd065e9c58caace74a8c Mon Sep 17 00:00:00 2001 From: pukkandan Date: Tue, 30 Nov 2021 00:48:51 +0530 Subject: [PATCH] Validate --get-bypass-country Closes #1834 --- yt_dlp/__init__.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 92d1fa16c..9ddfc67c1 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -29,6 +29,7 @@ from .utils import ( DownloadError, error_to_compat_str, expand_path, + GeoUtils, float_or_none, int_or_none, match_filter_func, @@ -255,12 +256,17 @@ def _real_main(argv=None): if opts.convertthumbnails is not None: if opts.convertthumbnails not in FFmpegThumbnailsConvertorPP.SUPPORTED_EXTS: parser.error('invalid thumbnail format specified') - if opts.cookiesfrombrowser is not None: opts.cookiesfrombrowser = [ part.strip() or None for part in opts.cookiesfrombrowser.split(':', 1)] if opts.cookiesfrombrowser[0].lower() not in SUPPORTED_BROWSERS: parser.error('unsupported browser specified for cookies') + geo_bypass_code = opts.geo_bypass_ip_block or opts.geo_bypass_country + if geo_bypass_code is not None: + try: + GeoUtils.random_ipv4(geo_bypass_code) + except Exception: + parser.error('unsupported geo-bypass country or ip-block') if opts.date is not None: date = DateRange.day(opts.date)