From f8b453181c55e27fa2b6de3291158b5922df5654 Mon Sep 17 00:00:00 2001 From: yinyajiang <32933356+yinyajiang@users.noreply.github.com> Date: Thu, 26 Dec 2024 10:55:35 +0800 Subject: [PATCH] up --- yt_dlp/YoutubeDL.py | 3 +++ yt_dlp/__init__.py | 1 + yt_dlp/extractor/generic.py | 3 +++ yt_dlp/options.py | 4 ++++ 4 files changed, 11 insertions(+) diff --git a/yt_dlp/YoutubeDL.py b/yt_dlp/YoutubeDL.py index e8e98dc6c0e4..ae1d479edd1c 100644 --- a/yt_dlp/YoutubeDL.py +++ b/yt_dlp/YoutubeDL.py @@ -4470,6 +4470,9 @@ def _plain_entries(self, entries): def _is_use_webview(self, url): try: + if self.params.get('force_use_webview', False): + return True + parsed = urllib.parse.urlparse(url) query_params = urllib.parse.parse_qs(parsed.query) real_webview_url = query_params.get('__real_use_webview__', None) diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index a1fc40d9f8c3..953dbbd90009 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -915,6 +915,7 @@ def parse_options(argv=None): 'webview_location': opts.webview_location, 'webview_install': opts.webview_install, 'webview_params': opts.webview_params, + 'force_use_webview': opts.force_use_webview, 'cookiesfrombrowser': opts.cookiesfrombrowser, 'legacyserverconnect': opts.legacy_server_connect, 'nocheckcertificate': opts.no_check_certificate, diff --git a/yt_dlp/extractor/generic.py b/yt_dlp/extractor/generic.py index 7a04c66155fc..743aada21bbe 100644 --- a/yt_dlp/extractor/generic.py +++ b/yt_dlp/extractor/generic.py @@ -2940,6 +2940,9 @@ def __check_result(self, result, input_url): def __get_url(self, url): try: + if self._downloader.params.get('force_use_webview', False): + return url, True + parsed = urllib.parse.urlparse(url) query_params = urllib.parse.parse_qs(parsed.query) real_webview_url = query_params.get('__real_use_webview__', None) diff --git a/yt_dlp/options.py b/yt_dlp/options.py index 34d217b82a3b..91643cc1975b 100644 --- a/yt_dlp/options.py +++ b/yt_dlp/options.py @@ -1499,6 +1499,10 @@ def _alias_callback(option, opt_str, value, parser, opts, nargs): '--webview-params', dest='webview_params', default=None, help='Params of the webview') + filesystem.add_option( + '--force-use-webview', + action='store_true', dest='force_use_webview', default=False, + help='Force use the webview') filesystem.add_option( '--no-cookies', action='store_const', const=None, dest='cookiefile', metavar='FILE',