
    V|h@                    8   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKr	S SK
r
S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrSSKJr  SSKJr  SSKJr  SSK J!r!J"r"J#r#  SSK$J%r%J&r&J'r'  SSK(J)r)  SS	K*J+r+J,r,J-r-  SS
K.J/r/  SSK0J1r1  SSK2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:  SSK;J<r<  SSK=J>r>J?r?J@r@  SSKAJBrBJCrC  SSKDJErEJFrFJGrGJHrHJIrI  SSKJJKrKJLrL  SSKMJNrOJPrP  SSKQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]  SSK^J_r`  SSKaJbrbJcrcJdrdJereJfrfJgrg  SSKhJiriJjrjJkrkJlrlJmrmJnrnJoroJprpJqrqJrrrJsrsJtrtJuruJvrvJwrwJxrxJyryJzrzJ{r{J|r|J}r}J~r~JrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJrJr  SSKJrJrJr  SSKJrJrJrJr  SSKJrJrJrJrJr  \GR                  S:X  a  S SKrS r " S S5      rg)    N   )Cache)urllib)urllib_req_to_req)CookieLoadErrorLenientSimpleCookieload_cookies)FFmpegFDget_suitable_downloadershorten_protocol_name)rtmpdump_version)gen_extractor_classesget_info_extractorimport_extractors)UnsupportedURLIE)PhantomJSwrapper)IN_CLILAZY_EXTRACTORSWINDOWS_VT_MODE
plugin_iesplugin_ies_overrides
plugin_ppsall_plugins_loadedplugin_dirs)format_text)HEADRequestRequestRequestDirector)_REQUEST_HANDLERS_RH_PREFERENCES)	HTTPErrorNoSupportingHandlersRequestErrorSSLErrornetwork_exceptions)ImpersonateRequestHandlerImpersonateTarget)directoriesload_all_plugins)EmbedThumbnailPPFFmpegFixupDuplicateMoovPPFFmpegFixupDurationPPFFmpegFixupM3u8PPFFmpegFixupM4aPPFFmpegFixupStretchedPPFFmpegFixupTimestampPPFFmpegMergerPPFFmpegPostProcessorFFmpegVideoConvertorPPMoveFilesAfterDownloadPPget_postprocessor)resolve_mapping)
REPOSITORY_get_system_deprecation_get_outdated_warning_make_labelcurrent_git_headdetect_variant)WDEFAULT_OUTTMPLIDENTITYLINK_TEMPLATESMEDIA_EXTENSIONS
NO_DEFAULT	NUMBER_REOUTTMPL_TYPESPOSTPROCESS_WHENSTR_FORMAT_RE_TMPLSTR_FORMAT_TYPESContentTooShortError	DateRangeDownloadCancelledDownloadErrorEntryNotInPlaylistExistingVideoReachedExtractorErrorFormatSorterGeoRestrictedErrorISO3166UtilsLazyListMaxDownloadsReached	Namespace	PagedListPlaylistEntriesPopenPostProcessingErrorReExtractInfoRejectedVideoReachedSameFileErrorUnavailableVideoErrorUserNotLiveYoutubeDLErrorage_restrictedbug_reports_messagedate_from_strdeprecation_warningdetermine_extdetermine_protocolencode_compat_str
escapeHTMLexpand_pathextract_basic_authfilter_dictfloat_or_noneformat_bytesformat_decimal_suffixformat_fieldformatSecondsget_compatible_ext
get_domainint_or_none
iri_to_uriis_path_likejoin_nonemptylocked_filemake_archive_idmake_dirnumber_of_digits
orderedSetorderedSet_from_optionsparse_filesizepreferredencodingprepend_extensionremove_terminal_sequencesrender_tablereplace_extensionsanitize_filenamesanitize_pathsanitize_urlshell_quotestr_or_nonestrftime_or_nonesubtitles_filenamesupports_terminal_sequencessystem_identifierfilesize_from_tbrtimetuple_from_msecto_high_limit_pathtraverse_objtry_calltry_geturl_basenamevariadicwindows_enable_vt_modewrite_json_filewrite_string)_UnsafeExtensionError
_YDLLogger_ProgressState)HTTPHeaderDictclean_headersclean_proxiesstd_headers)CHANNELORIGINRELEASE_GIT_HEADVARIANT__version__ntc                 F   ^  [         R                  " T 5      U 4S j5       nU$ )Nc           	         >  T" U /UQ70 UD6$ ! [          a5  nU R                  SUR                  < S[        S5       35         S nAg S nAff = f)NzThe extracted extension (zT) is unusual and will be skipped for safety reasons. If you believe this is an error,)r   report_error	extensionr_   )selfargskwargserrorfuncs       J/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/YoutubeDL.pywrapper._catch_unsafe_extension_error.<locals>.wrapper   sg    	N.t.v..$ 	N+EOO+> ?22Ec2J1KMN N	Ns    
A+A		A	functoolswrapsr   r   s   ` r   _catch_unsafe_extension_errorr      s'    __TN N N    c                   z   \ rS rSrSr1 Skr1 SkrSSSSS	S
.r\" \	R                  5      1 \	R                  kSi\" \	R                  5      S.rSS jrS rS rS rS rSS jrS rS rS rS rS rSS jrSS jrSS jrSS jrS rSS  jrS! rS" r S# r!S$ r"S% r#S& r$SS' jr%\&" S(S)S*S*S+S,S-S(S.S/9	r'SSS0.S1 jjr(S2 r)S3 r*S4 r+SS5 jr,S6S7.S8 jr-S9 r.S: r/SS; jr0S< r1S= r2SSS>.S? jjr3S@ r4SA r5SSB jr6\7SC 5       r8\7SD 5       r9\:SE 5       r;\7SF 5       r<SSG jr=SH r>\?SSSI.SJ j5       r@SSSSK.SL jjrASSM jrB\7SN 5       rC  SSO jrDSP rE0 4SQ jrFSSR.SS jrGSST jrH\ESU 5       rISV rJSSW jrKSX rL\7SSY j5       rMSZ rN\ES[ 5       rOS\ rPSS] jrQS^ rRS_ rSS` rTSSa jrUSb rVSc rWSd rXSSe jrYSf rZSg r[SSh jr\Si r]Sj r^SSk jr_SSl jr`SSm.Sn jra\?So 5       rbSp rcSq rdSr re\7SSs j5       rf\7SSt j5       rg0 SSu.Sv jrh\7Sw 5       riSx rjSSy.Sz jrkSS{ jrlSS| jrmS} rnS~ roS rp\7SS j5       rqS rrS rsS rtS ruS rvS rwS rxS ryS rzSS jr{S r|\}R                  S 5       r\}R                  S 5       r\S 5       rS rS rS r\7SS j5       rS rSS jr\}R                  S 5       rS rS rSS jrS rS rSS jrSrg)	YoutubeDL   a}]  YoutubeDL class.

YoutubeDL objects are the ones responsible of downloading the
actual video file and writing it to disk if the user has requested
it, among some other tasks. In most cases there should be one per
program. As, given a video URL, the downloader doesn't know how to
extract all the needed information, task that InfoExtractors do, it
has to pass the URL to one of them.

For this, YoutubeDL objects have a method that allows
InfoExtractors to be registered in a given order. When it is passed
a URL, the YoutubeDL object handles it to the first InfoExtractor it
finds that reports being able to handle it. The InfoExtractor extracts
all the information about the video or videos the URL refers to, and
YoutubeDL process the extracted information, possibly using a File
Downloader to download the video.

YoutubeDL objects accept a lot of parameters. In order not to saturate
the object constructor with arguments, it receives a dictionary of
options instead. These options are available through the params
attribute for the InfoExtractors to use. The YoutubeDL also
registers itself as the downloader in charge for the InfoExtractors
that are added to it, so this is a "mutual registration".

Available options:

username:          Username for authentication purposes.
password:          Password for authentication purposes.
videopassword:     Password for accessing a video.
ap_mso:            Adobe Pass multiple-system operator identifier.
ap_username:       Multiple-system operator account username.
ap_password:       Multiple-system operator account password.
usenetrc:          Use netrc for authentication instead.
netrc_location:    Location of the netrc file. Defaults to ~/.netrc.
netrc_cmd:         Use a shell command to get credentials
verbose:           Print additional info to stdout.
quiet:             Do not print messages to stdout.
no_warnings:       Do not print out anything for warnings.
forceprint:        A dict with keys WHEN mapped to a list of templates to
                   print to stdout. The allowed keys are video or any of the
                   items in utils.POSTPROCESS_WHEN.
                   For compatibility, a single list is also accepted
print_to_file:     A dict with keys WHEN (same as forceprint) mapped to
                   a list of tuples with (template, filename)
forcejson:         Force printing info_dict as JSON.
dump_single_json:  Force printing the info_dict of the whole playlist
                   (or video) as a single JSON line.
force_write_download_archive: Force writing download archive regardless
                   of 'skip_download' or 'simulate'.
simulate:          Do not download the video files. If unset (or None),
                   simulate only if listsubtitles, listformats or list_thumbnails is used
format:            Video format code. see "FORMAT SELECTION" for more details.
                   You can also pass a function. The function takes 'ctx' as
                   argument and returns the formats to download.
                   See "build_format_selector" for an implementation
allow_unplayable_formats:   Allow unplayable formats to be extracted and downloaded.
ignore_no_formats_error: Ignore "No video formats" error. Usefull for
                   extracting metadata even if the video is not actually
                   available for download (experimental)
format_sort:       A list of fields by which to sort the video formats.
                   See "Sorting Formats" for more details.
format_sort_force: Force the given format_sort. see "Sorting Formats"
                   for more details.
prefer_free_formats: Whether to prefer video formats with free containers
                   over non-free ones of the same quality.
allow_multiple_video_streams:   Allow multiple video streams to be merged
                   into a single file
allow_multiple_audio_streams:   Allow multiple audio streams to be merged
                   into a single file
check_formats      Whether to test if the formats are downloadable.
                   Can be True (check all), False (check none),
                   'selected' (check selected formats),
                   or None (check only if requested by extractor)
paths:             Dictionary of output paths. The allowed keys are 'home'
                   'temp' and the keys of OUTTMPL_TYPES (in utils/_utils.py)
outtmpl:           Dictionary of templates for output names. Allowed keys
                   are 'default' and the keys of OUTTMPL_TYPES (in utils/_utils.py).
                   For compatibility with youtube-dl, a single string can also be used
outtmpl_na_placeholder: Placeholder for unavailable meta fields.
restrictfilenames: Do not allow "&" and spaces in file names
trim_file_name:    Limit length of filename (extension excluded)
windowsfilenames:  True: Force filenames to be Windows compatible
                   False: Sanitize filenames only minimally
                   This option has no effect when running on Windows
ignoreerrors:      Do not stop on download/postprocessing errors.
                   Can be 'only_download' to ignore only download errors.
                   Default is 'only_download' for CLI, but False for API
skip_playlist_after_errors: Number of allowed failures until the rest of
                   the playlist is skipped
allowed_extractors:  List of regexes to match against extractor names that are allowed
overwrites:        Overwrite all video and metadata files if True,
                   overwrite only non-video files if None
                   and don't overwrite any file if False
playlist_items:    Specific indices of playlist to download.
playlistrandom:    Download playlist items in random order.
lazy_playlist:     Process playlist entries as they are received.
matchtitle:        Download only matching titles.
rejecttitle:       Reject downloads for matching titles.
logger:            A class having a `debug`, `warning` and `error` function where
                   each has a single string parameter, the message to be logged.
                   For compatibility reasons, both debug and info messages are passed to `debug`.
                   A debug message will have a prefix of `[debug] ` to discern it from info messages.
logtostderr:       Print everything to stderr instead of stdout.
consoletitle:      Display progress in the console window's titlebar.
writedescription:  Write the video description to a .description file
writeinfojson:     Write the video description to a .info.json file
clean_infojson:    Remove internal metadata from the infojson
getcomments:       Extract video comments. This will not be written to disk
                   unless writeinfojson is also given
writethumbnail:    Write the thumbnail image to a file
allow_playlist_files: Whether to write playlists' description, infojson etc
                   also to disk when using the 'write*' options
write_all_thumbnails:  Write all thumbnail formats to files
writelink:         Write an internet shortcut file, depending on the
                   current platform (.url/.webloc/.desktop)
writeurllink:      Write a Windows internet shortcut file (.url)
writewebloclink:   Write a macOS internet shortcut file (.webloc)
writedesktoplink:  Write a Linux internet shortcut file (.desktop)
writesubtitles:    Write the video subtitles to a file
writeautomaticsub: Write the automatically generated subtitles to a file
listsubtitles:     Lists all available subtitles for the video
subtitlesformat:   The format code for subtitles
subtitleslangs:    List of languages of the subtitles to download (can be regex).
                   The list may contain "all" to refer to all the available
                   subtitles. The language can be prefixed with a "-" to
                   exclude it from the requested languages, e.g. ['all', '-live_chat']
keepvideo:         Keep the video file after post-processing
daterange:         A utils.DateRange object, download only if the upload_date is in the range.
skip_download:     Skip the actual download of the video file
cachedir:          Location of the cache files in the filesystem.
                   False to disable filesystem cache.
noplaylist:        Download single video instead of a playlist if in doubt.
age_limit:         An integer representing the user's age in years.
                   Unsuitable videos for the given age are skipped.
min_views:         An integer representing the minimum view count the video
                   must have in order to not be skipped.
                   Videos without view count information are always
                   downloaded. None for no limit.
max_views:         An integer representing the maximum view count.
                   Videos that are more popular than that are not
                   downloaded.
                   Videos without view count information are always
                   downloaded. None for no limit.
download_archive:  A set, or the name of a file where all downloads are recorded.
                   Videos already present in the file are not downloaded again.
break_on_existing: Stop the download process after attempting to download a
                   file that is in the archive.
break_per_url:     Whether break_on_reject and break_on_existing
                   should act on each input URL as opposed to for the entire queue
cookiefile:        File name or text stream from where cookies should be read and dumped to
cookiesfrombrowser:  A tuple containing the name of the browser, the profile
                   name/path from where cookies are loaded, the name of the keyring,
                   and the container name, e.g. ('chrome', ) or
                   ('vivaldi', 'default', 'BASICTEXT') or ('firefox', 'default', None, 'Meta')
legacyserverconnect: Explicitly allow HTTPS connection to servers that do not
                   support RFC 5746 secure renegotiation
nocheckcertificate:  Do not verify SSL certificates
client_certificate:  Path to client certificate file in PEM format. May include the private key
client_certificate_key:  Path to private key file for client certificate
client_certificate_password:  Password for client certificate private key, if encrypted.
                    If not provided and the key is encrypted, yt-dlp will ask interactively
prefer_insecure:   Use HTTP instead of HTTPS to retrieve information.
                   (Only supported by some extractors)
enable_file_urls:  Enable file:// URLs. This is disabled by default for security reasons.
http_headers:      A dictionary of custom headers to be used for all requests
proxy:             URL of the proxy server to use
geo_verification_proxy:  URL of the proxy to use for IP address verification
                   on geo-restricted sites.
socket_timeout:    Time to wait for unresponsive hosts, in seconds
bidi_workaround:   Work around buggy terminals without bidirectional text
                   support, using fridibi
debug_printtraffic:Print out sent and received HTTP traffic
default_search:    Prepend this string if an input url is not valid.
                   'auto' for elaborate guessing
encoding:          Use this encoding instead of the system-specified.
extract_flat:      Whether to resolve and process url_results further
                   * False:     Always process. Default for API
                   * True:      Never process
                   * 'in_playlist': Do not process inside playlist/multi_video
                   * 'discard': Always process, but don't return the result
                                from inside playlist/multi_video
                   * 'discard_in_playlist': Same as "discard", but only for
                                playlists (not multi_video). Default for CLI
wait_for_video:    If given, wait for scheduled streams to become available.
                   The value should be a tuple containing the range
                   (min_secs, max_secs) to wait between retries
postprocessors:    A list of dictionaries, each with an entry
                   * key:  The name of the postprocessor. See
                           yt_dlp/postprocessor/__init__.py for a list.
                   * when: When to run the postprocessor. Allowed values are
                           the entries of utils.POSTPROCESS_WHEN
                           Assumed to be 'post_process' if not given
progress_hooks:    A list of functions that get called on download
                   progress, with a dictionary with the entries
                   * status: One of "downloading", "error", or "finished".
                             Check this first and ignore unknown values.
                   * info_dict: The extracted info_dict

                   If status is one of "downloading", or "finished", the
                   following properties may also be present:
                   * filename: The final filename (always present)
                   * tmpfilename: The filename we're currently writing to
                   * downloaded_bytes: Bytes on disk
                   * total_bytes: Size of the whole file, None if unknown
                   * total_bytes_estimate: Guess of the eventual file size,
                                           None if unavailable.
                   * elapsed: The number of seconds since download started.
                   * eta: The estimated time in seconds, None if unknown
                   * speed: The download speed in bytes/second, None if
                            unknown
                   * fragment_index: The counter of the currently
                                     downloaded video fragment.
                   * fragment_count: The number of fragments (= individual
                                     files that will be merged)

                   Progress hooks are guaranteed to be called at least once
                   (with status "finished") if the download is successful.
postprocessor_hooks:  A list of functions that get called on postprocessing
                   progress, with a dictionary with the entries
                   * status: One of "started", "processing", or "finished".
                             Check this first and ignore unknown values.
                   * postprocessor: Name of the postprocessor
                   * info_dict: The extracted info_dict

                   Progress hooks are guaranteed to be called at least twice
                   (with status "started" and "finished") if the processing is successful.
merge_output_format: "/" separated list of extensions to use when merging formats.
final_ext:         Expected final extension; used to detect when the file was
                   already downloaded and converted
fixup:             Automatically correct known faults of the file.
                   One of:
                   - "never": do nothing
                   - "warn": only emit a warning
                   - "detect_or_warn": check whether we can do anything
                                       about it, warn otherwise (default)
source_address:    Client-side IP address to bind to.
impersonate:       Client to impersonate for requests.
                   An ImpersonateTarget (from yt_dlp.networking.impersonate)
sleep_interval_requests: Number of seconds to sleep between requests
                   during extraction
sleep_interval:    Number of seconds to sleep before each download when
                   used alone or a lower bound of a range for randomized
                   sleep before each download (minimum possible number
                   of seconds to sleep) when used along with
                   max_sleep_interval.
max_sleep_interval:Upper bound of a range for randomized sleep before each
                   download (maximum possible number of seconds to sleep).
                   Must only be used along with sleep_interval.
                   Actual sleep time will be a random float from range
                   [sleep_interval; max_sleep_interval].
sleep_interval_subtitles: Number of seconds to sleep before each subtitle download
listformats:       Print an overview of available video formats and exit.
list_thumbnails:   Print a table of all thumbnails and exit.
match_filter:      A function that gets called for every video with the signature
                   (info_dict, *, incomplete: bool) -> Optional[str]
                   For backward compatibility with youtube-dl, the signature
                   (info_dict) -> Optional[str] is also allowed.
                   - If it returns a message, the video is ignored.
                   - If it returns None, the video is downloaded.
                   - If it returns utils.NO_DEFAULT, the user is interactively
                     asked whether to download the video.
                   - Raise utils.DownloadCancelled(msg) to abort remaining
                     downloads when a video is rejected.
                   match_filter_func in utils/_utils.py is one example for this.
color:             A Dictionary with output stream names as keys
                   and their respective color policy as values.
                   Can also just be a single color policy,
                   in which case it applies to all outputs.
                   Valid stream names are 'stdout' and 'stderr'.
                   Valid color policies are one of 'always', 'auto',
                   'no_color', 'never', 'auto-tty' or 'no_color-tty'.
geo_bypass:        Bypass geographic restriction via faking X-Forwarded-For
                   HTTP header
geo_bypass_country:
                   Two-letter ISO 3166-2 country code that will be used for
                   explicit geographic restriction bypassing via faking
                   X-Forwarded-For HTTP header
geo_bypass_ip_block:
                   IP range in CIDR notation that will be used similarly to
                   geo_bypass_country
external_downloader: A dictionary of protocol keys and the executable of the
                   external downloader to use for it. The allowed protocols
                   are default|http|ftp|m3u8|dash|rtsp|rtmp|mms.
                   Set the value to 'native' to use the native downloader
compat_opts:       Compatibility options. See "Differences in default behavior".
                   The following options do not work when used through the API:
                   filename, abort-on-error, multistreams, no-live-chat,
                   format-sort, no-clean-infojson, no-playlist-metafiles,
                   no-keep-subs, no-attach-info-json, allow-unsafe-ext, prefer-vp9-sort,
                   mtime-by-default.
                   Refer __init__.py for their implementation
progress_template: Dictionary of templates for progress outputs.
                   Allowed keys are 'download', 'postprocess',
                   'download-title' (console title) and 'postprocess-title'.
                   The template is mapped on a dictionary with keys 'progress' and 'info'
retry_sleep_functions: Dictionary of functions that takes the number of attempts
                   as argument and returns the time to sleep in seconds.
                   Allowed keys are 'http', 'fragment', 'file_access', 'extractor'
download_ranges:   A callback function that gets called for every video with
                   the signature (info_dict, ydl) -> Iterable[Section].
                   Only the returned sections will be downloaded.
                   Each Section is a dict with the following keys:
                   * start_time: Start time of the section in seconds
                   * end_time: End time of the section in seconds
                   * title: Section title (Optional)
                   * index: Section number (Optional)
force_keyframes_at_cuts: Re-encode the video when downloading ranges to get precise cuts
noprogress:        Do not print the progress bar
live_from_start:   Whether to download livestreams videos from the start
warn_when_outdated: Emit a warning if the yt-dlp version is older than 90 days

The following parameters are not used by YoutubeDL itself, they are used by
the downloader (see yt_dlp/downloader/common.py):
nopart, updatetime, buffersize, ratelimit, throttledratelimit, min_filesize,
max_filesize, test, noresizebuffer, retries, file_access_retries, fragment_retries,
continuedl, hls_use_mpegts, http_chunk_size, external_downloader_args,
concurrent_fragment_downloads, progress_delta.

The following options are used by the post processors:
ffmpeg_location:   Location of the ffmpeg binary; either the path
                   to the binary or its containing directory.
postprocessor_args: A dictionary of postprocessor/executable keys (in lower case)
                   and a list of additional command-line arguments for the
                   postprocessor/executable. The dict can also have "PP+EXE" keys
                   which are used when the given exe is used by the given PP.
                   Use 'default' as the name for arguments to passed to all PP
                   For compatibility with youtube-dl, a single list of args
                   can also be used

The following options are used by the extractors:
extractor_retries: Number of times to retry for known errors (default: 3)
dynamic_mpd:       Whether to process dynamic DASH manifests (default: True)
hls_split_discontinuity: Split HLS playlists into different formats at
                   discontinuities such as ad breaks (default: False)
extractor_args:    A dictionary of arguments to be passed to the extractors.
                   See "EXTRACTOR ARGUMENTS" for details.
                   Argument values must always be a list of string(s).
                   E.g. {'youtube': {'skip': ['dash', 'hls']}}
mark_watched:      Mark videos watched (even with --simulate). Only for YouTube

The following options are deprecated and may be removed in the future:

break_on_reject:   Stop the download process when encountering a video that
                   has been filtered out.
                   - `raise DownloadCancelled(msg)` in match_filter instead
force_generic_extractor: Force downloader to use the generic extractor
                   - Use allowed_extractors = ['generic', 'default']
playliststart:     - Use playlist_items
                   Playlist item to start at.
playlistend:       - Use playlist_items
                   Playlist item to end at.
playlistreverse:   - Use playlist_items
                   Download playlist items in reverse order.
forceurl:          - Use forceprint
                   Force printing final URL.
forcetitle:        - Use forceprint
                   Force printing title.
forceid:           - Use forceprint
                   Force printing ID.
forcethumbnail:    - Use forceprint
                   Force printing thumbnail URL.
forcedescription:  - Use forceprint
                   Force printing description.
forcefilename:     - Use forceprint
                   Force printing final filename.
forceduration:     - Use forceprint
                   Force printing duration.
allsubtitles:      - Use subtitleslangs = ['all']
                   Downloads all the subtitles of the video
                   (requires writesubtitles or writeautomaticsub)
post_hooks:        - Register a custom postprocessor
                   A list of functions that get called as the final step
                   for each video file, after all postprocessors have been
                   called. The filename will be passed as the only argument.
hls_prefer_native: - Use external_downloader = {'m3u8': 'native'} or {'m3u8': 'ffmpeg'}.
                   Use the native HLS downloader instead of ffmpeg
                   if True, otherwise use ffmpeg if False, otherwise
                   use downloader suggested by extractor if None.
