X-Git-Url: https://jfr.im/git/yt-dlp.git/blobdiff_plain/6d1b34896e69c4e53d8f960bf4b3867bca1c129c..ac668111128b5f124b4271b3aa4c35f6e71a4749:/yt_dlp/__init__.py diff --git a/yt_dlp/__init__.py b/yt_dlp/__init__.py index 1cd14a44d..a5921c565 100644 --- a/yt_dlp/__init__.py +++ b/yt_dlp/__init__.py @@ -3,13 +3,14 @@ __license__ = 'Public Domain' +import getpass import itertools import optparse import os import re import sys -from .compat import compat_getpass, compat_shlex_quote +from .compat import compat_shlex_quote from .cookies import SUPPORTED_BROWSERS, SUPPORTED_KEYRINGS from .downloader import FileDownloader from .downloader.external import get_external_downloader @@ -26,7 +27,7 @@ MetadataFromFieldPP, MetadataParserPP, ) -from .update import run_update +from .update import Updater from .utils import ( NO_DEFAULT, POSTPROCESS_WHEN, @@ -403,6 +404,8 @@ def metadataparser_actions(f): default_downloader = None for proto, path in opts.external_downloader.items(): + if path == 'native': + continue ed = get_external_downloader(path) if ed is None: raise ValueError( @@ -529,9 +532,9 @@ def report_deprecation(val, old, new=None): # Ask for passwords if opts.username is not None and opts.password is None: - opts.password = compat_getpass('Type account password and press [Return]: ') + opts.password = getpass.getpass('Type account password and press [Return]: ') if opts.ap_username is not None and opts.ap_password is None: - opts.ap_password = compat_getpass('Type TV provider account password and press [Return]: ') + opts.ap_password = getpass.getpass('Type TV provider account password and press [Return]: ') return warnings, deprecation_warnings @@ -879,17 +882,23 @@ def _real_main(argv=None): return with YoutubeDL(ydl_opts) as ydl: + pre_process = opts.update_self or opts.rm_cachedir actual_use = all_urls or opts.load_info_filename if opts.rm_cachedir: ydl.cache.remove() - if opts.update_self and run_update(ydl) and actual_use: - # If updater returns True, exit. Required for windows - return 100, 'ERROR: The program must exit for the update to complete' + updater = Updater(ydl) + if opts.update_self and updater.update() and actual_use: + if updater.cmd: + return updater.restart() + # This code is reachable only for zip variant in py < 3.10 + # It makes sense to exit here, but the old behavior is to continue + ydl.report_warning('Restart yt-dlp to use the updated version') + # return 100, 'ERROR: The program must exit for the update to complete' if not actual_use: - if opts.update_self or opts.rm_cachedir: + if pre_process: return ydl._download_retcode ydl.warn_if_short_id(sys.argv[1:] if argv is None else argv)