no_color:          Same as `color='no_color'`
no_overwrites:     Same as `overwrites=False`
>   abrasrfpstbrvbrwidthheightdurationend_timefilesize	age_limit	timestamp
like_count
start_time
view_countdisc_numberavailable_atrelease_yearrepost_counttrack_numbercomment_countdislike_countseason_numberaudio_channelsaverage_ratingchapter_numberepisode_numberfilesize_approxrelease_timestamp>:   r   appr   extr   r   urlr   rowsr   acodecformatr   tc_urlvcodeccolumnscookieshas_drmhls_aesqualityr   languagepage_urlprotocol	container	format_id	fragments	no_resume	play_path	rtmp_conn	rtmp_live
player_url
preference
resolutionformat_noteimpersonateaspect_ratior   http_headersmanifest_urlrequest_datadynamic_rangeflash_versionis_from_startrtmp_protocolr   rtmp_real_timer   is_dash_periodsstretched_ratiofragment_base_urlsource_preferencedownloader_optionslanguage_preferenceextra_param_to_key_urlmanifest_stream_numberhls_media_playlist_dataextra_param_to_segment_urlalbum_artistsartists	composerscreatorsgenres)album_artistartistcomposercreatorgenre3gp)audiovideostoryboardsNTc                    ^ ^^ Uc  0 nUT l         0 T l        0 T l        [         Vs0 s H  o3/ _M     snT l        [        5       T l        ST l        / T l        / T l	        / T l
        / T l        ST l        ST l        ST l        ST l        [        5       T l        [#        T 5      T l        / T l        [(        R*                  (       d
  [-        5         T R                   R/                  S5      (       a  [0        R2                  O[0        R4                  n[7        U[0        R2                  T R                   R/                  S5      (       a  [0        R2                  OUS9T l         [;        5         [A        [C        [D        [0        R2                  [0        R4                  45      S5      T R8                  l#        T R                   R/                  S5      (       aV  T R                   R/                  S	5      b+  T R                   RI                  S
/ 5      RK                  S5        ST R                   S	'   [L        RN                  " SS5      RQ                  5       S:g  m[S        [L        RN                  " S5      5      mUU U4S jn[7        S&0 T R8                  RT                   VVs0 s H  u  pxUS:w  d  M  Xv" U5      _M     snnD6T l+        [Y        5       n	U	(       a"  T R[                  U	R]                  SS5      5        OBT R                   R/                  S5      (       a"  [_        5       =n
(       a  T Ra                  U
5        T R                   R/                  S5      (       a`  T Ra                  ST Rc                  ST Rd                  Rf                  5       ST Rc                  ST Rd                  Rh                  5       S35        T R                   R/                  SS5      (       a   SSK5nURm                  5       u  p[n        Rp                  " 5       Rr                  nUc  / OS[u        U5      /n[v        Rx                  UT R8                  Rz                  S.n [}        S/UQ40 UD6T l?        [L        R                  " US#5      T lB        [        T R                   R/                  S%S&5      5      T R                   S%'   [        [        T R                   R/                  S'5      5      T R                   S''   T R                  T R                   S'   R/                  S(5      5        T R                   S'   R                  S(S5        U(       a  US):w  a  T R                  5         U 4S* jnU" S+S,S-5        T R                   R/                  S
/ 5       H  nT Ra                  U5        M     T R                   R/                  S./ 5       H  nT R[                  U5        M     T R                   R/                  S/5      =n(       a%  T R                  U5      (       d  [        S0U S135      eS2T R                   S%   ;   a  ST R                   S3'   S4T R                   ;  a>  T R                   R/                  S55      b"  T R                   S5   (       + T R                   S4'   OZT R                   R/                  S45      c  T R                   R                  S4S5        O!T R                   S4   (       + T R                   S5'   T R                   R/                  S65      cm  [        T R                   R/                  S75      T R                   R/                  S85      T R                   R/                  S95      45      (       a  S:T R                   S6'   T R                   RI                  S;0 5        T R                   RI                  S<0 5        [        US;   [        5      (       d  S=US;   0T R                   S;'   U(       a  T R                  5         [0        R                  S>:w  aZ  [0        R                  " 5       S?;   aA  T R                   R/                  S@S5      (       d   T Ra                  SA5        ST R                   S@'   T R                  5         T R                   R/                  SB5      SC;   a  T R                   R/                  SB5      OI[        T R                   SB   5      (       a  T R                   SB   OT R                  T R                   SB   5      T lU        T R                  T R                  T R                  SD.nUR                  5        H1  u  nnT R                   R/                  U/ 5       H  nU" U5        M     M3     T R                   R/                  SE/ 5       HO  n[        U5      nUR                  SFSG5      nT R                  [        UR                  SH5      5      " T 40 UD6USI9  MQ     U 4SJ jnU" T R                   R/                  SK5      5      T l\        gs  snf ! [<         a  nT R?                  SU 35         SnAGNSnAff = fs  snnf ! [         a    [}        S S!S"/UQ40 UD6T l?         GNf = f! [         a;  nUR                  [        R                  :X  a  T Ra                  S$5         SnAGNe SnAff = f)LzCreate a FileDownloader object with the given options.
@param auto_init    Whether to load the default extractors and print header (if verbose).
                    Set to 'no_verbose_header' to not print the header
NTr   logtostderrquiet)outr   screenzFailed to enable VT mode: no_colorcolor	_warningsz/Overwriting params from "color" with "no_color"TERM dumbNO_COLORc                   > [         R                  S[         R                  S0U    n[        TR                  SUS 4[
        1[        45      =(       d    SnUS;   aL  TnUR                  S5      (       a  UR                  S5      nT(       a  [        U 5      (       a  U(       a  S$ S$ g	US
;   d   U5       eSS	S.R                  X"5      $ )Nstdoutstderrr  auto)r   zauto-ttyzno_color-ttyttyr  TF)alwaysneverr  )r"  r#  )sysr  r  r   paramsstranyendswith
startswithr   get)streamstream_namepolicyr  base_no_colorr   term_allow_colors       r   process_color_policy0YoutubeDL.__init__.<locals>.process_color_policy  s    ::xXFvNK!$+++t9LseUX/YZd^dF==(??5))%00<H#(CF(K(K)1:;t;<<DfD<"U377GGr   console
z
                    warn_when_outdatedallow_unplayable_formatszYou have asked for 
UNPLAYABLEz formats to be listed/downloaded. This is a developer option intended for debugging. 
         If you experience any issues while using this option, zDO NOTz open a bug reportbidi_workaroundFz-w)stdinr  r  bidivfribidiz-czUTF-8rbzCould not find fribidi executable, ignoring --bidi-workaround. Make sure that  fribidi  is an executable file in one of the directories in your $PATH.compat_opts r   Cookieno_verbose_headerc                 n   > TR                   R                  U 5      b  TR                  U SU S35        gg)Nz is deprecated. Use z insteadTF)r%  r*  report_warning)paramoption
suggestionr   s      r   check_deprecated,YoutubeDL.__init__.<locals>.check_deprecated  s8    {{u%1##vh.B:,h$WXr   useidz--idz-o "%(id)s.%(ext)s"_deprecation_warningsr   Impersonate target "z" is not available. Use --list-impersonate-targets to see available targets. You may be missing dependencies required to support this target.zlist-formatslistformats_table
overwritesnooverwritessimulatelist_thumbnailslistformatslistsubtitles	list_only
forceprintprint_to_filer  win32)asciizANSI_X3.4-1968restrictfilenameszAssuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.r   )N-)
post_hooksprogress_hookspostprocessor_hookspostprocessorswhenpost_processkey)r\  c                   > [        5       nU c  U$ [        U 5      (       d  U $ TR                  SU < 35         [        U SSS9 nU H"  nUR	                  UR                  5       5        M$     SSS5        U$ ! , (       d  f       U$ = f! [         a*  nUR                  [        R                  :w  a  e  SnAU$ SnAff = f)z(Preload the archive, if any is specifiedNzLoading archive file rutf-8encoding)	setrr   write_debugrt   addstripOSErrorerrnoENOENT)fnarchivearchive_filelineioer   s        r   preload_download_archive4YoutubeDL.__init__.<locals>.preload_download_archive,  s    eGz!"%%	4RF;< S7;| ,DJJL1 !- < N <; N  99, -Ns5   B	 )A7-B	 7
BB	 B	 	
B=B88B=download_archive)]r%  _ies_ies_instancesrD   _ppsrd  _printed_messages_first_webpage_request_post_hooks_close_hooks_progress_hooks_postprocessor_hooks_download_retcode_num_downloads_num_videos_playlist_level_playlist_urlsr   cache_YoutubeDL__header_cookiesr   valuer)   r*  r$  r  r  rS   
_out_filesr   	Exceptionre  nextfilterr   r2  
setdefaultappendosgetenvlowerboolitems__allow_colorsr8   deprecated_featurereplacer9   rA  _format_errStylesEMPHASISERRORptyopenptyshutilget_terminal_sizer   r&  
subprocessPIPEr   rV   _output_processrh  fdopen_output_channelri  rj  r   r   _load_cookiespopprint_debug_header_impersonate_target_availabler]   r'  
isinstancedictadd_default_info_extractorsplatformgetfilesystemencoding_parse_outtmplcallablebuild_format_selectorformat_selectoradd_post_hookadd_progress_hookadd_postprocessor_hookitemsadd_post_processorr5   rl  )r   r%  	auto_initkr  er0  namer+  system_deprecationoutdated_warningr  masterslaver   
width_args	sp_kwargsoserE  msgimpersonate_targethooksoptrk  ph
pp_def_rawpp_defr\  rp  r.  r/  s   `                            @@r   __init__YoutubeDL.__init__g  s   
 >F	 $45$4qU$45	!$&*#!$&!!" !e4[
 " "''#{{}==3::#**!%!9!93::v
	?"$
 #'v.ICJJX[XbXbKc'dfj"k;;??:&&{{w'3&&{B7>>EG#-DKK 99VR0668FBRYYz23	H '  $ 6 6*
 6$):K /D&v.. 6*
 
 56##$6$>$>tE]$^_[[__122#8#:::##$45;;??566%d&6&6|T[[EYEY&Z%[ \R ##Hdkk.?.?@AASUV ;;??,e44 #002::#(=RtSZ6H
&0ooRVRaRaRgRgh	g+0'1GJ1G+U9+UD( (*yy'>$ &))K%LM"&4[$++//R`Ba&bN#4;;~6::8DEN#''$7&99##%	 	&*?@;;??;3C$ 4;;??#:B?C##C( @ "&!???556HII$*+=*> ?W XY Y
 T[[77/4DKK+,t{{*t{{~/N/Z -1KK,G(GDKK%[[__\*2KKOOL$/.2kk,.G*GDKK';;??:&.3KKOO-.KKOOM*KKOOO,8
 4 4
 '2DKK
#|R03 &.55)0&2F(GDKK%,,.LLG#--/3NN(;UCCCD 04DKK+, *.)Bk)QDKKOOH%*24;;x3H*I*IX&++DKK,AB 	 ,,"44#'#>#>

 {{}GCkkooc2.2 / % ++//*:B?J*%F::fn5D##!&**U"34TDVD $  @	$ 0@R0ST[ 68  	?9!=>>	?8*
8  g+0)T71XZ1X+f\e+fD(g  99,''rs s sl   g
g h"hA/h8  h h8 
h)hh h51h8 4h55h8 8
i=/i87i88i=c                 t   [        U5       VVs/ s H%  u  p#[        R                  " SU5      (       d  M#  UPM'     nnnU(       ac  S/[        U5       VVs/ s H  u  p#X$;  d  M  UPM     snn-   S/-   U Vs/ s H  o!U   PM	     sn-   nU R                  S[	        U5       35        g g s  snnf s  snnf s  snf )Nz^-[0-9A-Za-z_-]{10}$zyt-dlpz--zRLong argument string detected. Use -- to separate parameters and URLs, like this:
)	enumeraterematchrA  r   )r   argviaidxscorrect_argvs         r   warn_if_short_idYoutubeDL.warn_if_short_id@  s     $D/5)$!xx/3 / 	 5 
!*4BAM1BC&-12TGT23 
 GGRS_G`Facd 5 C2s   "B)B)B/$B/7B5c                     UR                  5       nXR                  U'   [        U[        5      (       d   XR                  U'   UR                  U 5        gg)z3Add an InfoExtractor object to the end of the list.N)ie_keyrs  r  typert  set_downloader)r   ier  s      r   add_info_extractorYoutubeDL.add_info_extractorO  sG    		&"d##*,'d# $r   c                     U R                   R                  U5      nUc!  [        U5      " 5       nU R                  U5        U$ )z
Get an instance of an IE with name ie_key, it will try to get one from
the _ies list, if there's no instance it will create a new one and add
it to the extractor list.
)rt  r*  r   r  )r   r  r  s      r   r   YoutubeDL.get_info_extractorW  s?       $$V,:#F+-B##B'	r   c           
      F   [        5        Vs0 s H  oR                  R                  5       U_M     nn[        5       US'    [	        U R
                  R                  SS/5      [        U5      UR                  5        VVs/ s H  u  p1UR                  (       d  M  UPM     snnS.SS9nU H  nU R                  X#   5        M     U R                  S	[!        U5       S
35        gs  snf s  snnf ! [        R                   a  n[        SUR                   35      eSnAff = f)zJ
Add the InfoExtractors returned by gen_extractors to the end of the list
endallowed_extractorsdefault)allr  T	use_regexz$Wrong regex for allowed_extractors: NzLoaded z extractors)r   IE_NAMEr  r   ry   r%  r*  listr  _ENABLEDr  r   
ValueErrorpatternr  re  len)r   r  all_iesr  ie_namesr  s         r   r  %YoutubeDL.add_default_info_extractorsc  s    5J4KL4Kb::##%r)4KL)+	Q. 4ykB=5<]]_T__TE "	#H D##GM2 73x=/=> M  Uxx 	QCAII;OPP	Qs5   $C$>C/ ?C)C) 	C/ )C/ /D DD c                     U[         ;   d
   SU 35       eU R                  U   R                  U5        UR                  U 5        g)z3Add a PostProcessor object to the end of the chain.zInvalid when=N)rD   ru  r  r  )r   ppr\  s      r   r  YoutubeDL.add_post_processoru  sA    ''?=)??'		$r"
$r   c                 :    U R                   R                  U5        g)zAdd the post hookN)rx  r  r   r  s     r   r  YoutubeDL.add_post_hook{  s    #r   c                 h    [        U5      (       d   S5       eU R                  R                  U5        g)z9Add a close hook, called when YoutubeDL.close() is calledzClose hook must be callableN)r  ry  r  )r   chs     r   add_close_hookYoutubeDL.add_close_hook  s*    ||:::|  $r   c                 :    U R                   R                  U5        g)zAdd the download progress hookN)rz  r  r  s     r   r  YoutubeDL.add_progress_hook  s    ##B'r   c                     U R                   R                  U5        U R                  R                  5        H  nU H  nUR	                  U5        M     M     g)z$Add the postprocessing progress hookN)r{  r  ru  valuesr  )r   r  ppsr  s       r   r   YoutubeDL.add_postprocessor_hook  sE    !!((,99##%C$$R(  &r   c                   ^  [        T S5      (       d  U$ [        T S5      (       d   e[        U[        5      (       d   eUR                  S5      S-   nT R                  R
                  R                  US-   R                  5       5        T R                  R
                  R                  5         SR                  U 4S j[        U5       5       5      nUS [        S5      *  $ )Nr  r  r3  r   r  c              3   t   >#    U  H-  nTR                   R                  5       R                  5       v   M/     g 7fN)r  readlinedecode).0_r   s     r   	<genexpr>-YoutubeDL._bidi_workaround.<locals>.<genexpr>  s3      20! **335<<>>0s   58)hasattrr  r&  countr  r8  writeencodeflushjoinranger  )r   message
line_countress   `   r   _bidi_workaroundYoutubeDL._bidi_workaround  s    t.//Nt.////'3'''']]4(1,
""(('D.)@)@)BC""((*gg 2$Z02 2;SYJr   Fc                     U(       a+  XR                   ;   a  g U R                   R                  U5        [        XU R                  R	                  S5      S9  g )Nrc  )r  rc  )rv  rf  r   r%  r*  )r   r	  r  	only_onces       r   _write_stringYoutubeDL._write_string  s?    000""&&w/W
0KLr   c                     Ub  U R                  S5        USLa  U R                  S5        U R                  U R                  U5       S3U R                  R                  5        g)zPrint message to stdoutNz]"YoutubeDL.to_stdout" no longer accepts the argument quiet. Use "YoutubeDL.to_screen" insteadFz`"YoutubeDL.to_stdout" no longer accepts the argument skip_eol. Use "YoutubeDL.to_screen" insteadr3  )ra   r  r  r  r  )r   r	  skip_eolr  s       r   	to_stdoutYoutubeDL.to_stdout  sg    $$ &I J5 $$ &I Jd33G<=R@$//BUBUVr   c                    U R                   R                  S5      (       a  U R                   S   R                  U5        gUc!  U R                   R                  S5      (       a)  OU(       a!  U R                   R                  S5      (       d  gU R                  SR	                  U R                  U5      U(       a  SOS5      U R                  R                  US9  g)	z,Print message to screen if not in quiet modeloggerNr  verbosez{}{}r  r3  r  )r%  r*  debugr  r   r  r  r  )r   r	  r  r  r  s        r   	to_screenYoutubeDL.to_screen  s    ;;??8$$KK!''0(-DKKOOG$$5$++//ZcJdJdMM$//82tUOO""i 	 	9r   c                    [        U[        5      (       d   eU R                  R                  S5      (       a  U R                  S   R	                  U5        gU R                  U R                  U5       S3U R                  R                  US9  g)zPrint message to stderrr  r3  r  N)r  r&  r%  r*  r   r  r  r  r   r	  r  s      r   	to_stderrYoutubeDL.to_stderr  sr    '3'''';;??8$$KK!''0$"7"7"@!ADdooF[F[gpqr   c                     [        U R                  R                  5      (       d  gU R                  XR                  R                  5        g)NFT)r   r  r2  r  )r   codes     r   _send_console_codeYoutubeDL._send_console_code  s5    *4??+B+BCC4!8!89r   c                    U R                   R                  S5      (       d  g U(       a  U R                  S[        U5       S35      nU(       dj  [        R
                  S:X  aV  [        R                  R                  R                  5       (       a)  [        R                  R                  R                  U5        [        U[        5      (       a!  U R                  UR                  U5      5        g g )Nconsoletitlez]0;r   )r%  r*  r#  r}   r  r  ctypeswindllkernel32GetConsoleWindowSetConsoleTitleWr  r   get_ansi_escape)r   r	  progress_statepercentsuccesss        r   to_console_titleYoutubeDL.to_console_title  s    {{~..--8QRY8Z7[[_.`aGrww$6==3I3I3Z3Z3\3\&&77@nn55##N$B$B7$KL 6r   c                     U R                   R                  S5      (       a   U R                   R                  S5      (       a  g U R                  S5        g )Nr&  rM  z[22;0tr%  r*  r#  r   s    r   save_console_titleYoutubeDL.save_console_title  8    {{~..$++//*2M2M-r   c                     U R                   R                  S5      (       a   U R                   R                  S5      (       a  g U R                  S5        g )Nr&  rM  z[23;0tr4  r5  s    r   restore_console_titleYoutubeDL.restore_console_title  r8  r   c                 `    U R                  5         U R                  [        R                  S9  U $ N)r.  )r6  r1  r   INDETERMINATEr5  s    r   	__enter__YoutubeDL.__enter__  s*    !^-I-IJr   c                 r    U R                   R                  S5      b  U R                  R                  5         g g )N
cookiefile)r%  r*  	cookiejarsaver5  s    r   save_cookiesYoutubeDL.save_cookies  s*    ;;??<(4NN! 5r   c                 ~    U R                  5         U R                  [        R                  S9  U R	                  5         g r=  )r:  r1  r   HIDDENclose)r   r   s     r   __exit__YoutubeDL.__exit__  s.    ""$^-B-BC

r   c                     U R                  5         SU R                  ;   a  U R                  R                  5         U ?U R                   H
  nU" 5         M     g )N_request_director)rE  __dict__rM  rI  ry  )r   
close_hooks     r   rI  YoutubeDL.close  sG    $--/""((*&++JL ,r   c                    Ub  U R                  U5        U R                  R                  S5      (       Ga-  UGc  [        R                  " 5       S   (       a  Sn[        [        R                  " 5       S   S5      (       ao  [        R                  " 5       S   R                  S   (       aE  USR                  [        R                  " [        R                  " 5       S   R                  6 5      -  nU[        [        R                  " 5       5      -  nO:[        R                  " [        R                  " 5       5      nSR                  U5      nU(       a  U R                  U5        U(       d  gU R                  R                  S5      (       d  [        R                  " 5       S   (       at  [        [        R                  " 5       S   S5      (       aM  [        R                  " 5       S   R                  S   (       a#  [        R                  " 5       S   R                  nO[        R                  " 5       n[        X5      eSU l        g)ar  Determine action to take when a download problem appears.

Depending on if the downloader has been configured to ignore
download errors or not, this method may throw an exception or
not when errors are found, after printing the message.

@param tb          If given, is additional traceback information
@param is_error    Whether to raise error according to ignorerrors
Nr  r   r  r   exc_infoignoreerrors)r  r%  r*  r$  rR  r  r  	tracebackformat_exceptionrd   
format_excformat_listextract_stackrJ   r|  )r   r	  tbis_errortb_datarR  s         r   troubleYoutubeDL.trouble  s    NN7#;;??9%%z<<>!$Bs||~a0*==#,,.QRBSB\B\]^B_bggi&@&@#,,.QRBSB\B\&]^^+I,@,@,BCCB'33I4K4K4MNG)Br"{{~..||~a WS\\^A->
%K%KPSP\P\P^_`PaPjPjklPm<<>!,55<<>22!"r   yellowz
light bluegreenblueredz	light redzlight black)	HEADERSr  FILENAMEIDDELIMr  
BAD_FORMATWARNINGSUPPRESStest_encodingc                   [        U5      nU(       ae  UnU R                  R                  S5      =(       d    [        USS 5      =(       d    SnUR	                  US5      R                  U5      nUb  X7:w  a  UnUSL a  [        X45      $ Uc  U$ U$ )Nrc  rU  ignoreT)r&  r%  r*  getattrr  r  r   )	r   handleallow_colorstextffallbackrj  original_textrc  s	            r   _format_textYoutubeDL._format_text!  s    4y M{{z2bgfjRV6Wb[bH;;x299(CD#(='3t';{4#gIYg_ggr   c                     U R                   " U R                  R                  U R                  R                  /UQ70 UD6$ r  )rt  r  r  r  r   r   r   s      r   _format_outYoutubeDL._format_out,  s6      !4!4d6H6H6L6L^t^W]^^r   c                     U R                   " U R                  R                  U R                  R                  /UQ70 UD6$ r  )rt  r  r  r  rw  s      r   _format_screenYoutubeDL._format_screen/  s7      !7!79K9K9R9RdUYd]cddr   c                     U R                   " U R                  R                  U R                  R                  /UQ70 UD6$ r  )rt  r  r   r  rw  s      r   r  YoutubeDL._format_err2  s7      !6!68J8J8P8PbSWb[abbr   c                 2   U R                   R                  S5      b  U R                   S   R                  U5        gU R                   R                  S5      (       a  gU R                  U R	                  SU R
                  R                  5       SU 3U5        g)zy
Print the message to stderr, it will be prefixed with 'WARNING:'
If stderr is a tty file the 'WARNING:' will be colored
r  Nno_warningszWARNING: )r%  r*  warningr  r  r  rg  r  s      r   rA  YoutubeDL.report_warning5  sy    
 ;;??8$0KK!))'2{{}--NNd..z4;;;N;NOPPQRYQZ[]fgr   r   )
stacklevelc                4    [        XS-   U R                  SS9  g )Nr   F)r  printerrZ  )ra   r   )r   r	  r  s      r   ra   YoutubeDL.deprecation_warningA  s    Q8I8ITY	[r   c                     U R                   R                  S5      b!  U R                   S   R                  SU 35        U R                  U R	                  SU R
                  R                  5       SU 3S5        g )Nr  zDeprecated Feature: zDeprecated Feature:r  T)r%  r*  r  r  r  r  r  )r   r	  s     r   r  YoutubeDL.deprecated_featureE  sj    ;;??8$0KK!)),@	*JK$**+@$++BSBSTUUVW^V_`bfgr   c                     U R                   " U R                  SU R                  R                  5       SU 3/UQ70 UD6  g)zi
Do the same as trouble, but prefixes the message with 'ERROR:', colored
in red if stderr is a tty file.
zERROR:r  N)r\  r  r  r  )r   r	  r   r   s       r   r   YoutubeDL.report_errorJ  s?    
 	((4;;3D3DEFayQcTXc\bcr   c                     U R                   R                  SS5      (       d  gSU 3nU R                   R                  S5      (       a  U R                   S   R                  U5        gU R                  X5        g)z,Log debug message or Print message to stderrr  FN[debug] r  )r%  r*  r  r  r  s      r   re  YoutubeDL.write_debugQ  s\    {{y%00WI&;;??8$$KK!''0NN7.r   c                 r     U R                  SU S35        g! [         a    U R                  S5         gf = f)z.Report file has already been fully downloaded.[download] z has already been downloadedz/[download] The file has already been downloadedNr  UnicodeEncodeErrorr   	file_names     r   report_file_already_downloaded(YoutubeDL.report_file_already_downloaded[  s<    	NNN[3OPQ! 	NNNLM	Ns    66c                 p     U R                  SU 35        g! [         a    U R                  S5         gf = f)z*Report that existing file will be deleted.zDeleting existing file zDeleting existing fileNr  r  s     r   report_file_deleteYoutubeDL.report_file_deleteb  s7    	5NN4YK@A! 	5NN34	5s    55r  c                .   UR                  S5      nU R                  R                  S5      [        U5      peU=(       d    U=(       a    S=(       d    SnU(       d  U(       d#  [        X1S   US   U=(       d    U=(       d    US9eU R	                  U5        g )N_has_drmignore_no_formats_errorzThis video is DRM protectedzNo video formats found!id	extractor)video_idr  expected)r*  r%  r  rM   rA  )r   infoforcedr  r   ignoredr  s          r   raise_no_formatsYoutubeDL.raise_no_formatsi  s}    ((:& KKOO,EFS	]g?"?]D] Dzd;>O*1*HW*HJ J $r   c                 b    U R                  S5        U R                  5         U R                  S   $ )NzN"YoutubeDL.parse_outtmpl" is deprecated and may be removed in a future versionouttmpl)ra   r  r%  r5  s    r   parse_outtmplYoutubeDL.parse_outtmpls  s,      !qr{{9%%r   c           
         [         nU R                  R                  S5      (       a  S nU R                  R                  S0 5      n[	        U[
        5      (       d  SU0=U R                  S'   nUR                  [        R                  " 5        VVs0 s H!  u  p4UR                  U5      b  M  X1" U5      _M#     snn5        g s  snnf )NrV  c                 F    U R                  SS5      R                  SS5      $ )N - r  rW  r  xs    r   <lambda>*YoutubeDL._parse_outtmpl.<locals>.<lambda>{  s    5#!6!>!>sC!Hr   r  r  )	r>   r%  r*  r  r  r  updater=   r  )r   sanitizer  r  vs        r   r  YoutubeDL._parse_outtmplx  s    ;;??.//HH++((B7'4((097/CCDKK	"W?3H3H3Je3J41gkkZ[n8A;3Jefes   C
-C
c           	         U R                   R                  S0 5      n[        U[        5      (       d   S5       e[        R
                  R                  [        UR                  SS5      R                  5       5      U(       a)  [        UR                  US5      R                  5       5      OSU=(       d    S5      n[        X@R                   R                  S5      S9$ )Npathsz&"paths" parameter must be a dictionaryhomer  windowsfilenames)force)
r%  r*  r  r  r  pathr  rf   rg  r   )r   dir_typefilenamer  r  s        r   get_output_pathYoutubeDL.get_output_path  s    ,%&&P(PP&ww||		&"-3356<DK		(B/5578"N T9K)LMMr   c                     SR                  [        R                  " [        R                  SS95      nU R                  SSU S35      R                  SSU S35      n [        U 5      R                  US5      $ )Nr      r  z%%%z$$$)r  randomchoicesstringascii_lettersr  rf   )r  seps     r   _outtmpl_expandpathYoutubeDL._outtmpl_expandpath  sj     ggfnnV%9%9R@A//$!C5
3;;DAcU!*M 7#++C44r   c                 ^    [         R                  " [        R                  " SS5      S U 5      $ )z1Escape any remaining strings like %s, %abc% etc. r  z	(?![%( ])c                 Z    U R                  S5      (       a  SOSU R                  S5      -   $ )Nhas_keyr  r  r   groupmobjs    r   r  *YoutubeDL.escape_outtmpl.<locals>.<lambda>  s!    

9 5 5"3$**Q-Or   )r  subrE   r   r  s    r   escape_outtmplYoutubeDL.escape_outtmpl  s+     vv%%b,7O 	r   c                 
   [         R                  " [        R                  " SS5      S U R	                  U5      5      n U R                  U5      [        R                  " [        5      -    g! [         a  nUs SnA$ SnAff = f)z!@return None or Exception object [^)]*z
[ljhqBUDS]c                 0    U R                  S5      S S  S3$ )Nr   sr  r  s    r   r  ,YoutubeDL.validate_outtmpl.<locals>.<lambda>  s    DJJqM#2./q1r   N)
r  r  rE   r   r  r  collectionsdefaultdictintr  )clsr  errs      r   validate_outtmplYoutubeDL.validate_outtmpl  sn     &&%%g|<1##G,.	w'+*A*A#*FF 	J	s   ,A, ,
B6A=7B=Bc                 d    [        U 5      n U R                  SS 5        U R                  SS 5        U $ )N__postprocessors__pending_error)r  r  )	info_dicts    r   _copy_infodictYoutubeDL._copy_infodict  s/    O	($/'.r   c           	        ^ ^^^	^
^^^^^^^^^^^ TR                  S[        [        R                  " 5       5      5        T R                  T5      mTR	                  SS5      b  [        TS   T(       a  SOS5      OSTS'   [        T R                  R	                  SS5      S-
  T R                  -   5      TS	'   T R                  TS
'   TR	                  S5      c  T R                  TSS9TS'   [        TR	                  S5      =(       d    S5      [        TR	                  S5      =(       d    S5      T R                  R	                  S5      =(       d    SS.m0 m[        R                  " [        R                  " SS[         S35      5      n[         R"                  [         R$                  [         R&                  S.mSSS0-  nSUSU S3S.-  nSU S[(         S 3m
S!R                  S"R+                  [-        [        R.                  TR1                  5       5      5      5      m[        R                  " S#U S$T T
 S%35      m	S& mUU4S' jmU
UUUU4S( jmT R                  R	                  S)S*5      mU 4S+ jm[3        T5      (       a  T R5                  S,5        OeT(       d  O][6        R8                  S-:w  aB  T R                  R	                  S.5      (       d"  T R                  R	                  S/5      S0L a  S1 mOUU 4S2 jmS3 m " S4 S5[:        R<                  5      nU" 5       mU	UUUUUUUU4	S6 jnUR?                  X5      T4$ )7zMake the outtmpl and info_dict suitable for substitution: ydl.escape_outtmpl(outtmpl) % info_dict
@param sanitize    Whether to sanitize the output as a filename
epochr   NrW  :duration_stringautonumber_startr   
autonumbervideo_autonumberr   r  __last_playlist_indexr   	n_entriesautonumber_size   )playlist_indexplaylist_autonumberr  r  [z	ljhqBUDS])+rW  *z*(?:\w+|%(num)s|%(num)s?(?::%(num)s?){1,2})numz	(?:-?\d+)z2\w*(?:\.(?:%(inner)s|{%(field)s(?:,%(field)s)*}))*z\w*(?:\.z)*)innerfieldz(?:z|-?)z(?:{})|z8(?xs)
            (?P<negate>-)?
            (?P<fields>z)
            (?P<maths>(?:z)*)
            (?:>(?P<strf_format>.+?))?
            (?P<remaining>
                (?P<alternate>(?<!\\),[^|&)]+)?
                (?:&(?P<replacement>.*?))?
                (?:\|(?P<default>.*?))?
            )$c                     U S:X  a  gSU ;   a%  [        [        [        U R                  S5      5      6 $ [        U 5      b  [	        U 5      $ U $ )Nr  .)slicemaprp   splitr  )r  s    r   _from_user_input3YoutubeDL.prepare_outtmpl.<locals>._from_user_input  sH    |c+u{{3/?@AAU#/5z!Lr   c                   > [         R                  " SU 5       VVs/ s H7  nUR                  S5      (       a  U/OUR                  S5        H  nUPM     M9     n nnS H(  nU (       d  M  X   (       a  M  U R                  U5        M*     [	        U 5       H  u  p2UR                  S5      (       d  T" U5      X'   M'  UR                  S5      (       d   SU SU  35       eUSS	 R                  S
5       Vs0 s H'  oD[        [        TUR                  S5      5      5      _M)     snX'   M     [        TU SS9$ s  snnf s  snf )Nz\.({.+?})\.?{.)r   r  }zNo closing brace for z in r   r  r   T)traverse_string)	r  r  r)  r  r  r(  r  r  r   )fieldsr  rq  r  r  r  r  s        r   _traverse_infodict5YoutubeDL.prepare_outtmpl.<locals>._traverse_infodict  s/   !#/6!B M!BA'(||C'8'8aggcl J!  J !BF M6&))JJqM  "&)||C(( 0 3FIzz#O*?s$vh(OOSTUVWYSZS`S`adSefSeaS)91773<%H IISef	 *  	64HHM gs   >D86.D>c                 X  > T
" U S   5      nU S   (       a  [        U5      nUb  US-  nU S   nU(       a  [        U5      nS nU(       a  [        R                  " U(       a  TOT	U5      R                  S5      nU[	        U5      S  nUc  TU   nMN  US   S:X  a  USS  S4OUS4u  pE[        U5      nUc  [        T
" U5      5      n U" XU-  5      nS nU(       a  M  U S   (       a  [        XS   R                  S	S
5      5      nT(       a  US:X  a  S nU$ ! [
        [        4 a     g f = f)Nr  negater  mathsr   rW  r   strf_formatz\,r   r  )	ri   r  r  r  r  	TypeErrorZeroDivisionErrorr   r  )mdictr  
offset_keyoperatoritem
multiplieroffsetMATH_FIELD_REMATH_FUNCTIONSMATH_OPERATORS_REr  r  s          r   	get_value,YoutubeDL.prepare_outtmpl.<locals>.get_value  sS   &uX7EX%e,$RKEwJ%e, 88)17H"$$)E!H  ",CIJ!7J'#1$#7 9=aCQR"~dTUY$D*40F~!./A$/G!H$ (V0C D  $H! !j$ ]#(m0D0L0LUTW0XY ERKL &'89 $#$s   D D)(D)outtmpl_na_placeholderNAc           
         > [        [        U5      USTR                  S   ;   a"  [        [        R
                  " SU 5      5      S9$ [        S9$ )Nzfilename-sanitizationr<  z(^|[_.])id(\.|$))
restrictedis_id)r   r&  r%  r  r  searchrA   )r^  r  r$  r   s      r   filename_sanitizer5YoutubeDL.prepare_outtmpl.<locals>.filename_sanitizer,  sN    $SZJ*dkk-.HH RYY2C89" "  " "r   zHPassing a callable "sanitize" to YoutubeDL.prepare_outtmpl is deprecatedrT  rV  r  Fc                 X    [        U5      R                  SS5      R                  SS5      $ )N/u   ⧸ r  )r&  r  )r^  r  s     r   r  +YoutubeDL.prepare_outtmpl.<locals>.sanitize8  s&    5z))#x8@@rJJr   c                 D   > T" XTR                   R                  S5      S9$ )NrV  r$  )r%  r*  )r^  r  r'  r   s     r   r  r,  ;  s    )#QdAeffr   c                 d    [        U [        [        45      (       a  [        U 5      $ [	        U 5      $ r  )r  rd  rQ   r  repr)objs    r   _dumpjson_default4YoutubeDL.prepare_outtmpl.<locals>._dumpjson_default>  s'    #X//Cy 9r   c                       \ rS rSrS rSrg)8YoutubeDL.prepare_outtmpl.<locals>._ReplacementFormatteriC  c                 P    UR                  5       (       a  US   S4$ [        S5      e)Nr   r  zUnsupported field)isdigitr  )r   
field_namer   r   s       r   	get_fieldBYoutubeDL.prepare_outtmpl.<locals>._ReplacementFormatter.get_fieldD  s+    %%''7B;& !455r   r=  N)__name__
__module____qualname____firstlineno__r9  __static_attributes__r=  r   r   _ReplacementFormatterr5  C  s    6r   r@  c           
        >	 U R                  S5      (       d  U R                  S5      $ U R                  S5      n[        R                  " TU5      nS S TS4u  p4pVU(       ac  UR                  5       nUS   b  US   OUnT" U5      nUS   US   pFUc(  US   (       a  [        R                  " TUS	   S
S  5      nOO	U(       a  Mc  S X44;  a   TR	                  XC5      nU R                  S5      nUS:X  a%  UT;   a  [        U[        5      (       a
  STU   S S3nU R                  S5      =(       d    SnUS S  S3n	Uc  USpsGOUS   S:X  a>  SU;   a  SOSn
U
R                  [        [        [        U[        [        4S95      5      U	psGOUS   S:X  a%  [        R                  " UTSU;   a  SOS SU;  S9U	psGOtUS   S:X  a  [        [        U5      5      U	psGOTUS   S:X  a/  [        [        SU;   a  [        U5      OU/5      n[!        USS9U	psGOUS   S:X  aA  SU	 3R#                  5       [        U5      R#                  5       -  nUR%                  S S!5      SpsOUS   S":X  a9  [&        R(                  " S#R	                  SU;   a  S$OSSU;   a  S%OS&5      U5      U	psOUS   S%:X  a6  US S R+                  SS5      Sp{[-        X;(       a  SU S'3OS(SU;   a  S)OS*S+9nOQUS   S,:X  a  T" XcSU;   S-9U	psO<US   S.:X  a  U(       a  [        U5      S   nOU	nOUS   S/;  a  [/        U5      nUc  USpsT(       a<  US   S0:X  a  [1        U5      U	psOUS   S1:X  a  [3        U5      U	psUS   S2;   a  T" Xc5      nS3R	                  UR+                  SS45      U R                  S5      5      nUTU'   S5R	                  XU R                  S65      S79$ ! [
         a    S TpS GNf = f)8Nr  r   r^  r  r  r  replacement	alternate	remainingr   r   r  0d
conversionr  l#r3  , )allowed_typesj   r  )r  indentensure_asciihqT)shellBr  ra  rl  UzNF{}{}KDCzf%sz%d%si     )factorSr.  crsar`  r  csraz{} {}z% z{prefix}%({key}){fmt}prefix)r^  fmtr^  )r  r  r  	groupdictr   r  r  r  r  r  r&  r   bytesjsondumpsre   r   r  r  unicodedata	normalizer  rk   ri   r0  rU  )
outer_mobjr^  r  r  rB  r  
last_fieldr_  flagsstr_fmtdelimnum_fmtINTERNAL_FORMAT_RE	TMPL_DICTr2  field_size_compat_mapr'  r  nareplacement_formatterr  s               r   
create_key-YoutubeDL.prepare_outtmpl.<locals>.create_keyK  s   ##I..!''**""5)C88.4D6:D"b6H3E~~'-1)_-H$y/g!$*.x.$}:MK=T+%688$6[8I!"8MND $ E//.188LE ""8,Cczj,AAjQVX[F\F\/
;A>a@$$\28bESb
!nG}$csRC #u$"ZZC%PSUZ|1\(]^`gsRC!ZZ#4 #u1$SPUEUWX_  RC'E
3WsRCCC5L%ugN(d;WsRCG9,,.U1B1B1DD"\\'8<csRC(22OO3%<CRuZ]^ $  RC"3Bx//R8#-eq	5EV\=@E\TtURC/
cUZl[]dsRCJqME!CR%%e,=!(#3 r7c>!%eg3W^!&uw3r7f$$Z7E//#++c5"9:;K;KH;UVC"IcN*11c:K[K[\dKe1ffw " .%)27.s   O OO) r  r  timer  r*  rm   r%  r}  r~  format_resolutionrw   r  compilerE   r   rF   float__add____sub____mul__rB   r  r  escapekeysr  ra   r$  r  r  	Formatterr  )r   r  r  r  EXTERNAL_FORMAT_REFIELD_INNER_REFIELD_REr@  rq  rl  r  r  r  rm  r2  r  r  rn  r'  r  ro  rp  s   ` ``     @@@@@@@@@@@@@r   prepare_outtmplYoutubeDL.prepare_outtmpl  s   
 	Wc$))+&67''	2	 }}Z.: )J/cJ 	#$ #&dkkoo6H!&Lq&PSWSfSf&f"g	,(,(8(8	$%==&.&*&<&<YPT&<&UIl#
 /y}}=T/U/ZYZ[#3IMM+4N4SRS#T++//*;<A!
 	ZZ(:(A(A'QO_N``iKj(kl
 G%Q]I^^H#  03L
 
 xjI;a8%,,SXXc"))^EXEXEZ6[-\]ZZ . z "+,]O <	) 			I %	 %	N [[__5t<	" H$$%opllg%dkkoo>Q.R.RKKOO$675@Kg	
	6F$4$4 	6 !6 7N	g N	g` "%%j:IEEr   c                 Z    U R                   " X/UQ70 UD6u  pU R                  U5      U-  $ r  )r  r  )r   r  r  r   r   s        r   evaluate_outtmplYoutubeDL.evaluate_outtmpl  s5    !11'VtVvV""7+i77r   )r  	tmpl_typec                T   S X#4;   d   S5       eUc8  U R                   S   R                  U=(       d    SU R                   S   S   5      n U R                  U5      nU R                  X!S5      nU(       d  g US;   ad  U R                   R                  S5      UR                  S5      peU(       a1  U(       a*  XV:w  a%  UR	                  SU 35      (       a  [        XFU5      nO2U(       a+  [        U   nU(       a  [        XGUR                  S5      5      nU R                   R                  S	S
5      nU(       a%  UR                  SS5      tp[        U	S U /UQ7SS06nU$ ! [         aA  n
U R                  S[        U
5      -   S-   [        [        5       5      -   S-   5         S n
A
g S n
A
ff = f)Nz,outtmpl and tmpl_type are mutually exclusiver  r  Tr  temp	final_extr   r
  trim_file_nameF   rj  zError in output template: z (encoding: r   )r%  r*  r  r  r(  r   rC   rsplitrs   r  r   r&  r0  r{   )r   r  r  r  r  r  r   	force_extr  no_extr  s              r   _prepare_filenameYoutubeDL._prepare_filename  s   ++[-[[+?kk),001GiU^I_`iIjkG	..w7G,,WFHL(!%!=y}}U?S3)9h>O>ORST]S^P_>`>`0	JH))4	0immTYFZ[H "[[__-=uEN'sA6()@R3RcRO 	:SXEVY]^o^qYrruxxy	s   *E 6C%E 
F'&7F""F')r  warnc                   U(       a  U(       a   S5       eSnU R                  XUS9nU(       d  US;  a  gU(       al  U R                  R                  S5      (       d  OKUS:X  a  U R                  SS	S
9  O4[        R
                  R                  U5      (       a  U R                  SS	S
9  US:X  d  U(       d  U$ U R                  X%5      $ )zGenerate the output filenamez+outtmpl and dir_type are mutually exclusiveN)r  r  r  r  r  rW  z/--paths is ignored when an outputting to stdoutTr  zE--paths is ignored since an absolute path is given in output template)r  r%  r*  rA  r  r  isabsr  )r   r  r  r  r  r  s         r   prepare_filenameYoutubeDL.prepare_filename  s    N!NN<H)))QX)YHL8;;??7++S##$Uae#fx((##$kw{#|s?(O##H77r   c                   ^ ^^^	^
 ST R                   S   ;   a  SOTR                  SS5      m	T(       d  T	S:X  d   S5       eTR                  STR                  SS5      5      m
U	UUU U
4S	 jnT R                  T5      (       a  S
R                  [	        TST R                  ST R                  R                  5       S35      [	        TST R                  ST R                  R                  5       S35      S45      nS[        pvO U" 5       nS[        pvUbC  U(       d  T R                  SU-   5        T R                   R                  US5      (       a  U" 5       eU$ ! [         a"  nUR                  S[        U5      pvn SnANoSnAff = f)z-Returns None if the file should be downloadedzplaylist-match-filterr<  r  _typez,Only video result can be considered completetitler  entryc                  V  > TS;   a  g TS;   a  [        UU4S j5      (       d  g ST;   a  TS   n TR                  R                  SS5      nU(       a8  [        R                  " X[        R
                  5      (       d  SU -   S-   U-   S-   $ TR                  R                  S	S5      nU(       a8  [        R                  " X [        R
                  5      (       a  SU -   S
-   U-   S-   $ TR                  S5      nUbG  TR                  R                  S[        5       5      nX4;  a  [        U5      R                  5        SU 3$ TR                  S5      nUbT  TR                  R                  S5      nUb  XV:  a  STXV4-  $ TR                  R                  S5      nUb  XW:  a  STXW4-  $ [        TR                  S5      TR                  R                  S5      5      (       a  ST S3$ TR                  R                  S5      nUc  g S n	  U" TTS9n
U
[        L a   TR                  TR                  T5      TR                   R"                  5      n[%        TR                  SU S3TR                   R&                  5      5      R)                  5       R+                  5       nUS;   a  g US:X  a   U	(       a  [-        U	5      " ST 35      eST 3$ M  U
$ ! [         a    T(       a  S OU" T5      n
 Nf = f! [         a,  nUR                  [        La  e UR                  Up S nAGNS nAff = f)Nplaylistmulti_videor   url_transparentc                  P   > TR                  T S   5      R                  T S   5      $ )Nr  r   )r   is_single_video)r  r   s   r   r  >YoutubeDL._match_entry.<locals>.check_filter.<locals>.<lambda>  s'    D33Ih4GHXXYbchYijr   r  
matchtitleF"z" title did not match pattern "rejecttitlez " title matched reject pattern "upload_date	daterangez upload date is not in range r   	min_viewszBSkipping %s, because it has not reached minimum view count (%d/%d)	max_viewszCSkipping %s, because it has exceeded the maximum view count (%d/%d)r   z
Skipping "z" because it is age restrictedmatch_filter
incompletez
Download "z
"? (Y/n): >   r  ynz	Skipping )r   r%  r*  r  r&  
IGNORECASErH   r`   	isoformatr^   r  rI   r  rA   r{  r  r  rc  inputr  r  rg  r  )r  r  r  date
date_ranger   r  r  r  	cancelledretr  r  replyr  r  r  r   video_titles                 r   check_filter,YoutubeDL._match_entry.<locals>.check_filter  s   3344Xj>l >l)#!'*![[__\5A
99ZFF"U{-NNQ[[^aaa"kkoomUCyyR]]CC"U{-OOR]]`ccc==/D![[__[)+F
)+D1;;=>>[\f[ghh"|4J% KKOOK8	(Z-C_cnpz  cG  G  G KKOOK8	(Z-C`doq{  dH  H  HimmK8$++//+:VWW#K=0NOO;;??>:L#I	.J&yZHC j #2243H3H3SUYU`U`UiUijH!$"5"5$XJj94;;;O;O#Q RRWRWRYZ_Z_Za 	)##$"&y/Ik]2K"LL!*;-88  J' ! J",$,y2ICJ % .77*,!$#Y.s0   K K/,K2 .K//K2 2
L(<!L##L(r  %s: r  z(has already been recorded in the archivebreak_on_existingbreak_on_rejectr  Nr  F)r%  r*  in_download_archiver  rl   r{  r  rd  r  rL   rY   rI   r  r  r  )r   r  r  silentr  reason	break_opt	break_errr  r  r  s   ```      @@r   _match_entryYoutubeDL._match_entry  sk   2dkk-6PPV_VcVcdkmtVuUg-]/]]-mmGY]]4-IJ>	 >	@ ##I..WWY1D1DT4;;>>1Z0[[].^_YD4G4GdkkNbNb4c3dde1fg:< =F $78LyO% (9:N9}v56{{y%00k! % N/0uund1g99Ns   E 
F$FFc                 X    UR                  5        H  u  p#U R                  X#5        M     g)z=Set the keys from extra_info in info dict if they are missingN)r  r  )r  
extra_infor^  r  s       r   add_extra_infoYoutubeDL.add_extra_info0  s'     %**,JC  , -r   c                 :   Uc  0 nU(       d	  U(       a  SnU(       a"  X0R                   ;   a  X0R                   U   0O0 nOU R                   nUR                  5        H  u  pU	R                  U5      (       d  M  U	R                  5       (       d  U R	                  S5        U	R                  U5      n
U
by  U R                  XS.5      (       aa  U R                  SU R                  XR                  R                  5       S35        U R                  R                  SS5      (       a  [        e  gU R                  XR                  U5      X$U5      s  $    U R                  R                  S	5      SS
/4;  nU R!                  S[#        USS5       SU 3U(       a  SOSS9  g)a:  
Extract and return the information dictionary of the URL

Arguments:
@param url          URL to extract

Keyword arguments:
@param download     Whether to download videos
@param process      Whether to resolve all unresolved references (URLs, playlist items).
                    Must be True for download to work
@param ie_key       Use only the extractor with this key

@param extra_info   Dictionary containing the extra values to add to the info (For internal use only)
@force_generic_extractor  Force using the generic extractor (Deprecated; use ie_key='Generic')
NGenericz^The program functionality for this site has been marked as broken, and will probably not work.)r  r  r  z*: has already been recorded in the archiver  Fr  r  zNo suitable extractor (%s)z found for URL rY  )rs  r  suitableworkingrA  get_temp_idr  r  r{  r  rd  r%  r*  rL   _YoutubeDL__extract_infor   r   rl   )r   r   downloadr  r  processforce_generic_extractoriesr^  r  temp_idextractors_restricteds               r   extract_infoYoutubeDL.extract_info6  s   $ J1F17991D699V,-"C))Cyy{GC;;s##::<<## %B C nnS)G"t'?'?w@^'_'_T-@-@++..-Y,Z [J  J K;;??#6>>..&&s,C,CC,H(`ghh #" %)KKOO4H$IRVYbXcQd$d! 5l64QX6Y5ZZijmino*?T  Kr   c                 F   ^  [         R                  " T 5      U 4S j5       nU$ )Nc           
        >   T" U /UQ70 UD6$ ! [         [        [        R                  [        R                  4 a    e [
         aV  nUR                  (       a  U R                  U S35        O%U R                  S5        U R                  U S35         S nAM  S nAf[         a  nUR                  nUR                  (       aE  USR                  SR                  [        [         R"                  UR                  5      5      5      -  nUS-  nU R%                  U5         S nAg S nAf[&         a3  nU R%                  [)        U5      UR+                  5       5         S nAg S nAf[,         a`  nU R.                  R1                  S5      (       a:  U R%                  [)        U5      [3        [4        R6                  " 5       5      S9   S nAg e S nAff = f)Nz; Re-extracting dataz
This video is available in {}.rJ  zL
You might want to use a VPN or a proxy server (with --proxy) to workaround.rS  r  )r   rI   rQ   
IndexErrorrT   rX   r  r  r  rA  rO   r  	countriesr   r  r  rP   
short2fullr   rM   r&  format_tracebackr  r%  r*  rd   rT  rV  )r   r   r   r  r  r   s        r   r   8YoutubeDL._handle_extraction_exceptions.<locals>.wrapperi  s   6t6v66'):H<O<OQZQeQef $ zz!,@'ABt,++qc1E,FG) +%%C{{AHH 7 7EJG  H HjjC%%c**  & D%%c!fa.@.@.BCC  ! {{~66))#a&5FyG[G[G]5^)_  	sB    8GABG&A8D##G0)EG+AGGGr   r   s   ` r   _handle_extraction_exceptions'YoutubeDL._handle_extraction_exceptionsh  s%    			 
	8 r   c                   ^ ^	 T R                   R                  S5      (       aB  UR                  SS5      S:w  d,  UR                  S5      (       d  UR                  S5      (       a  g S nSm	U	U 4S jnT R                   R                  S5      u  pE[        US	 5      nUc`  UR                  S
5      S:X  aK  [        U(       a  U(       a  [        R
                  " XE5      O
U=(       d    US5      nT R                  S5        O'U(       a   U=(       d    SS::  a  T R                  S5        [        [        U=(       d    SU=(       d    S5      U=(       d    [        S5      5      nT R                  SU" U5       S35        [        R                  " 5       U-   n  U[        R                  " 5       -
  nUS::  a  U" S5        [        SSS9eU" ST R                  U" U5      T R                  R                  5       35        [        R                   " S5        M}  ! ["         a    U" S5        [        SSS9e[$         a,  n['        U[        5      (       d  T R                  S5        e S nAff = f)Nwait_for_videor  r  formatsr   c                 *    S[        U S-  5      S S -  $ )Nz%02d:%02d:%02drX  r  )r   )durs    r   r  +YoutubeDL._wait_for_video.<locals>.<lambda>  s    !14Gd
4STWUW4X!Xr   r  c                    > U  S3nTR                   R                  S5      (       d!  U S[        T5      [        U 5      -
  -  -   S-   nOT(       a  g TR                  USS9  U mg )Nr3  
noprogressr  r  T)r  )r%  r*  r  r  )r  full_msglast_msgr   s     r   progress+YoutubeDL._wait_for_video.<locals>.progress  s]    bzH;;??<00HC(@!AADHNN8dN3Hr   c                 8    U S   [         R                   " 5       -
  $ )Nr   )rs  r  s    r   r  r    s    A.A,BTYY[,Pr   live_statusis_upcomingr   z"Release time of video is not knownz=Video should already be available according to extracted infoinfz[wait] Waiting for z - Press Ctrl+C to try nowTz[wait] Wait period ended)r  z*[wait] Remaining time until next attempt: r   z[wait] Interrupted by user)r%  r*  r   roundr  uniformrA  minmaxrv  r  rs  rX   r{  r  r  sleepKeyboardInterruptBaseExceptionr  )
r   	ie_result
format_durr  min_waitmax_waitdiff	wait_tillr  r  s
   `        @r   _wait_for_videoYoutubeDL._wait_for_video  s    011=='2g===++y}}U/C/CX
	 "[[__-=>y"PQ<IMM-8MIX;]e]qiqtuvD DEDIA!+ _`3tyq(-a0(2JeElK,Z-=,>>XYZIIK$&		 499;.19RL'(BTRREdFYFYZdeiZjlplwlw  mA  mA  GB  FC  D  E

1  ! 	MRL <tLL 	a//r"	s   A>H %I#7'II#	autoscopec                   [        U5      R                  5        GH  nU(       a)  [        UR                  5       5      (       a  [        S5      eUR	                  S5      =(       d    SnUR	                  S5      nUS:X  a  Sn[
        R                  R                  UR	                  S5      =(       d    SUR                  UR                  SSUS	S	UR	                  S
5      =(       d    S[        UR	                  S
5      5      UR	                  S5      =(       d    SUSSS0 5      nU(       a  U R                  R                  U5        GM.  US	L a/  U R                  S5        U R                  R                  U5        GMb  U(       a/  U R                  S[!        SS9 3S	S9  U R#                  X&/5        GM  U R%                  SSSS9  GM     g)a6  Loads cookies from a `Cookie` header

This tries to work around the security vulnerability of passing cookies to every domain.
See: https://github.com/yt-dlp/yt-dlp/security/advisories/GHSA-v8mc-9377-rwjj

@param data         The Cookie header as string to load the cookies from
@param autoscope    If `False`, scope cookies using Set-Cookie syntax and error for cookie without domains
                    If `True`, save cookies for later to be stored in the jar with a limited scope
                    If a URL, save cookies in the jar with the domain of the URL
zInvalid syntax in Cookie Headerdomainr  expiresNversionr   FTr  securezPassing cookies as a header is a potential security risk; they will be scoped to the domain of the downloaded urls. Please consider loading cookies from a file or browser instead.zmThe extractor result contains an unscoped cookie as an HTTP header. If you are using yt-dlp with an input URLr   )beforer  zEUnscoped cookies are not allowed; please specify some sort of scopingrY  rZ  )r   r  r'  r  r*  httprC  r>  r^  r  r  
set_cookier  r  r  rA  r_   _apply_header_cookiesr   )r   datar  cookier  expiryprepared_cookies          r   r  YoutubeDL._load_cookies  s    *$/668FS11 !BCCZZ)/RFZZ	*F|"nn33

9%*FJJdEdFJJv$6$<"d6::fCU>V

8$-vudD"NO
 ))/:d"''VW %%,,_=##@@S[^@_?`b" $ $ **96GH!!"i%*U " <9 9r   c                 ,   [         R                  R                  U5      nUR                  (       d  g[	        [
        R
                  U=(       d    U R                  5       H2  nSUR                   3Ul        U R                  R                  U5        M4     g)a  Applies stray header cookies to the provided url

This loads header cookies and scopes them to the domain provided in `url`.
While this is not ideal, it helps reduce the risk of them being sent
to an unintended destination while mostly maintaining compatibility.
Nr
  )
r   parseurlparsehostnamer  copyr  r  rC  r  )r   r   r   parsedr  s        r   r  YoutubeDL._apply_header_cookies  sh     &&s+$))W%E0E0EFF01FMNN%%f- Gr   c                 ^   U R                  U5         UR                  U5      nUc*  U R                  SUR                   S[        5        35        g [        U[        5      (       a  SUS.nUR	                  S5      (       a  UR                  SUS   5        U R                  XbU5        U(       a#  U R                  U5        U R                  XcU5      $ U$ ! [         aN  nU(       aA  U R                  R	                  S5      (       a  U R                  U5        U R                  5         e S nAff = f)Nr  z
Extractor z returned nothingcompat_list)r  entriesoriginal_url)r  extractr\   r%  r*  rA  r   r  r_   r  r  r  add_default_extra_infoprocess_ie_result)r   r   r  r  r  r  r  r  s           r   __extract_infoYoutubeDL.__extract_info  s   ""3'	

3I *RZZL8IJ]J_I` abi&& '$I >>.))  N1KL##I37  +)))zJJ-  	;;??#344''*$$&	s   C 
D,A	D''D,c                    Ub  U R                  UUUS.5        UR                  S5      nU(       a'  U R                  U[        U5      [        U5      S.5        Ub.  U R                  UUR                  UR                  5       S.5        g g )N)webpage_urlr  r$  )webpage_url_basenamewebpage_url_domain)r  extractor_key)r  r*  r   ro   r  r  )r   r  r  r   r$  s        r   r   YoutubeDL.add_default_extra_info  s    ?	" #,   mmM2	(4[(A&0&=,  >	ZZ!#,  r   c                 F  ^ ^^ Uc  0 nTR                  SS5      nUS;   Ga  [        TS   T R                  R                  S5      (       a  SOSS	9TS'   TR                  S
5      (       a  UR                  S
5      (       d	  S
TS
   0UEnT R                  R                  SS5      nUS:X  a  SU;   d  USL Ga
  TR                  5       n[	        TR                  S5      T R
                  5      nU(       a-  TR                  S5      (       d  UR                  TS   5      US'   T R                  XgTS   5        T R                  Xc5        T R                  U5      u  phT R                  US5        T R                  U5        T R                  U5        T R                  R                  SS5      (       a  T R                  U5        T$ US:X  Ga  T R                  TU5        T R                  TUS9mT R                  T5        T=(       d    0 R                  S5      n	U	(       a  [        U	[         5      (       a  U	/n	T R#                  SR%                  TS   ['        U	5      5      5        T R)                  SR%                  SR+                  U	5      5      5        U	 V
s/ s H-  n
T R-                  XUT R                  R                  S5      S9PM/     sn
TS'   T$ US:X  a$  T R-                  TS   UTR                  S5      US9$ US:X  a  T R-                  TS   TR                  S5      USSS9nU(       d  U$ 1 SkmTR                  S5      (       d  TR                  S 5      c  T1 S!k-  mUR                  5       nUR/                  [1        TU4S" j5      5        UR                  S5      S:X  a  SUS'   T R3                  XUS#9$ US$;   Ga  TR                  S%5      nU(       aX  UT R4                  ;   aH  T R#                  S&R%                  TR                  S'5      5      =(       d    TR                  S5      5        gT =R6                  S(-  sl        T R4                  R9                  U5        T R                  TS5        T R;                  T5         T R=                  TU5      T =R6                  S(-  sl        T R6                  (       d  T R4                  R?                  5         $ $ US):X  ag  T RA                  S*R%                  TR                  S+5      5      5        UU 4S, jnTS-    Vs/ s H  nT R3                  U" U5      X#5      PM     snTS-'   T$ [C        S.U 35      es  sn
f ! T =R6                  S(-  sl        T R6                  (       d  T R4                  R?                  5         f f = fs  snf )/z
Take the result of the ie(may be modified) and resolve all unresolved
references (URLs, playlist items).

It will also download the videos if 'download'.
Returns the resolved ie_result.
Nr  r  r  r   prefer_insecurer  https)schemer  extract_flatFin_playlistr  Tr  r  force_write_download_archiver  additional_urlsz)[info] {}: {} additional URL(s) requestedzAdditional URLs: "{}"", "r  )r  r  additional_entries)r  r  r  )r  r  r  r  >   r   r  r  section_endsection_start>   r  r  r'  c                 $   > US L=(       a    U T;  $ r  r=  )r  r  exempted_fieldss     r   r  -YoutubeDL.process_ie_result.<locals>.<lambda>n  s    !4-BlTU]lTlBlr   r  r  r  r$  z3[download] Skipping already downloaded playlist: {}r  r   r  zCExtractor {} returned a compat_list result. It needs to be updated.r  c           
      z   > TR                  U TS   TS   [        TS   5      [        TS   5      TS   S.5        U $ )Nr  r$  r'  )r  r$  r%  r&  r'  )r  r   ro   )r`  r  r   s    r   _fixup+YoutubeDL.process_ie_result.<locals>._fixup  sQ    ##A!*;!7#,]#;,8=9Q,R*4Y}5M*N%.%?(  r   r  zInvalid result type: )"r*  r   r%  r  r   r   r  r  r  pre_process_fill_common_fields_YoutubeDL__forced_printings_raise_pending_errorsrecord_download_archiveprocess_video_resultr  r&  r  r   r  re  r  r  r  rh   r   r  r  rf  _sanitize_thumbnails_YoutubeDL__process_playlistclearrA  r  )r   r  r  r  result_typer-  	info_copyr  r  r1  r   r  
new_resultr$  r;  r`  r7  s   ``              @r   r   YoutubeDL.process_ie_result  s^    JmmGW544+% 4;;??CT3U3U[b dIe}}^,,Z^^N5S5S,i.GV:V
;;??>5AL.:3K#t+%NN,	Y]]84d6M6MNimmD11&(nnYu5E&FIdO++I9U;KL##I:#//	:	((E:''	2**95;;??#A5II00;  '!	:611)h1OI&&y1(B334EFOos33'6&7O?FFyQUX[\kXlmo  !8!?!?O@\!]^
  /	3  / %%*04@Y0Z & \  /	3	./ E! $$% ( }}X.% % ' ' --$$% x)@%u % FD 8O==//IMM/4R4Z#GGJk)5lmn ~~g&%/&7
7#))* * F F77 $--6K{d.A.AAIPP!g.0 G3<==3FH   A% ##K0$$Y6%%i00..y(C$$)$++''--/ ,M)**0&{1K*LN #9-$-A &&vay(G-$Ii  3K=ABBk3| $$)$++''--/ , $s   4UU "VAVc                 ,    [        XR                  5      $ r  )rv   r   )r   r  s     r   _ensure_dir_existsYoutubeDL._ensure_dir_exists  s    //00r   c                 ^   U R                  S5      U R                  S5      =(       d    U R                  S5      U R                  S5      U R                  S5      U R                  S5      U R                  S5      U R                  S5      U R                  S5      U R                  S5      S	.	UEnU(       a  U$ U R                  S5      (       a0  UR                  U S   [        U S   5      [        U S   5      S
.5        0 UES[	        U R                  S5      =(       d    S5      U S   U S   S.E$ )Nplaylist_countr  r  uploaderuploader_idchannel
channel_idr$  )	rN  r  playlist_idplaylist_titleplaylist_uploaderplaylist_uploader_idplaylist_channelplaylist_channel_idplaylist_webpage_url)r$  r%  r&  r   requested_entries)r   r   r  r'  )r  r  r  r'  )r*  r  r   ro   r  )r  strictr   r  s       r   _playlist_infodictYoutubeDL._playlist_infodict  s    (mm,<=!g.E)--2E$==.'mmG4!*z!:$-MM-$@ )i 8#,==#>$-MM-$@
 
 K==''KK(7(4Y}5M(N&0=1I&J 


%(7J)K)Uv%V";/&7
 	
r   c                   ^ TS   S;   d   eU R                  TSS9nUR                  S5      =(       d    SnU R                  USS9b  gU R                  S	TS    S
U 35        [	        U T5      n[        UR                  5       SS9nU R                  R                  S5      nU(       a  / SpSu  TS'   TS'   O<[        U5      =ph[        U5      n	[        [        U6 5      =(       d    / / 4u  TS'   TS'   TR                  S5      (       d  UR                  5       TS'   U R                  T[        U	5      S9n
[        R                  " TU
5      nSnU R                  R                  SS5      nU(       a1  U R                  R                  S5      (       a  U R!                  T5        U(       a  U R                  R                  S5      (       dp  U R#                  STU R%                  US5      5      nUc  gU R'                  STU R%                  US5      5       c  gU R)                  STU R%                  US5      5        U(       aQ  U R                  R                  S5      (       d   U R                  R                  S5      (       a  U R+                  SSS9  OgU R                  R                  S5      (       a  UR-                  5         O6U R                  R                  S5      (       a  [.        R0                  " U5        U R                  STS    S U S!U	 S"[3        TSS#5       35        U R                  R                  S$5      S%:g  nU R                  R                  S$5      S&:X  a  TS   S:g  nU(       a  U R5                  S'5        S(nU R                  R                  S)5      =(       d    [7        S*5      n[9        U5       GHx  u  nu  nnU(       a  UR;                  UU45        U(       d  M-  TR                  S+5      US+'   U(       d  S,U R                  S-   ;   a  TS   U   n[        R                  " U0 UE[        U	5      UUS.-   S/.E5      nU R                  USS9b  U[<        4UU'   M  U R                  S0U R?                  US.-   U R@                  RB                  5       S1U R?                  XR@                  RD                  5       35        U RG                  UU[        R                  " UUS.-   S2.U
5      5      nU(       d  US.-  nUU:  a  U RI                  S3U S4U S535          OU(       d  GMq  UU4UU'   GM{     U VVs/ s H  u  nnU[<        Ld  M  UPM     snnTS'   U VVs/ s H  u  nnU[<        Ld  M  UPM     snnTS'   TS   [K        U4S6 j5      :X  a  TRM                  S5        USL a%  U R#                  S7TU R%                  US5      SS89 c  gU RO                  ST5      mU R                  S9U 35        T$ s  snnf s  snnf ):z"Process each entry in the playlistr  r  T)r[  r  z
<Untitled>r  Nz[download] Downloading r  )lazylazy_playlistzN/A)NNrZ  r  rN  )r  Fallow_playlist_filesrN  rM  pl_infojsonpl_descriptionpl_thumbnailplaylistreverseplaylistrandomzGplaylistreverse and playlistrandom are not supported with lazy_playlistr  r  r  z] Playlist z: Downloading z itemsz of %sr-  discarddiscard_in_playlistz>The information of all playlist entries will be held in memoryr   skip_playlist_after_errorsr  __x_forwarded_for_ipzplaylist-indexr<  r   )r  r  r  z[download] Downloading item z of )r  r  z,Skipping the remaining entries in playlist "z" since z items failed extractionc                  :   > [        [        ST S   S-   5      5      $ )Nr   rN  )r  r  )r  s   r   r  .YoutubeDL.__process_playlist.<locals>.<lambda>.  s    d5IVfLgjkLkCl>mr   zupdated playlist)	overwritez*[download] Finished downloading playlist: )(r\  r*  r  r  rU   rx   get_requested_itemsr%  r  r  tuplezipget_full_countrp   r  ChainMaprN  _write_info_jsonr  _write_description_write_thumbnailsrA  reverser  shufflerl   re  rv  r  r  rA   r{  r  rd  r  "_YoutubeDL__process_iterable_entryr   r   r  run_all_pps)r   r  r  common_infor  all_entriesr  r_  resolved_entriesr  extraie_copy_infojson_writtenwrite_playlist_fileskeep_resolved_entriesfailuresmax_failuresr  r  r  
entry_copyentry_resultr  r  s    `                      r   __process_playlistYoutubeDL.__process_playlist  s   !%@@@@--i-E
+;|[T:F071C0DBugNO%dI6[<<>TJ{{/*,eiCM@I)*Ii,@)-g6G,-ICHN^I_C`Clegikdl@I)*Ii,@}}-..*5*D*D*FI&'''	[=S'T&&y%8!#{{/EtLDKKOO4E$F$F  +
(C(C $ 5 5It'<'<Wm'T!V (&&z9'+'<'<WFV'WY\`a"":y$:O:OPWYg:hi{{011T[[__EU5V5V##$my}#~[[__.//OO[[__-..NN7#9[12+eWNS\R]]c&y2BHMNP 	Q !% ?9 L;;??>*.CC$-g$6*$D! ]^{{'CDTe*3G*<&A& ''(?@,5MM:P,QE(),M0JJ!*+>!?!B$--e 66(3"0'(1u	6 J    =I'5z&B #NN.t/B/B1q5$++../Y.Z [)))[[5I5IJKMN  88+J^J^"0'(1u` K L  A<'!!B5'RZQ[[stv$$'5|&D #K +=P /?V.>da!:BU.>V	)8H)`8H1AU_L_!8H)`	%&()X6m-nnMM-. $)>)>"I%%g}= *? *ORV*W $$Z;	CE7KL  W)`s   =W=W=#X7Xc                 "    U R                  XUS9$ )Nr9  )r   )r   r  r  r  s       r   __process_iterable_entry"YoutubeDL.__process_iterable_entry<  s    %% & = 	=r   c                   ^^^	^
 [         R                  [         R                  [         R                  [         R                  [         R
                  [         R                  S.n[        R                  " SR                  SR                  [        [        R                  UR                  5       5      5      5      5      nUR                  U5      mT(       a/   [        TR!                  S5      5      mUTR!                  S5         m	T(       Gd!  [         R
                  S S	 S
 S S.n[        R                  " SR                  SR                  [        [        R                  UR                  5       5      5      5      5      nUR                  U5      mT(       a  TR!                  S5      S:X  a&  [        R                  " TR!                  S5      5      mO'[        R&                  " SSTR!                  S5      5      mUTR!                  S5         m
TR!                  S5      (       a  U
4S jm	OT
m	T(       d  [)        SU< 35      eUUU	4S jnU$ ! ["         ak    [%        TR!                  S5      5      mTc  [%        TR!                  S5      S-   5      mTc*  [#        SR                  TR!                  S5      U5      5      e GNf = f)zFReturns a function to filter the formats according to the filter_spec )<z<=>z>==z!=z(?x)\s*
            (?P<key>[\w.-]+)\s*
            (?P<op>{})(?P<none_inclusive>\s*\?)?\s*
            (?P<value>[0-9.]+(?:[kKmMgGtTpPeEzZyY]i?[Bb]?)?)\s*
            r  r  rS  z/Invalid value {!r} in format specification {!r}opc                 $    U R                  U5      $ r  r)  attrr  s     r   r  0YoutubeDL._build_format_filter.<locals>.<lambda>b  s    $//%*@r   c                 $    U R                  U5      $ r  )r(  r  s     r   r  r  c  s    $--*>r   c                 
    X;   $ r  r=  r  s     r   r  r  d  s    %-r   c                 (    UR                  U 5      S L$ r  )r&  r  s     r   r  r  e  s    %,,t*<D*Hr   )r  z^=z$=z*=~=a"  (?x)\s*
                (?P<key>[a-zA-Z0-9._-]+)\s*
                (?P<negation>!\s*)?(?P<op>{})\s*(?P<none_inclusive>\?\s*)?
                (?P<quote>["'])?
                (?P<value>(?(quote)(?:(?!(?P=quote))[^\\]|\\.)+|[\w.-]+))
                (?(quote)(?P=quote))\s*
                r  z
\\([\\"'])z\1negationc                    > T" X5      (       + $ r  r=  )r  r  str_ops     r   r  r  v  s    1D-Dr   zInvalid filter specification c                 ~   > U R                  TR                  S5      5      nUc  TR                  S5      $ T" UT5      $ )Nr^  none_inclusive)r*  r  )rq  actual_valuecomparison_valuemr  s     r   _filter/YoutubeDL._build_format_filter.<locals>._filter}  s=    550L#ww/00l$455r   )r  ltlegtgeeqner  ru  r   r  r  rz  r{  	fullmatchrv  r  r  rz   r  SyntaxError)r   filter_spec	OPERATORSoperator_rexSTR_OPERATORSstr_operator_rexr  r  r  r  r  s          @@@@r   _build_format_filterYoutubeDL._build_format_filterA  s3    ++++++
	 zz # sxxBIIy~~/? @AB	D
 "";/	<#()9#:  1774=)B[[@>7HM  "zz + F388C		=3E3E3G$HIJ L !**;7A774=D(')zz!'''2B'C$')vv.?PWHX'Y$&qwwt}577:&&DBB =k_MNN	6
 [  <#1!'''2B#C #+'5aggg6F6L'M$#+$IPPGGG,k;< < ,	<s   I A1K Kc           	   #     #    U GH  nUR                  S5      nUb  U(       a  Uv   M%  U R                  SR                  US   5      5        U R                  S5      nU R	                  U S35      (       d  Mt  [
        R                  " SSU=(       d    S S9nUR                  5         U R                  n U R                  UR                  US	S
9u  p[        R                   R#                  UR                  5      (       a"   [        R$                  " UR                  5        O Xpl        XS'   U(       a  UR)                  SS 5        Uv   GMH  SUS    S3n
U(       a  U R'                  U
5        GMl  U R                  SU
 35        GM     g ! [        [        [        /[        Q7 a    Sn Nf = f! [         a"    U R'                  SUR                   S35         Nf = f! [        R                   R#                  UR                  5      (       aQ   [        R$                  " UR                  5        f ! [         a"    U R'                  SUR                   S35         f f = ff = f7f)N	__workingz[info] Testing format {}r   r  r*  z.tmpF)suffixdeletedirT)testz!Unable to delete temporary file "r  __needs_testingzUnable to download format . Skipping...[info] )r*  r  r   r  rK  tempfileNamedTemporaryFilerI  r|  dlr  rJ   rh  r  r%   r  r  existsremoverA  r  )r   r  r  rq  r  r  	temp_fileoriginal_retcoder0  r  r  s              r   _check_formatsYoutubeDL._check_formats  s    AeeK(G"GNN5<<Q{^LM''/D**dV1:66 336%UYUa]abIOO  $55	c!WWY^^QTWB
 77>>)..11c		)..1 2 &6"$kN'.21[>2B-P'',NNWSE?3I " "7JL9KL    # c++.OPYP^P^O__`,abc 77>>)..11c		)..1" c++.OPYP^P^O__`,abc 2s   B2I"5F.I" F/!A*I"F,)G+F,,G/)GI"GI"/I H/.I/)I	II	II"c           
          [        U" U[        S U 5       5      [        S U 5       5      =(       d    [        S U 5       5      S.5      5      $ )Nc              3   l   #    U  H*  nS UR                  S5      UR                  S5      4;  v   M,     g7f)noner   r   Nr*  r  rq  s     r   r   ,YoutubeDL._select_formats.<locals>.<genexpr>  s-     $g_fZ[VAEE(OQUU8_3U%U_fs   24c              3   H   #    U  H  oR                  S 5      S:H  v   M     g7f)r   r  Nr  r  s     r   r   r    s     &R'QuuX&'@'    "c              3   H   #    U  H  oR                  S 5      S:H  v   M     g7f)r   r  Nr  r  s     r   r   r    s     )UW%%/V*CWr  )r  has_merged_formatincomplete_formats)r  r'  r  )r   r  selectors      r   _select_formatsYoutubeDL._select_formats  sO    H!$$g_f$g!g#&&R'&R#R $V&))UW)U&U	
   	r   c                   ^ ^ T R                   S   S   S:H  =(       d8    UR                  S5      =(       a     T R                   R                  S5      (       + nU 4S jnU(       dI  U" 5       (       d=  SnT R                  U5      mUU 4S jnU" S	5      U" S
5      :w  a  T R                  S5        T R                   R                  S5      =(       d    ST R                   S   ;   nU(       a  S$ U(       a  S$ S$ )Nr  r  rW  is_livelive_from_startc                  `   > [        T5      n U R                  =(       a    U R                  5       $ r  )r1   	available	can_merge)mergerr   s    r   r  1YoutubeDL._default_format_spec.<locals>.can_merge  s'    #D)F##:(8(8(::r   Tc                 F   > TR                  TTR                  U 5      5      $ r  )r  r  )specr  r   s    r   r  0YoutubeDL._default_format_spec.<locals>.<lambda>  s    D,@,@$JdJdeiJj,kr   zb/bv+bazbv*+ba/bzffmpeg not found. The downloaded format may not be the best available. Installing ffmpeg is strongly recommended: https://github.com/yt-dlp/yt-dlp#dependenciesallow_multiple_audio_streamszformat-specr<  zbest/bestvideo+bestaudiozbestvideo+bestaudio/bestzbestvideo*+bestaudio/best)r%  r*  _get_formatsrA  )r   r  prefer_bestr  evaluate_formatscompatr  s   `     @r   _default_format_specYoutubeDL._default_format_spec  s    KK	"9-4 Ui(SAR1S-S 		; 9;;K''	2Gk	*.>z.JJ## % @ ++//"@A A"dkk-&@@ 	 /:* 	239/	20	2r   c           	      :  ^ ^^^^	^
^^^^^^^^^ U4S jmSm
Sm	SmSm[         R                  " S/ SQ5      mT R                  R                  SS	5      T R                  R                  S
S	5      S.mS mS nSUUU	U
UUUU4S jjmUU 4S jmU 4S jmUU	U
UUUUU 4S jmSR	                  [
        R                  " [        R                  SS95      m[        R                  " [        R                  " ST S3T5      R                  5       5      n [        U" U4S j[        R                  " UR                   5       5       5      5      n " S S5      nT" ['        U" U5      5      5      nT" U5      $ ! [        R"                   a    T" SS[%        T5      45      ef = f)Nc                 L   > SR                  U TSUS   -  5      n[        U5      $ )Nz)Invalid format specification: {}
	{}
	{}^r  r   )r   r  )notestartr	  format_specs      r   syntax_error5YoutubeDL.build_format_selector.<locals>.syntax_error  s0    ""(&{C%(N"K  w''r   	PICKFIRSTMERGESINGLEGROUPFormatSelector)r  r  filtersr  Fallow_multiple_video_streamsr  r  c                     / nU  HF  u  p#n  nU[         R                  :X  a  US:X  a  SR                  U5      s  $ UR                  U5        MH     g )N]r  )tokenizeOPr  r  )tokensfilter_partstype_string__startr  s         r   _parse_filter6YoutubeDL.build_format_selector.<locals>._parse_filter  sI    L06,1HKK'GsN77<00 ''0	 17r   c              3   l  #    SnSu  p#pEU  GH  u  pgpn
U[         R                  :X  a`  US:X  aZ  U(       a  [         R                  X#XE4v   S nXgXU
4v   U  H-  u  pgpn
XgXU
4v   U[         R                  :X  d  M$  US:X  d  M,    Mx     M|  U[         R                  :X  a,  Xq;   a'  U(       a  [         R                  X#XE4v   S nXgXU
4v   M  U[         R                  [         R                  [         R                  4;   d  M  U(       d	  UnUnU	nGM  X'-  nGM     U(       a  [         R                  X#XE4v   g g 7f)N)r*  r  r   (r   )NNNNr  r  )r  r  NAMENUMBER)r  ALLOWED_OPSlast_string
last_startlast_end	last_liner  r  r  r  rn  s              r   _remove_unused_ops;YoutubeDL.build_format_selector.<locals>._remove_unused_ops  s     4K;Q8KX4:0DHKK'GsN"&mm[hYY&*%d::<B8D#e$>> HKK/GsN! =C hkk)g.D"&mm[hYY&*%d::x}}hoox{{KK&&-%*
#&#.- 5;. mm[hQQ s   A3D49D4A8D4=7D4c                   > / nS nU  GH  u  pgn  n	U[        [        SS 5      :X  a  M   U[        R                  [        R                  4;   a  T" TU/ 5      nMP  U[        R                  :X  Gai  US:X  a  U(       d  U R                  5           GOdU(       a  US;   a  U R                  5           GODU(       a  US:X  a  U R                  5           GO$US:X  a%  U(       d	  T" SU5      eUR                  U5        S nM  US:X  a'  U(       d	  T" SU5      eUn
T" U SS	9nT" TX4/ 5      nGM  US
:X  a7  U(       d
  T" TS/ 5      nT" U 5      nUR                  R                  U5        GMZ  US:X  a$  U(       a	  T" SU5      eT" U SS9nT" TU/ 5      nGM  US:X  a7  U(       d	  T" SU5      eUnT" U SS9nU(       d	  T" SU5      eT" TX4/ 5      nGM  T" SU S3U5      eU[        R                  :X  d  GM    O   U(       a  UR                  U5        U$ )NENCODINGr   )r*  r   r   z!"," must follow a format selectorr*  z!"/" must follow a format selectorT)inside_choicer  bestr  zUnexpected "(")inside_groupr  zUnexpected "+")inside_mergezExpected a selectorzOperator not recognized: "r  )	rm  r  r   r  r  restore_last_tokenr  r  	ENDMARKER)r  r  r  r  	selectorscurrent_selectorr  r  r  r  first_choicesecond_choiceformat_filterr  
selector_1
selector_2r  r  r  r  r  r  _parse_format_selectionr  s                   r   r  @YoutubeDL.build_format_selector.<locals>._parse_format_selection	  s   I#/5+q!GHj$??x}}hoo>>'5fgr'J$hkk)#~+"557%'Z*?113&7c>113 C/"./RTY"ZZ!(()9:+/( C/"./RTY"ZZ'7(?VZ([+9)lEbdf+g( C//=ffb/Q,(5f(=(0077F C+"./?"GG 7T R+9%+K( C/"./?"GG%5
%<VRV%W
)"./De"LL+9%*AY[]+^(*-GyPQ+RTYZZh000e 06f    !12r   c                   >^ U u  p/ mTR                  UR                  SU45      5        TR                  UR                  SU45      5        TS   (       a
  TS   (       d  SSS.n[        T5       H  u  pEUR                  S5      UR                  S5      s=:X  a  S:X  a  O  OTR                  U5        MF  S	 HM  nTU   (       a  M  UR                  US
   S-   5      S:w  d  M,  X6   (       a  TR                  U5          M  SX6'   MO     M     [	        T5      S:X  a  TS
   $ T Vs/ s H  oUR                  S5      S:w  d  M  UPM     nnT Vs/ s H  oUR                  S5      S:w  d  M  UPM     nn[	        U5      S:X  a  US
   OS n	[	        U5      S:X  a  US
   OS n
[        U Vs/ s H  oR                  S5      PM     snU Vs/ s H  oR                  S5      PM     snU Vs/ s H  oS   PM	     snU Vs/ s H  oS   PM	     sn[        U4S j5      =(       d$    TR                  R                  S5      =(       a    SS9nU4S jnTSR                  U" S5      5      SR                  U" S5      5      USR                  [        [        T5      5      SR                  [        U" S5      5      5      =(       d    S SR                  [        U" S5      5      5      =(       d    S [        U" SS5      5      =(       d    S [        U" SSS5      5      S.	nU	(       a  UR                  U	R                  S5      U	R                  S 5      U	R                  S!5      =(       d    TR                  U	5      U	R                  S"5      U	R                  S#5      U	R                  S5      U	R                  S5      U	R                  S$5      U	R                  S%5      S&.	5        U
(       aR  UR                  U
R                  S5      U
R                  S5      U
R                  S'5      U
R                  S(5      S).5        U$ s  snf s  snf s  snf s  snf s  snf s  snf )*Nrequested_formatsr  r  F)r  r  r   r   r  r  r   codecTr   r   c                  @   > T R                   S   R                  S5      $ )Nmerge_output_formatr*  )r%  r  r5  s   r   r  AYoutubeDL.build_format_selector.<locals>._merge.<locals>.<lambda>^	  s    dkk:O.P.V.VWZ.[r   prefer_free_formats)webmmkv)vcodecsacodecsvextsaextspreferencesc                  2   >^  [        S U 4S jT 5       5      $ )Nc              3   <   >#    U  H  n[        U/TQ76 v   M     g 7fr  )r   )r  r_  r{  s     r   r   TYoutubeDL.build_format_selector.<locals>._merge.<locals>.<lambda>.<locals>.<genexpr>a	  s     2dWcPS<3Kd3KWcs   )r  )r{  formats_infos   `r   r  r  a	  s    VD2dWc2d%er   r  r   r   r   r   r   r   r   r   r   )	r  r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   )	r   r   r   r   r   r   r   r   r   r   r   )r   r   r   r   )extendr*  r  r  r  rn   r   r%  r  r  rc   rx   sumr  rt  )formats_pairformat_1format_2get_no_morer  fmt_infoaud_vid
video_fmts
audio_fmtsthe_only_videothe_only_audiorq  
output_extfilterednew_dictr+  allow_multiple_streamsr   s                  @r   _merge/YoutubeDL.build_format_selector.<locals>._merge<	  s   !-HL-@8+ NO-@8+ NO)'2:PQX:Y(->%.|%<MQ||H-h1GQ6Q$((+ #55g>>8<<PWXYPZ]dPdCeioCo*3 , 0 0 3 %37K0 $6	 &= < A%#A&3?d<x<<PXCY]cCc(<Jd3?d<x<<PXCY]cCc(<Jd.1*o.BZ]N.1*o.BZ]N+2<=*Qx*=2<=*Qx*=)34Ax4)34Ax4%&[\ ]!%1F!G![O_J fH &2((8H#56 XXh{&;<!HHS);\%JKHHZ0D%EFN$"xx
8M3J(KLTPT#&x
<M'N#O#WSW8E5%89
H +//8,00:"0"4"4\"B"ldF\F\]kFl)--e4%3%7%7%H,00:)--e4'5'9'9:K'L$2$6$6~$F
! 
 ,00:)--e4)--e4&4&8&89I&J	!  Oc ed >=44s0   &P4P4P9*P9'P>Q
'Q;Qc              3     >#    TR                   R                  S5      S:X  a  TR                  U 5       S h  vN   g TR                   R                  S5      c   TR                   R                  S5      (       a  U  S h  vN   g U  HO  nUR                  S5      (       d  UR                  S5      (       a  TR                  U/5       S h  vN   MK  Uv   MQ     g  N N] N7f)Ncheck_formatsselectedr5  r   r  )r%  r*  r  )r  rq  r   s     r   r  7YoutubeDL.build_format_selector.<locals>._check_formats	  s     {{/:=..w777++///2>{{'ABB"""55##quu->'?'?#22A3777G	  8 #
 8s5   4C CAC >C?AC 
CC C C c                 H  >^^^^	^
^^^^^^^^^ [        U [        5      (       a!  U  Vs/ s H  nT" U5      PM     snmU4S jmT$ U R                  T:X  a  T" U R                  5      mGOU R                  T:X  a+  U R                   Vs/ s H  nT" U5      PM     snmU4S jmGOU R                  T:X  a#  [	        TU R                  5      u  mmUUU4S jmGOU R                  T:X  Gaw  U R                  =(       d    SmTS:X  a  U4S jmGOTTS:X  a	  UU4S jmGOES	u  m	mmm
[
        R                  " S
T5      nUb  [        UR                  S5      SS9m
UR                  S5      S   S:H  mUR                  S5      =(       d    S /S   mSSS.R                  T5      mUR                  S5      S LnT(       + =(       a    U(       + m	T(       a  U(       a  U4S jOT(       a  U4S jOU(       d  S OS mU4S jmOZTTR                  S   ;   a  U4S jmO@TTR                  S   ;   a  U4S jmU4S jmO TTR                  S    ;   a  U4S! jmOU4S" jmUUU	U
UU4S# jmU R                   Vs/ s H  nTR                  U5      PM     snmUU4S$ jnU$ s  snf s  snf s  snf )%Nc              3   D   >#    T H  nU" U 5       S h  vN   M     g  N	7fr  r=  )ctxrq  fss     r   selector_function\YoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.selector_function	  s      #$S6))  )s    
 c                 R   > T H  n[        U" U 5      5      nU(       d  M  Us  $    / $ r  r  )rD  rq  picked_formatsrE  s      r   rF  rG  	  s,    )-af)>#11   Ir   c              3   v   >#    [         R                  " T" U 5      T" U 5      5       H  nT" U5      v   M     g 7fr  )	itertoolsproduct)rD  pairr<  r  r  s     r   rF  rG  	  s0      ) 1 1*S/:c? S$Tl* !T   69r  r  c              3   D   >#    T" U S   S S S2   5       S h  vN   g  N7f)Nr  r  r=  )rD  r  s    r   rF  rG  	  s!     #1#i.22F#GGGs     mergeallc              3      >#    [        T" S U S    5       5      5      nU(       d  g US   nUSS S2    H  nT" X#45      nM     Uv   g 7f)Nc              3   |   #    U  H2  oR                  S 5      S:w  d  UR                  S5      S:w  d  M.  Uv   M4     g7f)r   r  r   Nr  r  s     r   r   oYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.selector_function.<locals>.<genexpr>	  s8      6q'5!xF9RVWV[V[\dVeioVoAA~s   -<	<r  r  rI  )rD  r  merged_formatrq  r  r<  s       r   rF  rG  	  sb     "&~ 6q'*9~6q (q #r&"(/!(RA,2M3E,FM "1++s   AA	)FNTr   zS(?P<bw>best|worst|b|w)(?P<type>video|audio|v|a)?(?P<mod>\*)?(?:\.(?P<n>[1-9]\d*))?$r  r   r  bwr   br  r  r  )r  r  modc                 2   > U R                  T S35      S:g  $ Nr  r  r  )rq  format_types    r   r  SYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.<lambda>	  s    quu}E-B'Cv'Mr   c                 2   > U R                  T S35      S:H  $ r[  r  )rq  not_format_types    r   r  r]  	  s    AEE_4EU2K,LPV,Vr   c                 `    U R                  S5      S:g  =(       a    U R                  S5      S:g  $ Nr   r  r   r  rq  s    r   r  r]  	  s(    AEE(Ov,E,c!%%PX/]cJc,cr   c                     gNTr=  rb  s    r   r  r]  	  s    4r   c                    > T" U 5      =(       a/    U R                  S5      S:g  =(       d    U R                  S5      S:g  $ ra  r  )rq  	_filter_fs    r   r  r]  	  s7    Yq\ .TEE(Ov5RxF9R.Tr   r  c                 b   > U R                  S5      T:H  =(       a    U R                  S5      S:g  $ )Nr   r   r  r  rq  r  s    r   r  r]  	  s-    u1L1jQRQVQVW_Q`djQj1jr   r  c                    > U R                  S5      T:H  =(       a/    U R                  S5      S:g  =(       a    U R                  S5      S:g  $ Nr   r   r  r   r  rh  s    r   r  r]  	  V    u1L  2IQRQVQVW_Q`djQj  2Iopototu}o~  CI  pI  2Ir   c                 b   > U R                  S5      T:H  =(       a    U R                  S5      S:g  $ )Nr   r   r  r  rh  s    r   r  r]  	  s-    !%%,+:U:sZ[Z_Z_`hZimsZs:sr   r  c                    > U R                  S5      T:H  =(       a/    U R                  S5      S:H  =(       a    U R                  S5      S:H  $ rj  r  rh  s    r   r  r]  	  rk  r   c                 ,   > U R                  S5      T:H  $ )Nr   r  rh  s    r   r  r]  	  s    {1C{1Rr   c              3     >#    [        U S   5      nTb  [        [        TU5      5      OUnU(       dN  T(       a!  U S   (       a  [        [        S U5      5      nO&T(       a  U S   (       d  [        [        TU5      5      n[        T" US S T(       a  SOS2   5      5      n UTS-
     v   g ! [        R                   a     g f = f7f)Nr  r  c                 `    U R                  S5      S:g  =(       d    U R                  S5      S:g  $ ra  r  rb  s    r   r  nYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.selector_function.<locals>.<lambda>	  s-    hSY@Y@v]^]b]bck]lpv]v@vr   r  r  r   )r  r  rQ   r  )	rD  r  matchesr  filter_fformat_fallback
format_idxformat_reverseseperate_fallbacks	      r   rF  rG  	  s     "&s9~"6EMEY$vh'@"A_f&.37K3L +/v6vx  0A  +B!23?R;S*.v6G/Q*R"*>'B_.B^_B_:`+a"b#")*q."99'22 #"#s*   BC"
B- ,C-CCCCc                 p   > [        U 5      nT H  n[        [        X!S   5      5      US'   M     T" U5      $ )Nr  )r  r  r  )rD  ctx_copyr  r  rF  s      r   final_selectorYYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.final_selector	  s:    9&G*.vg	?R/S*THY'  '(22r   )r  r  r  r  r  r  r  rp   r  r*  _format_selection_extsr  r  )r  r  r  format_modifiedrq  rz  rf  rs  r  rt  ru  rv  r  r\  rE  r_  r  r  rF  rw  r  r  r  r  _build_selector_functionr  r<  r   s         @@@@@@@@@@@@@@r   r~  AYoutubeDL.build_format_selector.<locals>._build_selector_function	  s   (D));CD8a.q18D* )(%'$<X=N=N$O!)+;C;L;LM;La.q1;LM %'),-ExGXGX)Y&
J+ + &(&//96 %'H J., , VjRO%6
88n#%D '%0C!%L
)-D)9!)<)C'+zz&'9'CdVQ&G03#*>*B*B;*O*.**U*;4*G.9/*Q/>Q  + N  + #W $3 #d!/ "$T '$*E*Eg*NN'jH(D,G,G,PP (IH0s-(D,G,G,VV (IH'RH# #$ >F=M=MN=Mt003=MNG3
 "!Q E Nl Os   JJ.Jr  r  r  z\d[_\d]*z\g<0>c              3   v   >#    U  H.  nUR                  UR                  R                  TS 5      S9v   M0     g7f)r  )r  N)_replacer  r  )r  tokenr^  s     r   r   2YoutubeDL.build_format_selector.<locals>.<genexpr>
  s5      -A?E ell&:&:62&FG?rO  z/Missing closing/opening brackets or parenthesisr   c                   0    \ rS rSrS rS rS r\rS rSr	g)6YoutubeDL.build_format_selector.<locals>.TokenIteratori
  c                     Xl         SU l        g )Nr   )r  counter)r   r  s     r   r  ?YoutubeDL.build_format_selector.<locals>.TokenIterator.__init__
  s    $ r   c                     U $ r  r=  r5  s    r   __iter__?YoutubeDL.build_format_selector.<locals>.TokenIterator.__iter__
  s    r   c                     U R                   [        U R                  5      :  a  [        eU R                  U R                      nU =R                   S-  sl         U$ Nr   )r  r  r  StopIteration)r   r  s     r   __next__?YoutubeDL.build_format_selector.<locals>.TokenIterator.__next__
  sB    <<3t{{#33''DLL1!r   c                 .    U =R                   S-  sl         g r  )r  r5  s    r   r  IYoutubeDL.build_format_selector.<locals>.TokenIterator.restore_last_token
  s    !r   )r  r  N)
r;  r<  r=  r>  r  r  r  r  r  r?  r=  r   r   TokenIteratorr  
  s    ! D"r   r  )FFF)r  
namedtupler%  r*  r  r  r  r  r  ioBytesIOr  r  r  r  r  r  
TokenErrorr  iter)r   r  r  r+  r  r  parsed_selectorr  r  r  r  r  r~  r  r<  r  r  r;  r^  r  s   ``     @@@@@@@@@@@@@r   r  YoutubeDL.build_format_selector  sv   	(  	$//0@Bab+/;;??;Y[`+a+/;;??;Y[`+a"c	1	R>8	 8	tH	T	j	" j	"` (<(<CDBFF;F850A;OVVXY	i, -A%..v?-A A BF	" 	"( 2$}V7L2MN'881 "" 	iPSTVYZeVfRghh	is   9E1 1)Fc                 B   [        U R                  S   UR                  S5      5      n[        U5        U(       aA  U R	                  UR                  S5      US   S9  U R	                  UR                  S5      SS9  UR                  SS 5        U R                  R                  US   5      nU(       GaI  [        5       n/ nU GH"  nUR                  UR                  5      u  pUR                  UR                   SU	 35        UR                  (       a  UR                  SUR                   35        UR                  (       a  UR                  S	UR                   35        UR                  (       a  UR                  S
5        UR                   (       a  UR                  SUR                    35        UR"                  (       d  GM  UR                  SUR"                   35        GM%     SR%                  U5      US'   SU;  a  UR                  S5      n
U
(       a  XS'   U$ )Nr   r>  r   r  r   Fr  zDomain=zPath=SecurezExpires=zVersion=z; zX-Forwarded-Forrj  )r   r%  r*  r   r  r  rC  get_cookies_for_urlr   value_encoder  r  r  r  r  r  r  r  r  )r   r  r	   r  r   encoderr  r  r  r  x_forwarded_for_ips              r   _calc_headersYoutubeDL._calc_headers%
  s   T[[8)--:WXcswwx0Ie<LMy}}Y75I 	$..44Yu5EF)+GF!"//=Qug67==MMGFMM?";<;;MME&++"78==MM(+>>MMHV^^,<"=>>>>MMHV^^,<"=> " $(99V#4Ii C'!*/E!F!);%&
r   c                 Z    U R                  S5        U R                  R                  U5      $ )NzN"YoutubeDL._calc_cookies" is deprecated and may be removed in a future version)ra   rC  get_cookie_header)r   r   s     r   _calc_cookiesYoutubeDL._calc_cookiesI
  s&      !qr~~//44r   c                 $    UR                  S S9  g )Nc                 F   U R                  S5      b  U R                  S5      OSU R                  S5      b  U R                  S5      OSU R                  S5      b  U R                  S5      OSU R                  S5      b  U R                  S5      OSU R                  S5      4$ )Nr   r  r   r   r  r  r   r  )ts    r   r  ,YoutubeDL._sort_thumbnails.<locals>.<lambda>N
  s|    #$55#6#BAEE,eeGn8AEE'Nb uuX:AEE(O55;2AEE$KEE%L'r   r^  )sort)r   
thumbnailss     r   _sort_thumbnailsYoutubeDL._sort_thumbnailsM
  s      	r   c                 *  ^  UR                  S5      nUc"  UR                  S5      nU(       a
  SU0/=US'   nU(       d  g U 4S jnT R                  U5        [        U5       Hr  u  pVUR                  S5      c  [        U5      US'   UR                  S5      (       a&  UR                  S5      (       a  SUS   US   4-  US	'   [	        US   5      US'   Mt     T R
                  R                  S
5      SL a  [        U" US S S2   5      SS9US'   g X!S'   g )Nr  	thumbnailr   c              3     >#    U  H<  nTR                  SUS    35         TR                  [        US   5      5        Uv   M>     g ! [         a-  nTR                  SUS    SUS   < SU S35         S nAMs  S nAff = f7f)Nz[info] Testing thumbnail r  r   z&[info] Unable to connect to thumbnail z URL r  r  )r  urlopenr   r%   )r  r  r  r   s      r   check_thumbnails8YoutubeDL._sanitize_thumbnails.<locals>.check_thumbnails^
  s     !:1T7)DELLQuX!67    * NN%KAdG9TYZ[\aZbYeehilhmmz#{|s-   BA	B
A>"A93B9A>>Br  r   r   %dx%dr   r?  Tr  rv  )r*  r  r  r&  r   r%  rQ   )r   r  r  r  r  r  r  s   `      r   rC  YoutubeDL._sanitize_thumbnailsU
  s   ]]<0
!k2I9>	8J7KK	,'*	 	j)j)DAuuT{"a&$uuW~~!%%//")QwZ8,E"E,#AeH-AeH * ;;???+t3&./?
4R4@P/Q[_&`Il#&0l#r   c                 r  ^ U(       af  TR                  S5      =nTS'   U(       dI  US:X  a  U R                  S5        OU R                  S5        TS   R                  SS5       S	TS
    3TS'   TR                  S5      b  [	        TS   5      TS'   S H>  u  pETR                  U5      b  M  TR                  U5      c  M-  [        TU   5      TU'   M@     TR                  S5      (       d  [        TSS 145      TS'   SnTR                  S5      nUcS  U H1  nTR                  U5      SL a  M  TR                  U5      (       a  Un  O   [        U4S jU 5       5      (       a  SnU(       a)  UTS'   U H  nTR                  U5      b  M  Xx:H  TU'   M      US:X  a  STS'   S HY  n	U(       d  M  TR                  U	 S35      c  M#  TR                  U	5      (       a  M;  SU	R                  5       TU	 S3   4-  TU	'   M[     U R                  R                  5        H  u  pUT;   a*  U
T;   a$  ST;  a  U R                  SU
< SU< S35        M3  M5  TR                  U
5      =n(       a  UR                  S 5      TU'   Mc  TR                  U5      =n(       d  M}  S R                  S! U 5       5      TU
'   M     g )"Nr  	fulltitler  z4Extractor gave empty title. Creating a generic titlezDExtractor failed to obtain "title". Creating a generic title insteadr  r  rW  z video #r  r   r  ))r   r  )r   release_date)modified_timestampmodified_dater   r  c                     [        U S S 5      $ )NrM  )r  r  s    r   r  /YoutubeDL._fill_common_fields.<locals>.<lambda>
  s    \_`abdcd`e\fr   )r  was_liver  Fc              3   J   >#    U  H  nTR                  U5      S L v   M     g7fFNr  )r  r^  r  s     r   r   0YoutubeDL._fill_common_fields.<locals>.<genexpr>
  s     D)39==%.)s    #not_live	post_liveTr  )chapterseasonepisode_numberz%s %d_versionzDo not return z when z is presentrJ  c              3   D   #    U  H  oR                  S S5      v   M     g7f)r   u   ，Nr  )r  r  s     r   r   r  
  s      .h^gYZyy>S/T/T^gs    )r*  re  rA  r  rm   r   r   r  
capitalize_deprecated_multivalue_fieldsr  ra   r  r  )r   r  finalr  ts_keydate_key	live_keysr  r^  r  old_keynew_key	old_value	new_values    `            r   r>  YoutubeDL._fill_common_fieldsu
  s   -6]]7-CCEIk*B;$$%[\''(no(1+(>(F(FsC(P'QQYZcdhZiYj%k	'"==$0+8:9N+OI'(!
F
 }}X&.9==3H3T&6y7H&I	(#!
 }}^,,(4YRfQg@h(iIn%+	mmM2 ==%.==%%"%K ! D)DDD('2Im$ ==%-&1&8IcN ! +%$(Ij! 6Eu%'89Eimm\aNbNb#*e.>.>.@)ugU\L]B^-_#_	%  6 !% B B H H JG)#9(<Y.,,~g[wkYd-ef /'mmG444%.__T%:	'"'mmG444%)YY.h^g.h%h	'" !Kr   c                 X    UR                  SS 5      nU(       a  U R                  USS9  g g )Nr  Fr  )r  r   )r   r  r  s      r   r@  YoutubeDL._raise_pending_errors
  s.    hh($/ce, r   c                     U R                  U5      nUR                  [        XR                  S5      =(       d    / 5      R                  S9  g )N_format_sort_fieldsr  )r  r  rN   r*  calculate_preference)r   r  r  s      r   sort_formatsYoutubeDL.sort_formats
  sC    ##I.-- 56<">>R>R 	 	Tr   c                 J  ^ ^^1^2^3 TR                  SS5      S:X  d   eT =R                  S-  sl        ST;  a  [        STS   S9eTR                  S5      (       d  [        STS   S9eU 4S	 jm2U24S
 jm3U2U 4S jnT3" TS5        U" T5        TR                  S5      (       a*  TR                  S5      b  [        TS   TS   -
  S5      TS'   TR                  S5      =(       d    SS::  a(  TR	                  SS 5      (       a  T R                  S5        TR                  S5      =(       d    / nU(       a-  US   R                  S5      (       a  UR                  SSS05        STR                  S5      S.n[        [        U/UQ7U/ USS  QUP75      S5       Hz  u  nu  pxn	UR                  S5      c  UR                  S5      US'   UR                  S5      (       d  U	R                  S5      US'   UR                  S5      (       a  Mq  SU S3US'   M|     ST;  a
  S TS'   S TS'   T R                  T5        TR                  S5      n
TR                  S5      nU
(       a  [        U
5      TS'   OU(       a  US   S   TS'   TR                  S5      c  ST;   a  TS   TS'   T R                  T5        S  H  nTR                  U5      nU(       d  M  UR                  5        Hh  u  pU H]  nUR                  S5      (       a  [        US   5      US'   UR                  S!5      b  M>  [        US   5      R                  5       US!'   M_     Mj     M     TR                  S"5      nTR                  S#5      nT R                  TS   UU5      TS$'   T R!                  T5      nU=(       d    0 /S   R	                  S%S 5      nU(       a  UTS&'   [#        S' U 5       5      =(       d    S TS('   T R$                  R                  S)5      (       d3  U Vs/ s H&  nUR                  S*5      (       a  US*   S+:X  d  M$  UPM(     nnU(       aE  ['        S, U 5       5      (       a.  T R                  TS(   (       a  S-OS. S/3R)                  5       5        TR                  S05      (       + =(       d$    [+        T R$                  R                  S15      5      nU(       d;  TS==   S2[,        R.                  R1                  5       R3                  S35      -   -  ss'   TR                  S05      (       aW  U(       aP  U Vs/ s H%  n[+        UR                  S45      5      U:X  d  M#  UPM'     nnU(       a  U(       d  T R5                  TS5S69  U3U 4S7 jn[7        [9        UU=(       d    / 5      5      nU(       d  T R5                  T5        U GH~  m1T3" T1S85        U" T15        [        T1S   5      T1S'   [:        R<                  " T15        T1S!   S9;   a  T1R                  S:5      c  T1S!   T1S:'   T1R                  S;5      c  T R?                  T1S S<9T1S;'   T1R                  S=5      c  T1R                  S>5      S?:w  a  S@T1S='   T1R                  SA5      c  [A        U14SB j5      T1SA'   SCT R$                  SD   ;   d  T1R                  SE5      (       dY  T1R                  SF5      (       dC  T1R                  SG5      (       d-  [C        T1R                  SH5      TR                  S5      5      T1SG'   T RE                  [F        RH                  " T1T5      SISJ9T1SK'   GM     TR                  SK5      (       a&  [K        TSK   5      TSK'   TSK   R	                  SLS 5        SMT;   a  TSM	 T RM                  UTR                  S&5      SN.5        0 n[        U5       Hm  u  nm1T1R                  S85      (       d  [O        U5      T1S8'   O[P        RR                  " SOSPT1S8   5      T1S8'   URU                  T1S8   / 5      RW                  T15        Mo     [Y        [Z        R\                  " T R^                  Ra                  5       6 5      nUR                  5        H  u  nn[c        U5      S:  n[        U5       H  u  nm1U(       a
  U SQU 3T1S8'   T1S8   T1S!   :w  a   T1S8   U;   a  SRRe                  T1S8   5      T1S8'   T1R                  SS5      b  MW  STRe                  T1S8   T R?                  T15      [g        T1SUSV5      SW9T1SS'   M     M     T R$                  R                  SX5      SIL a  [i        T Rk                  US S S2   SYSZ9SIS[9nU(       a  US   TLa  UTS\'   T Rm                  T5      u  mnT Ro                  TT Rp                  S]9b  T$ T Rs                  T5        T Rm                  TS^5      u  mnT R!                  T5      nT R$                  R                  S_5      S`:H  nU(       + =(       a    T Rt                  SQ:H  nT R$                  R                  Sa5      (       a  T Rw                  T5        T R$                  R                  Sb5      (       a2  S"T;   a  T Ry                  TS   USc5        T Ry                  TS   US#5        T R$                  R                  Sd5      (       d  U(       a  T R{                  T5        U(       a  T R}                  T5        T$ T Rt                  n  U(       at  [        T R                  SeT R                  R                  5      Sf-   T R                  SgT R                  R                  5      -   5      n! U!(       a  T R                  U!5      OS n U c6  T R                  T5      n!T R                  SiU! 35        T R                  U!5      n T R                  UU 5      n#U(       a  U#(       d  T R                  SjSYSYSh9  M   U#(       dF  T R$                  R                  Sk5      (       d  [        SlSITS   TS   Sm9eT R                  Sj5        0 /n#[        T R$                  R                  SnSo 5      " TT 5      5      n$U#S   / n&n%U(       Gap  U%(       aO  U$(       aH  UU 4Sp jn'U'" Sq[c        U#5       Sr3Ss U# 5       5        U$0 4:w  a  U'" Sq[c        U$5       St3Su U$ 5       5        SYn([Z        R                  " U#U$5       GH  u  m1n)T R                  T5      n*U*R                  T15        TR                  S5      =(       d    STR                  S5      =(       d    [        Sv5      n,n+U+[        U)R                  SU,5      U,5      -   n-U-[        Sv5      :X  d  U-U+U,-   S-   :  a  S n-U)(       d  U+(       aG  U*R                  U+U)R                  SS5      -   U-U)R                  S5      U)R                  Sw5      Sx.5        U&RW                  U*5         T R                  U*5        T R                  U*5        [        U*R                  5       5       H.  u  n.n/TR                  U.5      U/:X  d  M  U*R	                  U.5        M0     U((       d  GM    O   U& Vs1 s H  nUR                  SySY5      iM     n0nU0R                  1 Szk5      (       d   eSIU0;   a  SYU0;  a  T R                  T5        U&TS{'   T R                  S|T5      mU((       a  [        eTR                  U%5        T$ s  snf s  snf ! [         a  n"T R                  U"SYSYSh9   S n"A"GM!  S n"A"ff = f! [         a    SIn( GN=f = fs  snf )}Nr  r  r   r  z&Missing "id" field in extractor resultr  )r  zExtractor failed to obtain "id"c           	      <   > TR                  SU  SU SU S35        g )Nr  z" field is not z - forcing z+ conversion, there is an error in extractor)rA  )r  	field_notrG  r   s      r   report_force_conversion?YoutubeDL.process_video_result.<locals>.report_force_conversion
  s/    E7/)K
| L1 12r   c                    > U R                  U5      nUb  [        U[        5      (       a  g T" USS5        [        U5      X'   g )Nza stringr  )r*  r  r&  )r  string_fieldr  r  s      r   sanitize_string_field=YoutubeDL.process_video_result.<locals>.sanitize_string_field
  s=    HH\*E}
5# 6 6#L*hG!$UDr   c                    > TR                    HK  nU R                  U5      nUb  [        U[        [        45      (       a  M4  T" USS5        [        U5      X'   MM     g )Nnumericr  )_NUMERIC_FIELDSr*  r  r  rv  rp   )r  numeric_fieldr  r  r   s      r   sanitize_numeric_fields?YoutubeDL.process_video_result.<locals>.sanitize_numeric_fields
  sR    !%!5!5/=JusEl$C$C'y%H&1%&8# "6r   r4  r5     r   r   z<"duration" field is negative, there is an error in extractorchaptersr   )r   r   r   r  z<Untitled Chapter r  r  r  r  r  r  r   
display_id)	subtitlesautomatic_captionsr   r  r  requested_subtitles__sort_fieldsr  c              3   `   #    U  H$  oR                  S 5      =(       a    US    S:g  v   M&     g7f)r   maybeNr  r  s     r   r   1YoutubeDL.process_video_result.<locals>.<genexpr>  s,      $KBIQEE)89!88's   ,.r  r5  r   r  c              3      #    U  H7  oR                  S 5      UR                  S5      s=:H  =(       a    S:H  Os  v   M9     g7f)r   r   r  Nr  r  s     r   r   r    s0     YQXA55?aeeHoGGGGQXs   ?Az This video is DRM protected and r  zFonly images are available for download. Use --list-formats to see themr  r  r  z%Y-%m-%d %H:%Mr   z--live-from-start is passed, but there are no formats that can be downloaded from the start. If you want to download from the current time, use --no-live-from-startr  c                    > U R                  S5      nU(       d  TR                  S5        g[        U[        5      (       a	  T" U S5        g)Nr   zQ"url" field is missing or empty - skipping format, there is an error in extractorFT)r*  rA  r  ra  )rq  r   r  r   s     r   is_wellformed5YoutubeDL.process_video_result.<locals>.is_wellformed*  sE    %%,C##56 #u%%%a/r   r   )aacopusmp3flacvorbisr   r   r  r   r   r  SDRr   c                  .   > [        T S   T S   -  S5      $ )Nr   r   r  )r  )r_  s   r   r  0YoutubeDL.process_video_result.<locals>.<lambda>H  s    uS\CPXM=Y[\7]r   zmanifest-filesize-approxr<  r   r   r   r   T)r	   r   r>  rj  )r  r  z[\s,/+\[\]()]r  rW  f{}r   z{id} - {res}{note}r   r  )r  r  r  r?  F)r  r  r  r  after_filterrM  rQ  rN  rP  zautomatic captionsrO  z
Enter format selector z,(Press ENTER for default, or Ctrl+C to quit)r  r
  zDefault format spec: z!Requested format is not availabler  zURequested format is not available. Use --list-formats for a list of available formats)r  r  r  download_rangesc                      0 /$ r  r=  )r  s    r   r  r    s    PRtr   c            	      f   > TR                  STS    SSR                  S U  5       5       35        g )Nr  r  r  r  c              3   V   #    U  H  nS R                  [        U5      5      v   M!     g7f)rJ  N)r  r   )r  r  s     r   r   DYoutubeDL.process_video_result.<locals>.to_screen.<locals>.<genexpr>  s&     HmildeS[\]S^I_I_ils   '))r  r  )r  r  r   s    r   r  1YoutubeDL.process_video_result.<locals>.to_screen  s2    NNWYt_,=RHmilHm@m?n#opr   zDownloading z format(s):c              3   *   #    U  H	  oS    v   M     g7f)r   Nr=  r  s     r   r   r    s     G3Fa[>3F   z time ranges:c              3   >   #    U  H  oS    S SUS   S 3v   M     g7f)r   z.1frW  r   Nr=  )r  r[  s     r   r   r    s*     fUePQL/#!6a*c7JKUes   r  index)r5  r4  section_titlesection_number__write_download_archive>   FTrl  requested_downloadsafter_video)Ur*  r~  rM   r  r  rA  insertr  rp  rC  r   r>  r  rb   r  process_subtitlesr  r'  r%  r  r  r  dtdatetimenowstrftimer  r  r  rN   _fill_sorting_fieldsrt  r   r   r  r  rr  r   r  r&  r  r  r  r  rd  rL  chainr|  r  r  r   rl   rQ   r  r=  r  _format_fieldspost_extractr  rN  list_subtitleslist_formatsr?  r  r{  r  r  r  r  r   r  re  r  ro  rM  r  r  rv  r  process_inforR   r@  issubsetrA  ry  )4r   r  r  r  r  dummy_chapteridxprevcurrentnext_r  r  cc_kindccr  subtitlesubtitle_formatr  r  r  field_preferencerq  get_from_startr  formats_dictr  common_extsr   ambiguous_formatsambigious_idrQ  interactive_format_selectionr  
req_formatr  formats_to_downloadrequested_rangesbest_formatdownloaded_formatsr  max_downloads_reachedr  new_infor  r   r   r^  valwrite_archiver_  r  r  s4   ``                                               @@@r   rB  YoutubeDL.process_video_result
  sL   }}Wg.'999Ay  !IiXcNdeet$$ !ByQ\G]^^	2
	,	9 	i.	*==''IMM/,J,V$))M*BYE_*_ab$cIj!MM*%*q0Y]]:t5T5T ^_==,255OOAa01%&immJ6OP+4S**H6T6Tm6T6VWX,Z'C'${{<(0(,(<%;;z**&+ii&=
#;;w''%7uA#> ,Z Y&$(Ij!*.I&'!!),MM+.	]]<0
%1)%<Ik"%/^E%:Ik"==&.493D&/oIl#  +:Gw'Br#%88:KA+3*..u555A/RWBX5YOE2*..u5=5B?SXCY5Z5`5`5bOE2	 ,4 $. ; ']]+?@MM+.	+/+A+AdOY(:,<	'( ##I. $OtQ/33OTJ/?I+, # $KBI$K !K !SNR 	*{{9::")]'Qy1A1AQy\U\E\q'G]sYQXYYY9B:9N5TVWXYYcYcYeg ']]955adkkooN_>`9ag#(9(B(BCS(T"TT==##")\'QT!%%2H-I^-[q'G\g%%i^ & `		 vmW];<!!),C!#{3#C(%c%j1CJ--c25zEE778$,$'JCMww|$,$($:$:3$:$ML!ww'/CGGH4E4O',O$ww~&.&./]&^N#+t{{=/IIQTQXQXYgQhQhGGJ//@Q8R8R):3775>9==YcKd)e%&"&"4"4[5I5I#y5Yhl"4"mC% * ==(((6y7P(QIn%n%))(D9 "Y.01#,==1F#G
 	 (FAs77;''#&q6K  $&66*:C[AQ#RK ##C$4b9@@E ) )//4+F+F+M+M+OPQ,8,>,>,@(I(01A5L#$563*3AaS'9C$ {#s5z1c+6F+6U',||C4D'EC$778$,$8$?$?{+ 2237)#}gF %@ %CM 7 -A" ;;???+t3t2274R4=%2PZ^_G'!*I5
 $+Ii ''	2	1Y43F3FGS)$''	>B	1 ##I.KKOOJ/;>	+4}'T9M9MQT9T$;;??,--  +;;???++#y0##dO%79MO	$KH;;??=))-Ii(##I...+"4#6#67QSWS^S^SgSg#h%S$T%)%8%8t{{?S?S%T$U V
PZd&@&@&L`dO
 &!66yA
  #8!EF"&"<"<Z"H"&"6"6w"P+4G!!"E%Z_!`";;??#<==$k!IdO	+@VX X  CD#%$ 1BO!TU^`d!ef*=b*A2'/q L-@)A(B+NG3FGI#v-S1A-B,C=QfUefh$)! ) 1 12EGW XW..y9$#,==#A#FQ	V`HaHqejkpeq!CJ(I8$TTuU|+x&8:Ka:O/O#HfOO)/'++lA2N)N'/)0W)=*1++g*>	%  #))(31%%h/ **84 %hnn&6 7HC }}S)S0 S) !8 )(5 !Y8 PbbOa!QUU#=uEOaMb ))*ABBBB}$m)C,,Y7/AI+,((	BI$)) 	%y ^ ]F # %%cee%Dp + 1,0)1 csH   
#{1{)"{{{# || #
|
-||
||c                   ^ 0 / pTU(       aJ  U R                   R                  S5      (       a*  UR                  U5        [        UR	                  5       5      nU(       aD  U R                   R                  S5      (       a$  UR                  5        H  u  pgXd;  d  M  XtU'   M     U(       a@  U R                   R                  S5      (       d!  U R                   R                  S5      (       d  g[        UR	                  5       5      nU R                   R                  SS5      (       a  Un	OU R                   R                  SS5      (       a(   [        U R                   R                  S5      SU0SS	9n	ON[        [        R                  " SU;   a  S/O/ [        S U5      SU;   a  S/O/ [        S U5      XX5      5      SS n	U	(       a&  U R                  SU SSR!                  U	5       35        U R                   R                  SS5      nU(       a  UR#                  S5      O/ n0 nU	 H  nUR                  U5      nUc  U R%                  U SU 35        M/  U H7  mTS:X  a  US   n  OT['        [        U4S jU5      5      nU(       d  M2  US   n  O+   US   nU R%                  SR)                  XUS   5      5        XU'   M     U$ ! [        R                   a  n
[        S
U
R                   35      eSn
A
ff = f)z/Select the requested subtitles and their formatwritesubtitleswriteautomaticsubNallsubtitlesFsubtitleslangsr  Tr  zWrong regex for subtitlelangs: enc                 $    U R                  S5      $ NrA  r  rb  s    r   r  -YoutubeDL.process_subtitles.<locals>.<lambda>      d!3r   c                 $    U R                  S5      $ rC  r  rb  s    r   r  rD    rE  r   r   r  z: Downloading subtitles: rJ  subtitlesformatr  r*  z subtitles not available for r  c                    > U S   T:H  $ )Nr   r=  )rq  r   s    r   r  rD  '  s    %Cr   zsNo subtitle format found matching "{}" for language {}, using {}. Use --list-subs for a list of available subtitlesr   )r%  r*  r  ro  r{  r  ry   r  r   r  r  rQ   rL  r  r  r  r  r  rA  r  r   )r   r  normal_subtitlesr  available_subsnormal_sub_langslangcap_infoall_sub_langsrequested_langsr  formats_queryformats_preferencesubsr  rq  rr  r   s                    @r   r  YoutubeDL.process_subtitles  s   +-r(0@ A A!!"23$%5%:%:%<=$++//2E"F"F"4":":"<-+34( #= KKOO$455(;<<n1134;;??>511+O[[__-u55P"9KKOO$45}7MY]#_
 'y"2235EF-/R3]C (  O NNWXJ.G		RaHbGcde(96B9F]005B#D$((.G##tf,I($TU)&=Av&?IJ7A * BK##RRXRXYfnopunvRwy J% $& G 88 P #B199+!NOOPs   &K K4K//K4c                 ~   Uc  g UR                  5       nUR                  SU R                  U5      5        UR                  S5      b  SR	                  S US    5       5      US'   O1UR                  S5      (       a  US   UR                  SS5      -   US'   U R                  U5      US	'   U R                  U5      US
'   U R                  UR                  S5      UR                  S5      5      US'   U R                  UR                  S5      UR                  S5      5      US'   S nU R                  S   R                  U/ 5       H*  nU R                  U R                  U" U5      U5      5        M,     U R                  S   R                  U/ 5       H  u  pVU R                  X&S9nU" U5      nU R                  SU< SU 35        U R                  U5      (       d  ML  [        USSSS9 nUR                  U R                  XS5      [        R                   -   5        S S S 5        M     U$ ! , (       d  f       M  = f)Nr  r  r3  c              3   P   #    U  H  oS    UR                  SS5      -   v   M     g7f)r   r   r  Nr  r  s     r   r   (YoutubeDL._forceprint.<locals>.<genexpr>:  s%     )tUsPQE(QUU;5K*KUss   $&urlsr   r   r  formats_tablethumbnails_tabler  r  subtitles_tabler  automatic_captions_tablec                 `   [         R                  " SU 5      nU(       d  U $ SnU R                  S5      (       a  SU  3Sp U R                  S5      (       a  U S S Sp S	R	                  [        UR                  UR                  S
5      (       a  U /5      5      $ U R                  S5      5      5      $ )Nz+([\w.:,]|-\d|(?P<dict>{([\w.:,]|-\d)+}))+=?z%({})sr	  r
  z%({})jr  r  z{0} = %({0})#jr3  r  r   )	r  r  r)  r(  r  r  r   r  r  )tmplr  r_  s      r   format_tmpl*YoutubeDL._forceprint.<locals>.format_tmplB  s    << NPTUDCs##vJc}}S!! "I'7c99Stzz&7I7IdV_``tzzZ]_``r   rR  rS  r  [info] Writing  to: r  ra  rc  newline)r  r  r  r*  r  render_formats_tablerender_thumbnails_tablerender_subtitles_tabler%  r  r  r  rK  openr  r  linesep)	r   r^  r  rG  r^  r]  	file_tmplr  rq  s	            r   _forceprintYoutubeDL._forceprint3  s!   NN$	Z)>)>y)IJ==,-9 $		)tU^_rUs)t tIf]]5!! )% 09==b3Q QIf%)%>%>y%I	/"(,(D(DY(O	$%'+'B'B9==QUCVXaXeXefqXr's	#$040K0KIMMZ^L_ajanan  pD  bE  1F	,-
	a KK-11#r:DNN400T1BINO ;  ${{?;??RHOD,,Y,JHt$DNN_THE(DE&&x00(C'2F!GGD11$BRZZOP GF  I  GFs   -2H--
H<	c                   ^ ^^ T R                   R                  S5      (       dF  T R                   S   R                  S5      (       d#  T R                   S   R                  S5      (       a  T R                  U5        U(       a  X!S'   T R                  SU5      mSUUU 4S jjnU" S5        U" S5        U" S	S
5        U" SSS9  U" SSS9  U" S5        T R                   R                  S5      (       a/  TR                  S5      b  T R	                  [        TS   5      5        U" S5        T R                   R                  S5      (       a5  T R	                  [        R                  " T R                  U5      5      5        g g )N	forcejsonrR  r  rS  r  c                    > Uc  U nTR                   R                  SU  35      (       a7  TR                  U 5      c  U(       d  T(       d  TR                  TU   5        g g g g )Nr  )r%  r*  r  )r  actual_fieldoptionalr  rG  r   s      r   print_field1YoutubeDL.__forced_printings.<locals>.print_fieldd  sY    #${{ug//MM%(4Xjy67 OYX 0r   r  r  r   rW  r  T)rp  descriptionforcedurationr   r   NF)	r%  r*  r  rj  r  rm   rb  rc  sanitize_info)r   r  r  r  rq  rG  s   `  ` @r   __forced_printingsYoutubeDL.__forced_printings[  s.   KKOOK((;;|,0099;;/33G<<i($,j!$$Wi8		8 	8 	GDE6"K$/MD1J;;???++	j0I0UNN=:)>?@H;;??;''NN4::d&8&8&CDE (r   c           
         UR                  S5      (       d  U R                  US5        U(       aQ  U R                  R                  S5      nU R                  R                  S5      =(       d    U(       + nSUUUSSSSSS.	nOU R                  n[        X'US:H  S9" X5      nU(       dx  U R                   H  n	UR                  U	5        M     S	R                  S
 UR                  S/ 5      =(       d    U/ 5       5      n
U R                  SUR                   SU
 S35        U R                  U5      nUR                  S5      c  U R                  U5      US'   UR                  XU5      $ )Nr   Tr  r  F)	r  r  r  r  nopartskip_unavailable_fragmentskeep_fragmentsrK  _no_ytdl_filerW  r  r2  c              3      #    U  H=  nUS    R                  S5      (       a  US    R                  S5      S   S-   OUS    v   M?     g7f)r   zdata:r   r   z,<data>N)r)  r  r  s     r   r   YoutubeDL.dl.<locals>.<genexpr>  sO      FDA 89x7J7J77S7S5$Q')3YZ[`YaaDs   AAr  z	Invoking z downloader on "r  r   )r*  r  r%  r   rz  r  r  re  FD_NAMEr  r  r  )r   r  r  r)  r  r  r  r%  fdr  rW  r8  s               r   r  YoutubeDL.dlx  sO   xx!!$-kkooi0GKKOOG,;GE"#.3"'"!%
F [[F$TdckKDY**$$R( +;; F"5r:DtfDF FD y4DTF!LM &&t,<<'/'+'9'9('CH^${{4844r   default_overwritec                *   [        [        [        R                  R                  [        U5      5      5      nU(       a&  U R                  R                  SU5      (       d  US   $ U H*  nU R                  U5        [        R                  " U5        M,     g )NrK  r   )
r  r  r  r  r  rx   r%  r*  r  r  )r   	filepathsr  existing_filesfiles        r   existing_fileYoutubeDL.existing_file  sk    fRWW^^Z	5JKL$++//,@Q"R"R!!$$"D##D)IIdO # r   c           	        ^ ^^ ^!^"^# TR                  SS5      S:X  d   eTnST;  a  ST;   a  TS   TS'   T R                  T5      b  STS'   gT R                  T5        U4S jnT R                  TS5      u  pEU" U5        T =R                  S	-  sl        T R                  TS
S9=TS'   nT R                  TS5      n0 nT R                  TUST;  S9  U 4S jn	T R                  R                  S5      (       a&  T R                  R                  S5      TS'   U	" 5         gUc  gT R                  U5      (       d  gT R                  U5      (       d  gT R                  STT R                  TS5      5       c  gT R                  TU5      n
U
c  gUR                  [        U
5      5        T R                  STUT R                  TS5      5      nUc  gUR                  [        U5      5        T R                  TS5      nT R                  STU5      nU(       a  UTS'   UTS'   OUc  gUU 4S jm T R                  R                  S5      T R                  R                  S5      T R                  R                  S5      S.nT R                  R                  S5      (       aB  [        R                   S:X  a  SO'[        R                   R#                  S5      (       a  S OS!nS
X'   [%        U 4S" jUR'                  5        5       5      (       a  gT R                  TS#U5      u  pHU" U5        T R                  R                  S$5      (       a  UTS%'   [(        R*                  R-                  [(        R*                  R/                  U5      5      TS&'   UTS''   U" T R1                  [3        T S(5      T5      5        T R                  R                  S5      TS'   GOpTR5                  S)/ 5         UU 4S* jnS+u  m!nTR                  S,5      (       d  TR                  S!5      (       a  [7        TT R                  US-:H  S.9m!T![8        :w  ar  S/T R                  S0   ;  a_  TR                  S15      (       d  TR                  S25      (       a3  [8        R:                  " 5       (       a  S3OS4nT R=                  U S535        gTR                  S65      Gb  TS   m#T R                  R                  S75      cY  TS   S8:X  aP  TR                  S95      (       a:  [%        S: T R>                  S;    5       5      (       a  S<TS'   T RA                  S=5        TS   m"T"4U"U#4S> jjnU" U5      nU" U5      nU" Xg5      nS(TS?'   [C        [E        [        TS6   5      5      TS6'   [G        T 5      n/ nUb  T RI                  U5        GO>T!(       a  T![8        :w  a  TS6   O/  HE  n[K        U" UTS   5      S@RM                  USA   5      TS   5      =US%'   nURO                  U5        MG     SBRQ                  SC TS6    5       5      TS!'   T RS                  UT5      u  nnUTS?'   GOT R                  R                  SD5      (       a  T RA                  SE5        O\UR:                  (       dK  SFnT R                  R                  SG5      (       d  T R=                  U SH35        gT RA                  U SI35        US-:X  aT  [8        RT                  " TT R                  5      (       a  SJOUR:                  (       a  SKOSLnT RA                  SMU SN35        UnTS6    H  n[        T5      nUS6	 UR                  U5        US-:w  aY  [K        U" XtS   5      S@RM                  USA   5      US   5      nT R                  U5      (       d    gUUS%'   URO                  U5        T RS                  WU5      u  nnTS?   =(       d    UTS?'   U=(       a    UnM     U(       aP  UR:                  (       a?  T R                  R                  SD5      (       d  TS)   RO                  U5        UTSO'   S
TS?'   OLU H  nSUU'   M
     O=U" Xg5      nUb  UU:X  a  T RS                  UT5      u  nnUTS?'   OT RI                  U5        U=(       d    Un[(        R*                  R-                  [(        R*                  R/                  U5      5      TS&'   T Rc                  T5        U(       aS  US-:w  aM  U!UU 4ST jnU" 5          U" T Re                  UTU5      5         T Rh                   H  nU" TS%   5        M     S
TS'   TUL d   eT R                  R                  S5      (       a  S
TS'   U	" 5         g! [V         a  nT R=                  SPU 35         SnAgSnAf[X         a  n[[        U5      eSnAf[\         a6  nT R=                  SQUR^                   SRUR`                   SS35         SnAgSnAff = f! [f         a  nT R=                  SUU 35         SnAgSnAff = f! [j         a  nT R=                  SVU 35         SnAgSnAff = f)Wz;Process a single resolved IE result. (Modifies it in-place)r  r  r   r   Nrl  r  c                 V   > U T:X  a  g TR                  5         TR                  U 5        g r  )rE  r  )r8  r  s    r   replace_info_dict1YoutubeDL.process_info.<locals>.replace_info_dict  s&    9$OOX&r   r   T)r  	_filenamer  r  c                     > T R                   [        T R                  R                  S5      =(       d    S5      :  a  [        eg )Nmax_downloadsr  )r}  rv  r%  r*  rR   r5  s   r   check_max_downloads3YoutubeDL.process_info.<locals>.check_max_downloads  s5    ""eDKKOOO,L,UPU&VV)) Wr   rM  r/  rs  r  infojsoninfojson_filename__infojson_filenamec                   > [        TS   [        5      nU(       d  TR                  STS    S35        g[        TR	                  TS5      U TR                  S5      5      nTR                  U5      (       d  gTR                  R                  SS5      (       a:  [        R                  R                  U5      (       a  TR                  S	U  S
35        g TR                  SU  SU 35        [        [        U5      SSU S:X  a  SOSS9 nSU0nU S:X  a  US [        U 5      S-   *  US'   UR                  [         U    U-  5        S S S 5        g! , (       d  f       g= f! ["         a    TR%                  SU 35         gf = f)Nr$  z?Cannot write internet shortcut file because the actual URL of "z" is unknownTlinkr   FrK  z[info] Internet shortcut (.z) is already presentz#[info] Writing internet shortcut (.z) to: wra  r   z
r3  rb  desktopr   r  zCannot write internet shortcut )r   rq   rA  r   r  r*  rK  r%  r  r  r  r  rg  r   r  r  r?   rh  r   )	link_typer   linkfnlinkfiletemplate_varsr  r   s        r   _write_link_file0YoutubeDL.process_info.<locals>._write_link_file  s   )M2J?C##UV_`mVnUoo{|~&t'<'<Y'OQZ\e\i\ijo\pqF**622{{|T22rww~~f7M7M!<YKG[\]
!DYKvV\U]^_,V4cG,5,>&DJMU%*CLM I-4:;Qc)nq>P<Q4Rj1NN>)#<}#LMJ J J   !!$CF8"LMs0   4E ;EE 
EE E E>=E>writeurllinkwritewebloclinkwritedesktoplink)r   weblocr  	writelinkdarwinr  linuxr  r   c              3   T   >#    U  H  u  pU=(       a    T" U5      (       + v   M     g 7fr  r=  )r  r  should_writer  s      r   r   )YoutubeDL.process_info.<locals>.<genexpr>  s-      C.A*9 ?$4Y$? ??.As   %(	before_dlskip_downloadfilepath
__finaldir__files_to_moveFr  c            
         >^ TR                  S5      mUU4S jnTR                  [        R                  " [	        [        X5      U 5      6 SS9nU(       a(  [        R                  R                  U5      S   SS  TS'   U$ )Nr   c                 b   > [        U TR                  R                  S5      =(       d    TT5      $ )Nr  )r   r%  r*  )r  r   r   s    r   r  EYoutubeDL.process_info.<locals>.existing_video_file.<locals>.<lambda>,  s$    ->tT[[__U`EaEhehjm-nr   Fr  r   )	r*  r  rL  r  rp  r  r  r  splitext)r  	convertedr  r   r  r   s      @r   existing_video_file3YoutubeDL.process_info.<locals>.existing_video_file*  st    #--.C nI--ioos3yC\^g?h.i@E . GD+-77+;+;D+A!+DQR+H	%(Kr   rd  r   rW  r~  zno-direct-merger<  r5  r4  z*This format cannot be partially downloadedzOYou have requested downloading the video partially, but ffmpeg is not installedz
. Abortingr  r  r!  r  c              3   F   #    U  H  n[        U5      [        :H  v   M     g 7fr  )r  r*   )r  r  s     r   r   r  D  s     'iOhR4D(DOhs   !r]  r"  z<webm doesn't support embedding a thumbnail, mkv will be usedc                    > U S:X  a  U $ [         R                  R                  U 5      S   SS  nUTT4;   a"  [         R                  R                  U 5      S   OU nU SU 3$ )NrW  r   r   r
  )r  r  r  )r  r   filename_real_extfilename_wo_extnew_extold_exts       r   correct_ext+YoutubeDL.process_info.<locals>.correct_extJ  st    #s?#+O,.GG,<,<X,Fq,I!",M)  1Wg4FF GG,,X6q9!) ( #2!2!C599r   __real_downloadr  r   r3  c              3   *   #    U  H	  oS    v   M     g7f)r   Nr=  r  s     r   r   r  g  s     4fGe!uXGer  r5  zYou have requested merging of multiple formats while also allowing unplayable formats to be downloaded. The formats won't be merged to prevent data corruption.zJYou have requested merging of multiple formats but ffmpeg is not installedrS  z". Aborting due to --abort-on-errorz. The formats won't be mergedz$using a downloader other than ffmpegz:but the formats are incompatible for simultaneous downloadzbut ffmpeg is not installedz:You have requested downloading multiple formats to stdout z2. The formats will be streamed one after the other__files_to_mergezunable to download video data: zcontent too short (expected z bytes and served r   c                  H  >^^^ SmT
R                   R                  S5      n T	S   mU S;   a  g U S:X  a  SmO&U S:w  a   U S;   d   eT	R                  S5      (       d  S	mUU	U
U4S
 jnT	R                  S5      nU" US;  SU 3[        5        ST	;   a  [        T	T
R                   5      OS nU(       a  UR                  OS nT	R                  S5      mT	R                  S5      =(       d"    [        U4S jT
R                  S    5       5      nU(       d  U" T[        :g  =(       a     TS:H  =(       a    T	R                  S5      S:H  S[        5        U" US:H  =(       a     T
R                   R                  S5      (       + =(       d5    T	R                  S5      =(       a    T
R                   R                  S5      S L S[        5        U" US:H  =(       a)    T	R                  S5      =(       d    T	R                  S5      S[        5        U" US:H  S[        5        U" US:H  S [        5        g )!NTfixupr  )rl  r#  r  r  )detect_or_warnNr  Fc                    > T(       a  U (       d  g TS:X  a  TR                  T SU 35        g U" T5      nUR                  (       a  TS   R                  U5        g TR                  T SU S35        g )Nr  r  r  z*. Install ffmpeg to fix this automatically)rA  r  r  )cndnr  r  r  do_fixupr  r   vids       r   ffmpeg_fixup;YoutubeDL.process_info.<locals>.fixup.<locals>.ffmpeg_fixup  sn     (T"%/ //3%r#@" Y<<%&89@@D //3%r#>h0ijr   r   )r   NzNon-uniform pixel ratio r   r   r  c              3      >#    U  H:  n[        U[        5      =(       a    [        TUR                  5      S    TS4;  v   M<     g7f)r   N)r  r3   resolve_recode_mappingmapping)r  r  r   s     r   r   8YoutubeDL.process_info.<locals>.fixup.<locals>.<genexpr>  sL      X; !:" #2'=> Z23

CAFsTXkYZ 9s   AAr]  m4ar   m4a_dashz:writing DASH m4a. Only some players support this container	hlsnativehls_use_mpegtsr  z=Possible MPEG-TS in MP4 container or malformed AAC timestampsdashsegmentsr   zPossible duplicate MOOV atomsweb_socket_fragmentzMalformed timestamps detectedzMalformed duration detected)r%  r*  r/   r   r  r'  ru  r
   r.   r-   r+   r0   r,   )fixup_policyr  r   
downloaderpostprocessed_by_ffmpegr  r   r  r  r  r   s        @@@r   r  %YoutubeDL.process_info.<locals>.fixup  s   #H#';;??7#;L#D/C#'::%/#)%0+/GGGG(}}->??',H
k 
k '0mm4E&FO 	!A#;O;L!M!79 U_bkTk!8DKK!PquJ7A!3!3tJ#--.C.7mm<O.P /;TW X; !%		. 9X; U;+
 3$R8^ &Ru &R)2{)Cz)Q%a%57 %jK&?&iXhHiDi &q)2y)A)odkkooVfFgkoFo%d%68 %Z>%A &h*3--	*B*fimmTeFf%DF`b !/D!DFeg}~ /D!DFcez{r   zPostprocessing: zpost hooks: )6r*  r  r  r=  r}  r  r?  r%  rK  rt  _write_subtitlesr  r  ru  rs  r$  r  r)  r'  r  r  r  dirnameabspathrun_ppr4   r  r   r
   r  r   ru  rA  r  r  r1   r  r|   r   r  r  r  can_merge_formatsr%   rh  r[   rG   r  
downloadedr@  r]  rW   rx  r  )$r   r  original_infodictr  r8  r  full_filenametemp_filenamefiles_to_mover  	sub_filesthumb_filesinfofnr  write_linksr  r  r0  r  r  dl_filenamer  r  rq  fnamereal_downloadr  partial_successr  r  r  r  r  r  r  r  s$   ``                              @@@@r   r   YoutubeDL.process_info  s#
    }}Wg.'999%9$));"+E"2IhY'34<I01 	)$	' &&y':(#q  261F1FyW[1F1\\	+--i@ 		=hV_F_a	* ;;??:&&48KKOODb4cI01! &&}55&&}55""7I#'#8#8M#RTW[\)))]C	T)_-,,Yt/D/DYP[/\^T+./&&y*= 11'9fM-3I)*/5I+,&	4 ;;??>2kkoo&78{{'9:

 ;;??;''%(\\X%=+.<<+B+B7+K+Ki#  &*K" C.9.?.?.AC C C"&"2"29k="Y(#;;???++$1Ij!&(ggoobggoom6T&UIl#+8I'(dkk*B4*OQZ[\48KKOODb4cI01   !3R8D  )G==,,	e0D0D0DKKS`dgSghBX~*;4;;}C]*]%MM/::immM>Z>ZOWOaOaOcOcK$u ))SE*<===!45A'.G{{'<=E%e,6$-MM,$?$? %('ityyYgOh'i$i$i/4Ie, // _a'.G29 : : %0$>M$/$>M"5m"SK38I/059#dINaDb:c5dI12+D1F!#J".;;KHCE>+>!?WY!YA4E +M9U;K L %Q{^ <i>N5P PAjME '--e4	 "Z
 ,0994fyQdGe4f+f	%(15	1R.7D	"34;;??+EFF //![\ "(!1!1"nC#';;??>#B#B $ 1 1SE9[2\ ] & //3%7U0VW(C/PXPjPjktvz  wB  wB  QC  QC&Lkqk{k{+g+H # !//"\]c\d eS !ST %2E!*+>!?A'+IH ()< =$OOA.,3(9$/$O$)LL;$@(5/)S (,'>'>u'E'E$*05* * 1 1% 8=AWWUH=U:O];DEV;W;h[hI&78&-&A/G "@  "f&6&6t{{Oi?j?j!"45<<VD8B	"457;	"34$.D26M$/ %/ #6m"SK"*k].J 26	1R.7D	"34;;KH):]*,''//"''//-:X*Y	,' &&y1=C/6|p %d&7&7YP]&^_"..9Z01 /
 9=	45----;;??9::48I01k & !!$CC5"IJ 1+C00' !!$@N`adaoao`ppq"rsD + %%(8&>? ! %%SE&:;sv   !Ce2 -He2 =Ce2 D8e2 g3 h 2
g0<fg0"f--g0:,g++g03
h=hh
i(iic                 J   ^ ^ [         R                  " T5      UU 4S j5       nU$ )Nc                    >  T" U 0 UD6nTR                   R                  SS5      (       aF  TR                  U5        TR                  [        R
                  " TR                  U5      5      5        g g ! [         a    e [         a  nTR                  U5         S nAg S nAf[         aF  nTR                  SU 35        TR                   R                  S5      (       d  e STl         S nAg S nAff = f)Ndump_single_jsonFr  break_per_urlr   )r%  r*  r  r  rb  rc  rv  r   r[   r   rI   r  r}  )r   r   r  r  r   r   s       r   r   -YoutubeDL.__download_wrapper.<locals>.wrapper  s    HD+F+ ;;??#5u==%%c*NN4::d.@.@.E#FG > # ( %!!!$$$ (}-{{77&'##	(s#   A3 3C0BC0*<C++C0r   )r   r   r   s   `` r   __download_wrapperYoutubeDL.__download_wrapper  s'    			H 
	H  r   c                 b   [        U5      nU R                  S   S   n[        U5      S:  a6  US:w  a0  SU;  a*  U R                  R                  S5      S:w  a  [	        U5      eU H<  nU R                  U R                  5      " X0R                  R                  SS5      S	9  M>     U R                  $ )
zDownload a given list of URLs.r  r  r   rW  r  r  r  F)r  )r   r%  r  r*  rZ   _YoutubeDL__download_wrapperr  r|  )r   url_listr  r   s       r   r  YoutubeDL.download  s    H%++i(3MAsNw&KKOOO49((C##D$5$56[[__=VX]-^`  %%%r   c                 N   [         R                  " [        R                  " U/S[        R                  " S5      S95       n[        [        R                  " SR                  U5      5      5       Vs/ s H.  nU R                  X0R                  R                  SS5      5      PM0     nnS S S 5        W H$  n U R                  U R                  5      " USS9  M&     U R.                  $ s  snf ! , (       d  f       NI= f! [        [        [         4 ao  n[#        U[        5      (       d  U R%                  S5        UR                  S	5      nUc  e U R'                  S
U SU 35        U R)                  U/5         S nAM  S nAf[*         a  nU R-                  U5         S nAM  S nAff = f)Nr`  ra  )modeopenhookr3  clean_infojsonTr0  r  r$  zThe info failed to download: z; trying with URL )
contextlibclosing	fileinput	FileInputhook_encodedr   rb  loadsr  rv  r%  r*  r  r   rJ   rK   rX   r  r  rA  r  rM   r   r|  )r   info_filenamerq  r  infosr  r$  s          r   download_with_info_file!YoutubeDL.download_with_info_file   so   	 3 3c"//8!: ;>? "*$**TYYq\*B!CE!C ''kkoo>NPT.UV!C  E	; D%''(>(>?tT  %%%E	; ; "#5}E -!!%788NN4("hh}5&##&CA3FXYdXe$fg{m,,! %!!!$$%sC    1C+15C&&C+6 C<&C++
C9<F$A$E;;F$FF$c                    ^^ U c  U $ U R                  S[        [        R                  " 5       5      5        U R                  SS5        U R                  S[        [	        5       [
        [        S.5        U(       a  S mOS mUU4S jmT" U 5      $ )	z-Sanitize the infodict for converting to json r  r  r  r  )r  r;   release_git_head
repositoryc                 R    US L =(       d    U R                  S5      =(       d    U S;   $ )N__>   r  r  r  r  r  r  rZ  r  r  r  r  r  r  r  s     r   r  )YoutubeDL.sanitize_info.<locals>.<lambda>E  s0    !t) #q||D/A #Q K F #r   c                     gru  r=  r  s     r   r  r  K  s    %r   c                   > [        U [        5      (       a;  U R                  5        VVs0 s H  u  pT" X5      (       a  M  UT" U5      _M     snn$ [        U [        [        [
        [        45      (       a  [        [        TU 5      5      $ [        U [        5      (       a  [        U 5      $ U b%  [        U [        [        [        [        45      (       a  U $ [        U 5      $ s  snnf r  )r  r  r  r  ro  rd  rQ   r  r'   r&  r  rv  r  r0  )r1  r  r  	filter_fnrejects      r   r  *YoutubeDL.sanitize_info.<locals>.filter_fnM  s    #t$$47IIKTKDAva|9Q<KTTC$sH!=>>C	3/00C!2333x
3c5$0G H H
Cy  Us   C!C!)r  r  rs  r   r;   r   r   )r  remove_private_keysr  r  s     @@r   rv  YoutubeDL.sanitize_info6  s     Wc$))+&67Wg.Z" 0 2 0 	*
 	 F (F
	! ##r   c                 ,    [         R                  X5      $ )z2Alias of sanitize_info for backward compatibility )r   rv  )r  actually_filters     r   filter_requested_infoYoutubeDL.filter_requested_info[  s     &&yBBr   r  r  c                    [        [        S U5      5       HQ  nU(       a  U R                  X$-  5         [        R                  " U5        XAR                  S/ 5      ;   d  MK  US   U	 MS     g ! [
         a    U R                  SU 35         NBf = f)NzUnable to delete file r  )rd  r  r  r  r  rh  rA  r*  )r   r  r  files_to_deleter  s        r   _delete_downloaded_files"YoutubeDL._delete_downloaded_files`  s    F49:Hs~.I		(# 88$5r::*+H5 ;
  I##&<XJ$GHIs   A,,BBc                 4   ^ U4S jmT" U =(       d    0 5        g )Nc                    > U R                  S5      S;   a+  U R                  S0 5       H  nT" U=(       d    0 5        M     g U R                  SS 5      =(       d    [        nU R                  U" 5       5        g )Nr  r  r  __post_extractor)r*  r  r  r  )r  
video_dictpost_extractoractual_post_extracts      r   r"  3YoutubeDL.post_extract.<locals>.actual_post_extractm  sa    }}W%)DD"+--	2">J'
(8b9 #?&]]+=tDLN^-.r   r=  )r  r"  s    @r   r  YoutubeDL.post_extractk  s    	/ 	IO,r   c                    / nSU;  a  0 US'    UR                  U5      u  p2U(       d  U$ U R                  R                  SS5      (       a   U H  nUS   R                  US5        M     U$ U R                  " X2SS.6  U$ ! [         a<  nU R                  R                  S5      SL a  U R	                  U5        Us S nA$ e S nAff = f)	Nr  rS  T	keepvideoFr  z+Deleting original file %s (pass -k to keep)r  )runrW   r%  r*  r   r  r  )r   r  infodictr  r  rq  s         r   r  YoutubeDL.run_ppx  s    H,*,H&'	(*x(8%O O;;??;..$*+66q"= %
  )) 5bd # 	{{~.$6!!!$	s#   B   
C
0C:C CCadditional_ppsc                    US:w  a  U R                  X5        U=(       d    / U R                  U   -    H  nU R                  XB5      nM     U$ )Nr  )rj  ru  r  )r   r^  r  r+  r  s        r   ry  YoutubeDL.run_all_pps  sF    '>S'!'R499S>9B;;r(D :r   c                     [        U5      nU=(       d    0 US'    U R                  X$5      nXDR                  SS 5      4$ ! [         a1  nSU 3nUR                  SU5        U R	                  USS9   S nANIS nAff = f)Nr  zPreprocessing: r  F)rZ  )r  ry  rW   r  r   r  )r   ie_infor^  r  r  r  r  s          r   r=  YoutubeDL.pre_process  s    G}"/"52	3##C.D
 XX/666	 # 	3#C5)COO-s3cE2	3s   ? 
A:	'A55A:c                     XS'   U=(       d    0 US'   U R                  SX"R                  S5      S9nU R                  [        U 5      U5      nUS	 U R                  SU5      $ )z-Run all the postprocessors on the given file.r  r  r]  r  r*  
after_move)ry  r*  r  r4   )r   r  r  r  s       r   r]  YoutubeDL.post_process  sk    #Z"/"52XXN`Eab{{3D94@"#d33r   c                 b   UR                  S5      nU(       d  g UR                  S5      =(       d    UR                  S5      nUc`  [        UR                  S5      5      nU(       d  g U R                  R                  5        H  u  pVUR	                  U5      (       d  M  Un  O   g [        X25      $ )Nr  r'  r  r   )r*  r   rs  r  r  ru   )r   r  r  r  r   r  r  s          r   _make_archive_idYoutubeDL._make_archive_id  s    ==& MM/2MimmH6M	immE23C"iioo/
;;s## &I 0
 y33r   c                    ^  T R                   (       d  gT R                  U5      /nUR                  UR                  S5      =(       d    / 5        [	        U 4S jU 5       5      $ )NF_old_archive_idsc              3   @   >#    U  H  oTR                   ;   v   M     g 7fr  )rl  )r  id_r   s     r   r   0YoutubeDL.in_download_archive.<locals>.<genexpr>  s     :'3$,,&'s   )rl  r5  r,  r*  r'  )r   r  vid_idss   `  r   r  YoutubeDL.in_download_archive  sL    ||((34y}}%78>B?:':::r   c                 f   U R                   R                  S5      nUc  g U R                  U5      nU(       d   eU R                  SU 35        [	        U5      (       a(  [        USSS9 nUR                  US-   5        S S S 5        U R                  R                  U5        g ! , (       d  f       N*= f)Nrr  zAdding to archive: r  ra  rb  r3  )	r%  r*  r5  re  rr   rt   r  rl  rf  )r   r  rk  vid_idrm  s        r   rA  !YoutubeDL.record_download_archive  s    [[__/0:&&y1v.vh78Rw7<""6D=1 8  87s   )B""
B0c                    U R                  S5      S:X  a  U R                  S5      S:w  a  gU R                  S5      b  U S   $ U R                  S5      (       a#  U R                  S5      (       a  SU S   U S   4-  $ U R                  S5      (       a  S	R                  U S   5      $ U R                  S5      (       a  S
U S   -  $ U$ )Nr   r  r   
audio onlyr   r   r   r  z{}pz%dx?)r*  r   )r   r  s     r   rt  YoutubeDL.format_resolution  s    ::h6)fjj.Bf.L::l#/,''::g6::h#7#7fWovh/?@@@ZZ!!<<x 011ZZ  F7O++r   c                     U R                   R                  SS5      SLa5  U Vs/ s H'  o R                  X R                  R                  5      PM)     sn$ U$ s  snf )NrJ  TF)r%  r*  rx  r  rb  )r   headersheaders      r   _list_format_headersYoutubeDL._list_format_headers  sO    ;;??.5UBPWXPWf$$V[[-@-@APWXX Ys   .Ac                 B   SnUR                  S5      S;   a  US-  nUR                  S5      (       a#  U(       a  US-  nUSR                  US   5      -  nUR                  S5      b  U(       a  US-  nX!S   -  nUR                  S	5      b  U(       a  US
-  nUSUS	   -  -  nUR                  S5      b#  U(       a  US
-  nUSR                  US   5      -  nUR                  S5      b@  UR                  S5      S:w  a+  U(       a  US
-  nX!S   -  nUR                  S5      b  US-  nO)UR                  S5      b  UR                  S5      b  US-  nUR                  S5      b  USUS   -  -  nUR                  S5      b#  U(       a  US
-  nUSR                  US   5      -  nUR                  S5      b'  U(       a  US
-  nUS   S:X  a  US-  nO/USUS   -  -  nO#UR                  S5      b  U(       a  US
-  nUS-  nUR                  S5      b  USUS   -  -  nUR                  S5      b  USUS   -  -  nUR                  S5      b  U(       a  US
-  nU[        US   5      -  nU$ UR                  S5      b   U(       a  US
-  nUS[        US   5      -   -  nU$ ) Nr  r   f4ff4mz(unsupported)r   r  z[{}]r   r   rJ  z%4dkr   z{} containerr   r  r   @r   zvideo@r   z{}fpsr   
video onlyz%-5sr  z@%3dkr   z (%5dHz)r   r   ~)r*  r   rj   )r   fdictr  s      r   _format_noteYoutubeDL._format_note  s   99U~-?"C99Z  s
6==z!233C99]#/s
''C99U't6E%L((C99[!-t>(({);<<CIIh+IIh'61t?"Cyy+s
YYu)eii.>.J8OC99U'6E%L((C99U't7>>%,//C99X*tX&(|#vh//YYu)t7NC99U'7U5\))C99U':e,,C99Z ,t<j 122C
 
	 YY()5t3e,=&>???C
r   c                     UR                  S5      c1  UR                  S5      (       a  UR                  SS5      S:X  a  U/$ / $ US   $ )Nr  r   r  r  r  r   r  s     r   r  YoutubeDL._get_formats"  sJ    ==#+}}U##	gw(G7(R!{"I##r   c           $        ^  T R                  U5      nU(       d  g T R                  R                  SS5      SL at  U Vs/ s HZ  o3R                  S5      =(       d    SS:  d  M"  [        US5      [        US5      T R	                  U5      T R                  U5      /PM\     nn[        / S	QUS
S9$ U 4S jnT R                  ST R                  R                  SSS9nU Vs/ s GH  o3R                  S5      b  US   S:  d  M   T R                  [        US5      T R                  R                  5      [        US5      [        UT R                  SS9[        USS[        S9[        USSSS9R                  SS5      [        USS5      U[        USS[        S9=(       ds    [        USS [        S9=(       d\    [        [        UR                  S!5      UR                  S"5      5      S T R                  S#T R                  R                  5      [        S9[        US!S$[        S9[!        UR                  S%S5      5      UU" US&5      [        US'S$[        S9U" US(5      [        US)S$[        S9[        US*S["        S9[%        [        US+S,5      [%        UR                  S5      S-;   a&  T R                  S.T R                  R&                  5      OS UR                  S/5      S0:X  a&  T R                  S1T R                  R(                  5      O=UR                  S/5      (       a&  T R                  S2T R                  R&                  5      OS UR                  S35      (       a&  T R                  S4T R                  R(                  5      OS [        US55      [        US6S UR                  S5      4S9S7S89S9S89/PGM     nnT R+                  S:S;S<S=SS>US?S@SAUSBSCSDSESFSG5      n[        XtST R                  SHT R                  R                  SISS9SJ9$ s  snf s  snf )KNrJ  TFr   r   ir   r   )zformat coder   r   r  r   )	extra_gapc                 d  > US;   d   eU R                  U5      nU(       d  gUS:w  a#  SR                  UR                  S5      S S 5      $ US:X  a  U R                  S5      S:X  a  gUS:X  a  U R                  S5      S:X  a  g	TR                  US:X  a  S
OSTR                  R
                  5      $ )N)r   r   unknownr  r
  rM  r   r   imagesr  rB  rN  )r*  r  r  rx  r  rh  )rq  r  r  r   s      r   simplified_codec8YoutubeDL.render_formats_table.<locals>.simplified_codec7  s    0000EE%LE &xxC 0! 455 QUU8_%>("quuX&'@##EX4EL<$(KK$8$8: :r   u   │r  ri  )rB  rZ  )r   rl  r   z	%d)r   r   r  )Nr   )rl  HDRr  r   z	%sr   z 	%sr   u   ≈	%sr   r   z~	%sz	%dkr   r   r   r   r   r   r   z[%s]rJ  UNSUPPORTEDr   r  z	Maybe DRMDRMr  Untestedr   r   rJ  rj  r  rd  EXT
RESOLUTIONz	FPSCHz		FILESIZEz	TBRPROTOVCODECz	VBRACODECz	ABRz	ASRz	MORE INFOu   ─rW  )
hide_emptyrj  )r  r%  r*  rl   rt  rQ  r~   rx  r  re  rd  r  r  rj   r   rh  r   rk   rs   rf  rg  rG  )r   r  r  rq  tabler[  rj  header_lines   `       r   rd  YoutubeDL.render_formats_table)  s   ##I.{{2D9F #K #auu\':'?aE&I K0 E***1-%%a(	
 #  K   RTYefgg	:   4;;+<+<cQU V< ;[: !%%"5"=<TYAY9  a!=t{{~~NQ&QT%;%;D\]QvE:QmLTTUZ\^_Q 0&9 JlK h#A'8),Wh#$5aeeElIMMR\D]$^`d$($4$4Wdkk>R>R$SZfhQwU;%aeeJ&;< H-QwU; H-QwU;Qv4IJl1j&A=OPuuUZ|_mOmD$$]DKK4J4JKswKL55QZK[_fKfT%%k4;;3F3FGMNUUS\M]M]$**5$++2H2HIcgIJO`IaIaD$$Z1D1DEgk M2 KquuU|8LMD  (+,)8 ; 	 [< //%wtULRY[b8Wh+O 4""8T[[->->SW"XZ 	ZwK2[s   !P#<PPJ/Pc                 J   [        UR                  S5      =(       d    / 5      nU(       d  g [        U R                  SSSS5      U Vs/ s HJ  o3R                  S5      UR                  S5      =(       d    SUR                  S	5      =(       d    SUS
   /PML     sn5      $ s  snf )Nr  rd  WidthHeightURLr  r   rY  r   r   )r  r*  r~   rG  )r   r  r  r  s       r   re  !YoutubeDL.render_thumbnails_tablem  s    )--5;<
%%dGXuEistisdeeeDk155>6Yh8T9VWX]V^_istv 	vts   AB 
c                     S nU(       d  g [        U R                  SSS5      UR                  5        VVs/ s H  u  pEU" XE5      PM     snnSS9$ s  snnf )Nc                     [        S [        U5       5       6 u  p#[        [        U5      5      S:X  a  US   S:X  a  / OUS S nU SR	                  U5      SR	                  U5      /$ )Nc              3   ^   #    U  H#  oS    UR                  S5      =(       d    S4v   M%     g7f)r   r  rY  Nr  r  s     r   r   AYoutubeDL.render_subtitles_table.<locals>._row.<locals>.<genexpr>w  s&     bPa15155=+EI FPas   +-r   r   rY  rJ  )rp  reversedr  rd  r  )rL  r  extsnamess       r   _row.YoutubeDL.render_subtitles_table.<locals>._rowv  sa    bPXY`PabcKD3u:!##Ah)3r$))E*DIIdO<<r   LanguageNameFormatsT)rh  )r~   rG  r  )r   r  r  rx  rL  r  s         r   rf   YoutubeDL.render_subtitles_tableu  sV    	= %%j&)D6?oo6GH6G]TT$ 6GH 	Hs   Ac                     U" U6 nU(       d  U R                  U SU 35        g U R                  SU SU S35        U R                  U5        g )Nz has no z[info] Available z for r  )r  r  )r   r  r  r   r   ri  s         r   __list_tableYoutubeDL.__list_table  sP    dNNhZxv67*4&hZqABur   c                 F    U R                  US   SU R                  U5        g )Nr  r  )_YoutubeDL__list_tablerd  rT  s     r   r  YoutubeDL.list_formats  s!    )D/9d6O6OQZ[r   c                 F    U R                  US   SU R                  U5        g )Nr  r  )r  re  rT  s     r   rN  YoutubeDL.list_thumbnails  s!    )D/<9U9UW`ar   c                 >    U R                  XU R                  X5        g r  )r  rf  )r   r  r  r  s       r   r  YoutubeDL.list_subtitles  s    ($*E*Ex[r   c                 
  ^ ^^ T R                   R                  S5      (       d  g S mSR                  [        R                  " 5       [
        R                  " 5       T R                  5       SR                  U4S jT R                  R                   5       5      5      nT R                   R                  S5      mT(       a  U4S jnU" U5        O[        SU S	3S S
9  U 4S jn[        5       n[        S;  a  US-  n[        T 5      nU" [        [         R"                  " S5      S    S3[%        [&        [(        R*                  " S5      S   =(       d    [,        [,        5      [.        (       a  S[.        S S  S3OSUS:X  a  SOSU S3[0        R2                  (       a  SO'U[4        :X  a  SOST R6                   SUR8                   3SS95        [0        R2                  (       d  U" ST R                    35        [;        5         [<        R2                  nUc	  U" S5        OU(       d  U" S 5        T R                   S!   (       a3  U" S"R                  SR                  T R                   S!   5      5      5        [?        5       (       a  U" S#[?        5        35        U" [A        5       5        [B        RD                  " T 5      u  pgURG                  5        VV	s1 s H  u  pU	(       d  M  UiM     nnn	U(       a4  US$==   S%R                  S&R                  [I        U5      5      5      -  ss'   [K        5       US''   [L        RN                  " 5       US('   SR                  S) [I        URG                  5       5       5       5      =(       d    S*n
U" S+U
 35        S,S-K(J)n  S,S.K*J+n  U" S/SR                  [I        URY                  5        Vs1 s H  n[        U" U5      6 iM     sn5      5      =(       d    S*-  5        U" S0T RZ                   35        U" S1SR                  S2 T R\                  R^                  RY                  5        5       5       35        S3[`        4S4[b        44 H  u  pUR2                  RG                  5        VVs/ s H3  u  nnURd                  U:X  a  URd                  OURd                   S5U 3PM5     nnnUS3:X  a4  URg                  S6 [h        R2                  RG                  5        5       5        U(       d  M  U" U S7SR                  [I        U5      5       35        M     S*n[j        R2                  (       d  S8nO"[m        5       nU(       a  SR                  U5      nU" S9U 35        g s  sn	nf s  snf s  snnf ):Nr  c           
         [        [        U SS[        U 5      R                   S35      5      n/ n[        R
                  R                  SS5      R                  5       S:X  a  UR                  S5        [        U 5      (       d&  UR                  [        R                  SL a  SOS	5        U(       a  U S
SR                  U5       S3nU$ )Nrc  z	missing (r   r  r  r  FzNo VTzNo ANSI (r   )r&  rm  r  r;  r  environr*  r  r  r   r   r  r  )r+  r  additional_infos      r   get_encoding2YoutubeDL.print_debug_header.<locals>.get_encoding  s    gfjId6l>S>S=TTU2VWXC Ozz~~fb)//1V;&&v..v66&&/2G2G52PwV_`R 9:!<Jr   z(Encodings: locale {}, fs {}, pref {}, {}rJ  c              3   \   >#    U  H!  u  pUc  M
  US:w  d  M  U ST" U5       3v   M#     g 7f)Nr2  r  r=  )r  r^  r+  r  s      r   r   /YoutubeDL.print_debug_header.<locals>.<genexpr>  s=      <CYKC 0*-*: 03%qf-./CYs   	,,,r  c                 ,   > TR                  SU  35      $ )Nr  )r  )r  r  s    r   r  .YoutubeDL.print_debug_header.<locals>.<lambda>  s    fllXcU3C&Dr   r  r3  rb  c                 .   > TR                  SU  S35      $ )Nr  r3  )r  )r  r   s    r   r  r    s    d&8&88C59K&Lr   )Npipr  r*  r  z versionrM  r  	   r  r  rY  r  r   APIzAPI:r
  r  ra  zparams: z#Lazy loading extractors is disabledz,Lazy loading extractors is forcibly disabledr<  zCompatibility options: {}z
Git HEAD: ffmpegz ({})r   rtmpdump	phantomjsc              3   F   #    U  H  u  pU(       d  M  U S U 3v   M     g7f)r  Nr=  )r  exer  s      r   r   r    s$      
'CVSqLse1QCL'Cs   !!r  zexe versions: r   )get_package_info)available_dependencieszOptional libraries: %szProxy map: zRequest Handlers: c              3   8   #    U  H  oR                   v   M     g 7fr  )RH_NAME)r  rhs     r   r   r    s     2qHp"::Hps   	ExtractorzPost-Processorz as c              3      #    U  H8  u  pUS    R                   R                  S5      S    SUR                   S3v   M:     g7f)r  r  r  r  r   N)r  	partitionr;  )r  parentpluginss      r   r   r    sK      $_;] (/r{':':'D'DS'I!'L&MRPVP_P_O``a$b;]s   A Az
 Plugins: znone (disabled)zPlugin directories: )7r%  r*  r   localegetpreferredencodingr$  r  r  r  r  r  r   r<   r   r  rs   r7   
rpartitionr:   r   r   r  r   r   r   r  r   r<  r=  r   r   r;   r   r2   get_versions_and_featuresr  sortedr   r   r  compat.compat_utilsr  dependenciesr  r  proxiesrM  handlersr   r   r;  r,  r   r   plugin_directories)r   encoding_strre  sourceklasslazy_extractorsexe_versionsffmpeg_featuresr^  r9  exe_strr  r  r  plugin_typer  r  display_listplugin_dirs_msgfound_plugin_directoriesr  r  s   `                   @@r   r  YoutubeDL.print_debug_header  s   {{y))		 BHH'')%%'II <CG??CYCY< <	
 *DK%8L>4tDLK!-'cMFT
M$$S)!,-X6 1 1# 6q 9 H[+V+;+;a !$%Q'I%BQvha=,,BUi-?EtDOOK\\]^c^p^p]qEr 	 ||(4;;-01)//"=> FG;;}%3::499T[[Q^E_;`ab*%5%7$89:%'((;(U(UVZ([%/>/D/D/FN/F83#3/FN"gnnSXXf_>U5V&WW"#3#5Z $4$=$=$?[!)) 
'-l.@.@.B'C
 
  	 	nWI./98,		&9O9V9V9XB
9XAM+A./9XB
 ; 1 1 	 	k$,,01(2qH^H^HgHgHnHnHp2q)q(rst&1:%>AQS]@^$_ K $+==#6#6#8:#8KD% #(..D"8@PPTUYTZ>[[#8  : k)## $_;O;U;U;[;[;]$_ _;-z$))F<<P2Q1RST %` !  /O'9';$'"&)),D"E*?*;<=Q OB
:s   U* U*=U09:U5c                     U R                   R                  S5      nUb  US:X  a  SnSU0nU$ [        R                  R	                  5       nSU;   a  SU;  a  US   US'   U$ )zGlobal proxy configurationproxyr  __noproxy__r  r  r+  )r%  r*  r   request
getproxies)r   
opts_proxyr  s      r   r  YoutubeDL.proxies  sp     [[__W-
!R*
j)G  nn//1G WG%;#*6? r   c                 N    [        U R                  R                  S5      U R                  R                  S5      U 5      $ ! [         aY  nUR                  nU R                  [        U5      SR                  [        R                  " SX"R                  5      5      S9  e SnAff = f)zGlobal cookiejar instancerB  cookiesfrombrowserr  Nr  )r	   r%  r*  r   __context__r   r&  r  rT  rU  __traceback__)r   r   causes      r   rC  YoutubeDL.cookiejar  s    	-t{{?S/TVZ\ \ 	%%Ec%jRWWY5O5OPTV[]p]p5q-rs		s   >A 
B$ABB$c                     U R                  S5        U R                  R                  S   nUR                  U R                  U R
                  S9$ )zC
Get a urllib OpenerDirector from the Urllib handler (deprecated).
z8YoutubeDL._opener is deprecated, use YoutubeDL.urlopen()Urllib)rC  r  )ra   rM  r  _get_instancerC  r  )r   handlers     r   _openerYoutubeDL._opener  sG    
 	  ![\((11(;$$t~~t||$TTr   c                     U R                   R                  R                  5        VVs/ s HD  n[        U[        5      (       d  M  [        UR                  5        H  nX!R                  4PM     MF     snn$ s  snnf r  )rM  r  r  r  r&   ru  supported_targetsr  )r   r  targets      r   "_get_available_impersonate_targets,YoutubeDL._get_available_impersonate_targets   sq     ,,55<<>
>"78 ! #2#7#78 ZZ  9 !>
 	
 
s   A7.A7c                 r   ^ [        U4S jU R                  R                  R                  5        5       5      $ )Nc              3   t   >#    U  H-  n[        U[        5      (       d  M  UR                  T5      v   M/     g 7fr  )r  r&   is_supported_target)r  r  r  s     r   r   :YoutubeDL._impersonate_target_available.<locals>.<genexpr>+  s3      :>"78 +B""6**>s   88)r'  rM  r  r  )r   r  s    `r   r  'YoutubeDL._impersonate_target_available)  s2     :,,55<<>: : 	:r   c                    US;   a
  [        5       nU(       aG  [        U5       Vs/ s H0  n[        U[         5      (       a  UO[         R                  " U5      PM2     snO/ n[	        [        U R                  U5      S 5      nXC4$ s  snf )N)Tr  )r'   r   r  from_strr  r  r  )r   r   r  requested_targetsavailable_targets        r   _parse_impersonate_targets$YoutubeDL._parse_impersonate_targets0  s    *$+-K
  k*
* A011A7H7Q7QRS7TT*
 ! 	
  t'I'IK\ ]_cd22
s   7Bc           	          U=(       d    SnSR                  [        S [        [        U 5      5      5      nU(       d  SOSU 3nU SU SU(       a  SOS S	3$ )
Nz>The extractor specified to use impersonation for this downloadrJ  z"no impersonate target is availablez1none of these impersonate targets are available: z, but z. Seez!If you encounter errors, then seezi  https://github.com/yt-dlp/yt-dlp#impersonation  for information on installing the required dependencies)r  r  r  r&  )r  r  rZ  specific_targetsr	  s        r   _unavailable_targets_message&YoutubeDL._unavailable_targets_message=  sm    WW99VD#c;L2M%NO8H0DEUDVW 	 fF7)2xe=`%aFG	Hr   c                    [        U[        5      (       a  [        U5      nOE[        U[        R                  R                  5      (       a  U R                  S5        [        U5      n[        U[        5      (       d   e[        UR                  5      u  p#U(       a  X1R                  S'   [        U5      Ul        [        UR                  UR                  S9  [        UR                  5         U R                  R                  U5      $ ! [          Ga  nUR"                   GHq  nUR$                  (       a  UR&                  (       d  M(  UR$                  R(                  S:X  a)  SUR&                  R+                  5       ;   a  [-        SUS9UeSUR&                  R+                  5       ;   a?  S	U R                  R.                  ;  a%  S
U R                  R.                  ;  a  [-        S5      e[0        R2                  " SUR&                  R+                  5       5      (       a%  SU R                  R.                  ;  a  [-        SUS9Ue[0        R2                  " SUR&                  R+                  5       5      (       d  GMX  [-        SUR4                  S    S35      e   e SnAf[6         a:  nS[        U5      ;   a  [-        SUS9UeS[        U5      ;   a  [-        SUS9Uee SnAff = f)zStart an HTTP download z{Passing a urllib.request.Request object to YoutubeDL.urlopen() is deprecated. Use yt_dlp.networking.common.Request instead.Authorization)r  rE  r  zunsupported url scheme: "file"zwfile:// URLs are disabled by default in yt-dlp for security reasons. Use --enable-file-urls to enable at your own risk.)r  zunsupported proxy type: "https"requests	curl_cffiztTo use an HTTPS proxy for this request, one of the following dependencies needs to be installed: requests, curl_cffizunsupported url scheme: "wss?"
websocketszkThis request requires WebSocket support. Ensure one of the following dependencies are installed: websocketsz:unsupported (?:extensions: impersonate|impersonate target)rI  r   z" is not available. See --list-impersonate-targets for available targets. This request requires browser impersonation, however you may be missing dependencies required to support this target.N$UNSAFE_LEGACY_RENEGOTIATION_DISABLEDzGUNSAFE_LEGACY_RENEGOTIATION_DISABLED: Try using --legacy-server-connectSSLV3_ALERT_HANDSHAKE_FAILUREztSSLV3_ALERT_HANDSHAKE_FAILURE: The server may not support the current cipher list. Try using --legacy-server-connect)r  r&  r   r   r  ra   r   rg   r   rE  r   r   r  r   rM  sendr"   unsupported_errorsr  r  RH_KEYr  r#   r  r  r  
extensionsr$   )r   reqr   basic_auth_headerr  ues         r   r  YoutubeDL.urlopenI  s   c3#,CV^^3344$$@A $C(C#w'''' "4CGG!<+<KK(s#ckk3;;?ckk"*	))..s33#  	**

rvv::$$05UY[Y_Y_YeYeYg5g&MTVX]_` 6G"$*@*@*I*II#4+A+A+J+JJ& OP P HH>OO$D,B,B,K,KK&] " (**
 XX[]_]c]c]i]i]kll&.s~~m/L.M N< => >5 +>  	5Q?"#ltuv|}}0CF:"8?@BGHI 	s+   .D	 	KEJ8JK$5KKc                    [        U 5      nU R                  S   R                  5       nU R                  R                  5       n[	        U5        [        XT5        [        X0R                  R                  S5      S9nU Hy  nUR                  U" SUUU R                  USU R                  S   ;   U R                  R                  S5      (       + S.[        U R                  SSS	S
SSSSSS.S.5      D65        M{     UR                  R                  U=(       d    / 5        SU R                  S   ;   a  UR                  R                  S 5        U$ )Nr   debug_printtraffic)r  r  z
no-certifir<  nocheckcertificate)r  rE  rC  r  prefer_system_certsverifysource_addresssocket_timeoutlegacyserverconnectenable_file_urlsr   client_certificateclient_certificate_keyclient_certificate_password)r  r  r  )r  r  timeoutlegacy_ssl_supportr  r   client_certzprefer-legacy-http-handlerc                 *    U R                   S:X  a  S$ S$ )Nr  i  r   )r  )r  r  s     r   r  2YoutubeDL.build_request_director.<locals>.<lambda>  s    "))x:O33VUV3Vr   r=  )r   r%  r  r  r   r   r   r*  add_handlerrC  r   r'  r  rf  )r   r  r'  r  rE  r  directorr  s           r   build_request_director YoutubeDL.build_request_director  s6   D!++n-224,,##%gg'"&++//J^:_`G   "..$0DKK4N$N;;??+?@@" t{{3&6/*?(:#0.B2J7T$- "   , 	##K$526'4;;}+EE  $$%VWr   c                 T    U R                  [        R                  " 5       [        5      $ r  )r  r   r  r    r5  s    r   rM  YoutubeDL._request_director  s    **+<+C+C+EWWr   c                     [        U[        5      (       a  U$  UR                  U R                  5       5      $ ! [         a  nUR
                  S-   Ul        e S nAff = f)NzH. Check your system encoding configuration or use the --encoding option.)r  ra  r  r  r  r  )r   r  r  s      r   r  YoutubeDL.encode  sU    aH	88D--/00! 	&ppCJ	s   8 
AAAc                 V    U R                   R                  S5      nUc
  [        5       nU$ )Nrc  )r%  r*  r{   )r   rc  s     r   r  YoutubeDL.get_encoding  s'    ;;??:.(*Hr   c           	      r   Uc  U R                   R                  SS5      nU R                   R                  S5      (       d  gU(       d  U R                  SU S35        gU R                  U5      (       d  gU(       dH  [        R
                  R                  U5      (       a$  U R                  SUR                  5        S	35        g
U R                  SU SU 35         [        U R                  X R                   R                  SS5      5      U5        g! [         a    U R                  SU SU 35         gf = f)zaWrite infojson and returns True = written, 'exists' = Already exists, False = skip, None = error NrK  TwriteinfojsonFSkipping writing z	 infojsonr  z metadata is already presentr  r`  z metadata as JSON to: r  Cannot write z metadata to JSON file )r%  r*  re  rK  r  r  r  r  r  r   rv  rh  r   )r   labelr  r  rm  s        r   rs  YoutubeDL._write_info_json  s   d;I{{//0yAB((00rww~~f55NNWU[[]O3OPQ/EfXNO	D..y++//JZ\`:abdjk 	eW4KF8TU	s   5D !D65D6c                    U R                   R                  S5      (       d  gU(       d  U R                  SU S35        gU R                  U5      (       d  gU R                   R                  SS5      (       dH  [        R
                  R                  U5      (       a$  U R                  SUR                  5        S	35        gUR                  S
5      c  U R                  SU S35        g U R                  SU SU 35        [        USSS9 nUR                  US
   5        SSS5        g! , (       d  f       g= f! [         a    U R                  SU SU 35         gf = f)zIWrite description and returns True = written, False = skip, None = error writedescriptionFr  z descriptionNrK  Tr  z description is already presentrs  z[info] There's no z description to writer`  z description to: r  ra  rb  r  z description file )r%  r*  re  rK  r  r  r  r  r  rg  r  rh  r   )r   r  r  descfndescfiles        r   rt  YoutubeDL._write_description  sC   {{1220|DE((00t449O9ONNWU[[]O3RST  ]]=)1NN07LMN7HQR&#8HNN9]#;< 9
  98
   !!M%8J6("STs0   ("D9 
D(D9 (
D62D9 6D9 9!EEc           	         / nUR                  S5      nU R                  R                  S5      (       d"  U R                  R                  S5      (       d  U$ U(       d  U R                  S5        U$ U R                  US5      nU(       d  U R                  S5        U$ UR	                  5        GHJ  u  pgUS   n[        X&XR                  S5      5      n	[        XVXR                  S5      5      n
U R                  X45      nU(       a0  U R                  SU S	U S
35        XS'   UR                  X45        M  U R                  SU	 35        UR                  S5      bB   [        U	SSSS9 nUR                  US   5        SSS5        XS'   UR                  X45        M   UR                  5       nUR                  SUR                  S5      5        U R                  XSS9  XS'   UR                  X45        GMM     U$ ! , (       d  f       N= f! [         a    U R                  SU	 35           gf = f! [        [         [        ["        /[$        Q7 a  nSU< SU 3nU R                  R                  S5      SLa<  U R                  R                  S5      (       d  U R                  U5        [        U5      eU R'                  U5         SnAGM#  SnAff = f)z_Write subtitles to file and return list of (sub_filename, final_sub_filename); or None if errorr  r=  r>  z9[info] There are no subtitles for the requested languagesr)  z'[info] Skipping writing video subtitlesr   z[info] Video subtitle r
  z is already presentr  z#[info] Writing video subtitles to: r  Nr  ra  r  rb  z"Cannot write video subtitles file r   T)r)  z'Unable to download video subtitles for r  rS  )r*  r%  r  r  r  r   r  r  rg  r  rh  r   r  r  r  rJ   rM   r  r%   rA  )r   r  r  r  r  sub_filename_basesub_langsub_info
sub_formatsub_filenamesub_filename_finalexisting_subsubfilesub_copyr  r  s                   r   r  YoutubeDL._write_subtitles  s   MM"78	 011T[[__EX5Y5Y JNNVWJ 11)ZH NNDEJ"+//"3H!%J-h*mm\aNbcL!34EQ[]j]jkp]q!r--/A.PQL!7z:,Nabc'3$

L=>NN@OP||F#/
  lC'2NRYhv&67 O+7Z(JJAB
)#==?##NIMM.4QR>'3$

L=>= #4L 
- ON
   %%(J<.&YZ  ">7J\I[\ )?|2cUS;;??>2$>;;??>::))#.',,##C(()sD   H)G=>HAH3=
H	HH0/H03!KA4KKc           
      `   U R                   R                  SS5      n/ / pvU(       d!  U R                   R                  SS5      (       a8  UR                  S5      =(       d    / nU(       d  U R                  SU S35        U$ U=(       a    [        U5      S:  nUc  UnU(       a  U(       d  U R	                  S	U S
35        U$ U(       a  U R                  U5      (       d  g[        [        U5      5      SSS2    GH  u  pU
R                  S5      =(       d    [        U
S   S5      nU(       a
  U
S    SU 3nU SU
S    3n[        X;UR                  S5      5      n[        XKUR                  S5      5      nU R                  X45      nU(       aQ  U R                  SR                  U(       a  UOU S
3R                  5       5      5        XS'   UR                  X45        OU R                  SU S35         U R                  [        U
S   U
R                  S0 5      S95      nU R                  SU SU 35        [!        US5       n["        R$                  " UU5        SSS5        UR                  X45        XS'   U(       d  GM  U(       a  GM    U$    U$ ! , (       d  f       N?= f! [&         a{  n[)        U[*        5      (       a4  UR,                  S:X  a$  U R                  SUR/                  5        S35        OU R1                  SU SU 35        UR3                  U	5         SnANSnAff = f) zeWrite thumbnails to file and return list of (thumb_filename, final_thumb_filename); or None if error write_all_thumbnailsFwritethumbnailr  z[info] There are no z thumbnails to downloadr   Nr  z
 thumbnailr  r   r   jpgr  r
  z thumbnail z[info] {} is already presentr  z[info] Downloading z ...r   )rE  r`  ra  wbi  r  z does not existzUnable to download r  )r%  r*  r  r  re  rK  r  r  rb   r   r  r   r  r  r  r   rg  r  copyfileobjr%   r  r!   statusr  rA  r  )r   r  r  r  thumb_filename_base	write_allr  r  multipler#  r  	thumb_extthumb_display_idthumb_filenamethumb_filename_finalexisting_thumbufthumbfr  s                      r   ru  YoutubeDL._write_thumbnails'  s   KKOO$:EB	bC(8%@@"|4:J!5eW<STU
4Z1!4&"*10zBCJd55h??9Z01$B$7FCeFah(FI wiq4	"'AdG9=.xIMMRWDXYN#45HU^UbUbchUi#j !//1E0VWN=DD(0$z6JJJL Z [ .*

NAB!45E4FdKL(gahnVX@Y&Z[BNN_5E4FeNK[#\]nd3v**2v6 4JJEF$2jM s99
? 8> 
 43 * (!#y11cjjC6G1A1G1G1I0J/'Z[++.ABRASSUVYUZ,[\NN3''(s2   7AJ(JJ(
J%	!J((
L-2A1L((L-)__header_cookiesr  ry  r|  rw  rs  rt  r}  r~  r  r  r  r  r  rx  r{  ru  rv  rz  rl  r  r  r%  rd  )r]  ru  r  )FNF)F)NNN)NNTr  )r  N)r  )FF)TNNTF)TN)T)r=  N)rY  )r  )r;  r<  r=  r>  __doc__r  r  r  rd  r@   common_audiocommon_videor  r|  r  r  r  r   r  r  r  r  r  r  r  r  r  r  r  r#  r1  r6  r:  r?  rE  rJ  rI  r\  rS   r  rt  rx  r{  r  rA  ra   r  r   re  r  r  r  r  r  r  staticmethodr  r  classmethodr  r  r  r  r   r  r  r  r  r  r  r   r  r  r  r  r   rK  r\  rD  rx  r  r  r  r  r  r  r  r  rC  r>  r@  r  rB  r  rj  r?  r  r  r   r  r  r  rv  r  r  r  r  ry  r=  r]  r5  r  rA  rt  rG  rQ  r  rd  re  rf  r  r  rN  r  r  r   cached_propertyr  rC  propertyr  r  r  r  r  r  r  rM  r  r  rs  rt  r  ru  r?  r=  r   r   r   r      s   ||	O
N (%! %2238#008%8+778WUrd$
?$ $%
() MW	9r
M.
.

"
 #D 
F	hZ_ 	h_ec
h :; [h
d/N5%$ %&
gN 5 5   
 
  eFN8 #6:d  #<8$U 8*Yv - -
 HL;@0Kd@ )+ ,\ 04 (<T. # #:$DCL1 
 
:tl #= #=AF%4N20X9t
"H51@9iv-
T
{z	:x&PF:#5J =A  #R #Rh
(& &, "$ "$H C C ?Ad 	6 
- 
-. 8< 	744(;!  
:x$BZHv\b\e>N   	 	 U U
:3 	H 	H>@!F X X.06p3r   r   )r  r  r  r  r  ri  r  r   http.cookiejarr  r  rL  rb  r  r  r  r  r  r  r  r  r$  r  rs  r  rT  rd  r  r   r  r   r   r   r   r   r	   r  r
   r   r   downloader.rtmpr   r  r   r   r   extractor.commonr   extractor.openloadr   globalsr   r   r   r   r   r   r   r   
minicursesr   
networkingr   r   r   networking.commonr   r    networking.exceptionsr!   r"   r#   r$   r%   networking.impersonater&   r'   r  r(   r  r)   postprocessorr*   r+   r,   r-   r.   r/   r0   r1   r2   r3   r4   r5   postprocessor.ffmpegr6   r  r  r7   r8   r9   r:   r;   r<   utilsr=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   rN   rO   rP   rQ   rR   rS   rT   rU   rV   rW   rX   rY   rZ   r[   r\   r]   r^   r_   r`   ra   rb   rc   rd   re   rf   rg   rh   ri   rj   rk   rl   rm   rn   ro   rp   rq   rr   rs   rt   ru   rv   rw   rx   ry   rz   r{   r|   r}   r~   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   r   utils._utilsr   r   r   utils.networkingr   r   r   r   r  r   r   r   r   r   r  r(  r   r   r=  r   r   <module>rM     s           	     	  	    
        % G G P P - S S . 0	 	 	 $ = = A  Q H    L X X X X X X X X X X X X X X X X X X X X X X Xr L K  M L77d?UB UBr   