a
    Ù;’hK ã                   @   s  d dl Z d dlZd dlZd dlZd dlZd dlZd dlZd dlZ	d dl
Z
d dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZd dlZddlmZ ddlmZ ddlmZ ddl m!Z!m"Z"m#Z# ddl$m%Z%m&Z&m'Z' ddl(m)Z) dd	l*m+Z+m,Z,m-Z- dd
l.m/Z/ ddl0m1Z1 ddl2m3Z3m4Z4m5Z5m6Z6m7Z7m8Z8m9Z9 ddl:m;Z; ddl<m=Z=m>Z>m?Z? ddl@mAZAmBZB ddlCmDZDmEZEmFZFmGZGmHZH ddlImJZJmKZK ddlLmMZNmOZO ddlPmQZQmRZRmSZSmTZTmUZUmVZVmWZWmXZXmYZYmZZZm[Z[m\Z\ ddl]m^Z_ ddl`maZambZbmcZcmdZdmeZe ddlfmgZgmhZhmiZimjZjmkZkmlZlmmZmmnZnmoZompZpmqZqmrZrmsZsmtZtmuZumvZvmwZwmxZxmyZymzZzm{Z{m|Z|m}Z}m~Z~mZm€Z€mZm‚Z‚mƒZƒm„Z„m…Z…m†Z†m‡Z‡mˆZˆm‰Z‰mŠZŠm‹Z‹mŒZŒmZmŽZŽmZmZm‘Z‘m’Z’m“Z“m”Z”m•Z•m–Z–m—Z—m˜Z˜m™Z™mšZšm›Z›mœZœmZmžZžmŸZŸm Z m¡Z¡m¢Z¢m£Z£m¤Z¤m¥Z¥m¦Z¦m§Z§m¨Z¨m©Z©mªZªm«Z«m¬Z¬m­Z­m®Z®m¯Z¯m°Z°m±Z±m²Z²m³Z³m´Z´mµZµm¶Z¶m·Z·m¸Z¸m¹Z¹mºZºm»Z»m¼Z¼m½Z½ ddl¾m¿Z¿mÀZÀmÁZÁ ddlÂmÃZÃmÄZÄmÅZÅmÆZÆ ddlÇmÈZÈmÉZÉmÊZÊmËZËmÌZÌ ejÍdkrüd dlÎZÎdd„ ZÏG dd„ dƒZÐdS )é    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Ú
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Ú_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                    s   t  ˆ ¡‡ fdd„ƒ}|S )Nc              
      s^   zˆ | g|¢R i |¤ŽW S  t yX } z(|  d|j›dtdƒ› ¡ W Y d }~n
d }~0 0 d S )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©Úfunc© úU/var/www/html/swiplay.fr/scambot/venv/lib/python3.9/site-packages/yt_dlp/YoutubeDL.pyÚwrapper¶   s    
þÿz._catch_unsafe_extension_error.<locals>.wrapper©Ú	functoolsÚwraps©r¦   r©   r§   r¥   r¨   Ú_catch_unsafe_extension_errorµ   s    	r®   c                   @   s’  e Zd ZdZh d£Zh d£Zdddddd	œZeej	ƒh ej
£d
’eejƒdœZddd„Zdd„ Zdd„ Zdd„ Zdd„ Zddd„Zdd„ Zdd„ Zdd „ Zd!d"„ Zd#d$„ Zdd&d'„Zdd(d)„Zdd*d+„Zdd,d-„Zd.d/„ Zd d0d1„Zd2d3„ Zd4d5„ Zd6d7„ Z d8d9„ Z!d:d;„ Z"d<d=„ Z#d!d>d?„Z$e%d@dAdBdBdCdDdEd@dFdG	Z&d"d%dHœdIdJ„Z'dKdL„ Z(dMdN„ Z)dOdP„ Z*d#dQdR„Z+dSdTœdUdV„Z,dWdX„ Z-dYdZ„ Z.d$d[d\„Z/d]d^„ Z0d_d`„ Z1d%ddaœdbdc„Z2ddde„ Z3dfdg„ Z4d&didj„Z5e6dkdl„ ƒZ7e6dmdn„ ƒZ8e9dodp„ ƒZ:e6dqdr„ ƒZ;d'dsdt„Z<dudv„ Z=e>dddwœdxdy„ƒZ?d(dd%dzœd{d|„Z@d)d}d~„ZAe6dd€„ ƒZBd*dd‚„ZCdƒd„„ ZDi fd…d†„ZEdd‡œdˆd‰„ZFd+dŠd‹„ZGeDdŒd„ ƒZHdŽd„ ZId,dd‘„ZJd’d“„ ZKe6d-d”d•„ƒZLd–d—„ ZMeDd˜d™„ ƒZNdšd›„ ZOd.dœd„ZPdždŸ„ ZQd d¡„ ZRd¢d£„ ZSd/d¤d¥„ZTd¦d§„ ZUd¨d©„ ZVdªd«„ ZWd0d¬d­„ZXd®d¯„ ZYd°d±„ ZZd1d²d³„Z[d´dµ„ Z\d¶d·„ Z]d2d¸d¹„Z^d3dºd»„Z_dd¼œd½d¾„Z`e>d¿dÀ„ ƒZadÁdÂ„ ZbdÃdÄ„ ZcdÅdÆ„ Zde6d4dÇdÈ„ƒZee6d5dÉdÊ„ƒZfi ddËœdÌdÍ„Zge6dÎdÏ„ ƒZhdÐdÑ„ ZiddÒœdÓdÔ„Zjd6dÖd×„Zkd7dØdÙ„ZldÚdÛ„ ZmdÜdÝ„ ZndÞdß„ Zoe6d8dádâ„ƒZpdãdä„ Zqdådæ„ Zrdçdè„ Zsdédê„ Ztdëdì„ Zudídî„ Zvdïdð„ Zwdñdò„ Zxdódô„ Zyd9död÷„Zzdødù„ Z{e|j}dúdû„ ƒZ~e|j}düdý„ ƒZe€dþdÿ„ ƒZd d„ Z‚dd„ Zƒdd„ Z„e6d:dd„ƒZ…dd	„ Z†d;d
d„Z‡e|j}dd„ ƒZˆdd„ Z‰dd„ ZŠd<dd„Z‹dd„ ZŒdd„ Zd=dd„ZŽdS (>  Ú	YoutubeDLa¯g  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
    writeannotations:  Write the video annotations to a .annotations.xml file
    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

    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, xattr_set_filesize, 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/avconv 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)
    include_ads:       - Doesn't work
                       Download ads as well
    call_home:         - Not implemented
                       Boolean, true if we are allowed to contact the
                       yt-dlp servers for debugging.
    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/avconv
                       if True, otherwise use ffmpeg/avconv if False, otherwise
                       use downloader suggested by extractor if None.
    prefer_ffmpeg:     - avconv support is deprecated
                       If False, use avconv instead of ffmpeg if both are available,
                       otherwise prefer ffmpeg.
    youtube_include_dash_manifest: - Use extractor_args
                       If True (default), DASH manifests and related
                       data will be downloaded and processed by extractor.
                       You can reduce network I/O by disabling it if you don't
                       care about DASH. (only for youtube)
    youtube_include_hls_manifest: - Use extractor_args
                       If True (default), HLS manifests and related
                       data will be downloaded and processed by extractor.
                       You can reduce network I/O by disabling it if you don't
                       care about HLS. (only for youtube)
    no_color:          Same as `color='no_color'`
    no_overwrites:     Same as `overwrites=False`
    >   Ú
start_timeZseason_numberÚabrÚend_timeÚrelease_yearÚfilesizeÚaudio_channelsZtrack_numberÚrelease_timestampÚwidthÚ	age_limitZepisode_numberÚasrZaverage_ratingZdislike_countÚdurationÚfpsÚtbrÚ	timestampÚfilesize_approxZrepost_countÚvbrZcomment_countÚheightZ
like_countZchapter_numberÚ
view_countZdisc_number>8   Ú
resolutionZsource_preferencer±   Úmanifest_urlÚprotocolZrtmp_real_timeZextra_param_to_segment_urlÚ	play_pathÚ
preferenceÚ	format_idZ	no_resumeÚis_dash_periodsÚformat_noter´   rµ   Zrequest_dataÚrowsr·   Zflash_versionÚextÚacodecZ	rtmp_liveÚvcodecr¹   Z
player_urlÚhttp_headersÚqualityÚhas_drmr»   ZappÚcolumnsZfragment_base_urlZtc_urlr¼   Zrtmp_protocolÚaspect_ratior¾   r¿   Zhls_media_playlist_dataÚstretched_ratioZmanifest_stream_numberÚdynamic_rangeZhls_aesÚ	fragmentsÚ	containerÚis_from_startÚcookiesrÀ   Zextra_param_to_key_urlZ	rtmp_connÚlanguageZlanguage_preferenceÚpage_urlÚformatÚurlZdownloader_optionsZalbum_artistsZartistsZ	composersZcreatorsZgenres)Zalbum_artistZartistZcomposerZcreatorZgenreZ3gp)ÚaudioÚvideoÚstoryboardsNTc              
      s¨  |du ri }|ˆ_ i ˆ_i ˆ_dd„ tD ƒˆ_tƒ ˆ_dˆ_g ˆ_g ˆ_	g ˆ_
g ˆ_dˆ_dˆ_dˆ_dˆ_tƒ ˆ_tˆƒˆ_g ˆ_tjstƒ  ˆj  d¡r¢tjntj}t|tjˆj  d¡rÂtjn|dˆ_z
tƒ  W n6 ty } zˆ d	|› ¡ W Y d}~n
d}~0 0 t t!t"tjtjfƒdƒˆj_#ˆj  d
¡rhˆj  d¡dur^ˆj  $dg ¡ %d¡ d
ˆj d< t& 'dd¡ (¡ dk‰t)t& 'd¡ƒ‰ ‡ ‡‡fdd„‰tf i ‡fdd„ˆjj*D ƒ¤Žˆ_+t,ƒ }|rÚˆ -| .dd¡¡ ˆj  d¡rˆ /dˆ 0dˆj1j2¡› dˆ 0dˆj1j3¡› d¡ ˆj  dd¡rzªddl4}| 5¡ \}}t6 7¡ j8}	|	du rVg n
dt9|	ƒg}
t:j;|ˆjj<d œ}zt=d!g|
¢fi |¤Žˆ_>W n0 t?yÀ   t=d"d#d$g|
¢fi |¤Žˆ_>Y n0 t& @|d%¡ˆ_AW nB t?y } z(|jBtBjCkrþˆ /d&¡ n‚ W Y d}~n
d}~0 0 tˆj  d'd(¡ƒˆj d'< tDtEˆj  d)¡ƒˆj d)< ˆ Fˆj d)  d*¡¡ ˆj d)  Gd*d¡ |r†|d+kr†ˆ H¡  ‡fd,d-„}|d.d/d0ƒrÂˆj  d1¡du rÂˆj d. ˆj d1< |d2d3d4ƒ |d5d6d7ƒ |d8d9d:ƒ ˆj  dg ¡D ]}ˆ /|¡ qôˆj  d;g ¡D ]}ˆ -|¡ qˆj  d<¡ }rTˆ I|¡sTtJd=|› d>ƒ‚d?ˆj d' v rndˆj d@< dAˆj vr ˆj  dB¡dur ˆj dB  ˆj dA< n4ˆj  dA¡du rÂˆj  GdAd¡ nˆj dA  ˆj dB< ˆj  dC¡du rtKˆj  dD¡ˆj  dE¡ˆj  dF¡fƒrdGˆj dC< ˆj  $dHi ¡ ˆj  $dIi ¡ tL|dH tMƒsVdJ|dH iˆj dH< |rdˆ N¡  tjOdKkr¢t P¡ dLv r¢ˆj  dMd¡s¢ˆ /dN¡ dˆj dM< ˆ Q¡  ˆj  dO¡dPv rÈˆj  dO¡n(tRˆj dO ƒrâˆj dO nˆ Sˆj dO ¡ˆ_TˆjUˆjVˆjWdQœ}| X¡ D ](\}}ˆj  |g ¡D ]}||ƒ q$qˆj  dRg ¡D ]>}tM|ƒ}| GdSdT¡}ˆjYtZ| GdU¡ƒˆfi |¤Ž|dV qF‡fdWdX„}|ˆj  dY¡ƒˆ_[dS )ZzðCreate 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
        Nc                 S   s   i | ]
}|g “qS r§   r§   ©Ú.0Úkr§   r§   r¨   Ú
<dictcomp>  ó    z&YoutubeDL.__init__.<locals>.<dictcomp>Tr   ZlogtostderrÚquiet)Úoutr¤   ÚscreenzFailed to enable VT mode: Úno_colorÚcolorÚ	_warningsz/Overwriting params from "color" with "no_color"ÚTERMÚ ÚdumbZNO_COLORc                    s   t jdt jdi|  }tˆjd|d fthtfƒp0d}|dv rnˆ }| d¡rR| d¡}ˆrjt	| ƒrj|rfdS dS d	S |d
v s~J |ƒ‚dd	dœ 
||¡S )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_colorr§   r¨   Úprocess_color_policy¬  s    

z0YoutubeDL.__init__.<locals>.process_color_policyc                    s"   i | ]\}}|d kr|ˆ |ƒ“qS )Úconsoler§   )rá   Únamerû   )r   r§   r¨   rã   ¹  s   ÿÚ
z
                    Úallow_unplayable_formatszYou have asked for Z
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 reportZbidi_workaroundFz-w)Ústdinrî   rï   ZbidivZfribidiz-czUTF-8Úrbz–Could not find fribidi executable, ignoring --bidi-workaround. Make sure that  fribidi  is an executable file in one of the directories in your $PATH.Úcompat_optsr§   rÎ   ÚCookieZno_verbose_headerc                    s.   ˆ j  | ¡d ur*ˆ  |› d|› d¡ dS dS )Nz is deprecated. Use z insteadTF)rõ   rú   Úreport_warning)ÚparamÚoptionZ
suggestion©r¡   r§   r¨   Úcheck_deprecatedå  s    z,YoutubeDL.__init__.<locals>.check_deprecatedZcn_verification_proxyz--cn-verification-proxyz--geo-verification-proxyZgeo_verification_proxyÚ
autonumberz--auto-numberz%-o "%(autonumber)s-%(title)s.%(ext)s"Zusetitlez--titlez-o "%(title)s-%(id)s.%(ext)s"Zuseidz--idz-o "%(id)s.%(ext)s"Z_deprecation_warningsÚimpersonateú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Ú
overwritesZnooverwritesÚsimulateÚlist_thumbnailsÚlistformatsÚlistsubtitlesÚ	list_onlyÚ
forceprintÚprint_to_filerÞ   Úwin32)ÚasciizANSI_X3.4-1968Úrestrictfilenamesz‡Assuming --restrict-filenames since file system encoding cannot encode all characters. Set the LC_ALL environment variable to fix this.rÛ   )Nú-)Z
post_hooksZprogress_hooksZpostprocessor_hooksZpostprocessorsÚwhenÚpost_processÚkey)r  c              
      s°   t ƒ }| du r|S t| ƒs| S ˆ  d| ›¡ zJt| ddd(}|D ]}| | ¡ ¡ qDW d  ƒ n1 sl0    Y  W n2 tyª } z|jtjkr–‚ W Y d}~n
d}~0 0 |S )z(Preload the archive, if any is specifiedNzLoading archive file Úrúutf-8©Úencoding)	Úsetro   Úwrite_debugrq   ÚaddÚstripÚOSErrorÚerrnoÚENOENT)ÚfnÚarchiveÚarchive_fileÚlineZioer  r§   r¨   Úpreload_download_archive?  s    2z4YoutubeDL.__init__.<locals>.preload_download_archiveÚdownload_archive)\rõ   Ú_iesÚ_ies_instancesrA   Ú_ppsr%  Ú_printed_messagesZ_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î   rP   Ú
_out_filesrŽ   Ú	Exceptionr&  ÚnextÚfilterr„   r  Ú
setdefaultÚappendÚosÚgetenvÚlowerÚboolÚitems_Ú_allow_colorsr6   Údeprecated_featureÚreplacer	  Ú_format_errÚStylesÚEMPHASISÚERRORÚptyÚopenptyÚshutilÚget_terminal_sizerÑ   rö   Ú
subprocessÚPIPEr¤   rS   Ú_output_processr)  ÚfdopenÚ_output_channelr*  r+  r”   r—   Ú_load_cookiesÚpopÚprint_debug_headerÚ_impersonate_target_availablerZ   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_processorr3   r-  )r¡   rõ   Z	auto_initrî   ÚeZsystem_deprecationrT  ZmasterZslaver·   Z
width_argsZ	sp_kwargsZoser  ÚmsgZimpersonate_targetÚhooksÚoptr,  ÚphZ
pp_def_rawZpp_defr  r0  r§   )rþ   r   r¡   rÿ   r¨   Ú__init__w  s   
ý
&ÿ
þýÿ
"ÿ
ÿ



ý

ÿþÿ
ýýþ
zYoutubeDL.__init__c                    sb   dd„ t ˆ ƒD ƒ‰ˆr^dg‡fdd„t ˆ ƒD ƒ dg ‡ fdd„ˆD ƒ }|  dt|ƒ› ¡ d S )Nc                 S   s    g | ]\}}t  d |¡r|‘qS )z^-[0-9A-Za-z_-]{10}$)ÚreÚmatch©rá   ÚiÚar§   r§   r¨   Ú
<listcomp>U  s   ÿz.YoutubeDL.warn_if_short_id.<locals>.<listcomp>zyt-dlpc                    s   g | ]\}}|ˆ vr|‘qS r§   r§   rw  )Úidxsr§   r¨   rz  [  rä   z--c                    s   g | ]}ˆ | ‘qS r§   r§   )rá   rx  )Úargvr§   r¨   rz  \  rä   zRLong argument string detected. Use -- to separate parameters and URLs, like this:
)Ú	enumerater	  r€   )r¡   r|  Zcorrect_argvr§   )r|  r{  r¨   Úwarn_if_short_idS  s"    ÿÿþþÿÿÿzYoutubeDL.warn_if_short_idc                 C   s4   |  ¡ }|| j|< t|tƒs0|| j|< | | ¡ dS )z3Add an InfoExtractor object to the end of the list.N)Úie_keyr2  ra  Útyper3  Úset_downloader)r¡   Úier  r§   r§   r¨   Úadd_info_extractorb  s
    


zYoutubeDL.add_info_extractorc                 C   s,   | j  |¡}|du r(t|ƒƒ }|  |¡ |S )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.
        N)r3  rú   r   rƒ  )r¡   r  r‚  r§   r§   r¨   r   j  s
    

zYoutubeDL.get_info_extractorc              
   C   sº   dd„ t ƒ D ƒ}tƒ |d< z6t| j ddg¡t|ƒdd„ | ¡ D ƒdœd	d
}W n6 tjy† } zt	d|j
› ƒ‚W Y d}~n
d}~0 0 |D ]}|  || ¡ qŒ|  dt|ƒ› d¡ dS )zZ
        Add the InfoExtractors returned by gen_extractors to the end of the list
        c                 S   s   i | ]}|j  ¡ |“qS r§   )ÚIE_NAMErJ  )rá   r‚  r§   r§   r¨   rã   z  rä   z9YoutubeDL.add_default_info_extractors.<locals>.<dictcomp>ÚendÚallowed_extractorsÚdefaultc                 S   s   g | ]\}}|j r|‘qS r§   )Z_ENABLED)rá   r  r‚  r§   r§   r¨   rz  €  rä   z9YoutubeDL.add_default_info_extractors.<locals>.<listcomp>)Úallr‡  T©Z	use_regexz$Wrong regex for allowed_extractors: NzLoaded z extractors)r   r   rv   rõ   rú   Úlistrm  ru  r¤   Ú
ValueErrorÚpatternrƒ  r&  Úlen)r¡   Zall_iesZie_namesro  r  r§   r§   r¨   rc  v  s    
þü
&z%YoutubeDL.add_default_info_extractorsr  c                 C   s4   |t v sJ d|› ƒ‚| j|  |¡ | | ¡ dS )z3Add a PostProcessor object to the end of the chain.zInvalid when=N)rA   r4  rG  r  )r¡   Úppr  r§   r§   r¨   rn  ˆ  s    zYoutubeDL.add_post_processorc                 C   s   | j  |¡ dS )zAdd the post hookN)r6  rG  ©r¡   rs  r§   r§   r¨   rj  Ž  s    zYoutubeDL.add_post_hookc                 C   s    t |ƒsJ dƒ‚| j |¡ dS )z9Add a close hook, called when YoutubeDL.close() is calledzClose hook must be callableN)rg  r7  rG  )r¡   Úchr§   r§   r¨   Úadd_close_hook’  s    zYoutubeDL.add_close_hookc                 C   s   | j  |¡ dS )zAdd the download progress hookN)r8  rG  r  r§   r§   r¨   rk  —  s    zYoutubeDL.add_progress_hookc                 C   s4   | j  |¡ | j ¡ D ]}|D ]}| |¡ qqdS )z$Add the postprocessing progress hookN)r9  rG  r4  Úvaluesrk  )r¡   rs  ZppsrŽ  r§   r§   r¨   rl  ›  s    z YoutubeDL.add_postprocessor_hookc                    sˆ   t ˆ dƒs|S t ˆ dƒsJ ‚t|tƒs*J ‚| d¡d }ˆ jj |d  ¡ ¡ ˆ jj ¡  d 	‡ fdd„t
|ƒD ƒ¡}|d tdƒ … S )Nr\  rZ  r  r   rì   c                 3   s   | ]}ˆ j  ¡  ¡ V  qd S ©N)r\  ÚreadlineÚdecode)rá   Ú_r  r§   r¨   Ú	<genexpr>«  s   ÿz-YoutubeDL._bidi_workaround.<locals>.<genexpr>)Úhasattrra  rö   ÚcountrZ  r  ÚwriteÚencodeÚflushÚjoinÚranger  )r¡   ÚmessageÚ
line_countÚresr§   r  r¨   Ú_bidi_workaround¢  s    
ÿzYoutubeDL._bidi_workaroundFc                 C   s8   |r|| j v rd S | j  |¡ t||| j d¡d d S )Nr$  )ræ   r$  )r5  r'  r   rõ   rú   )r¡   rŸ  ræ   Ú	only_oncer§   r§   r¨   Ú_write_string¯  s
    
zYoutubeDL._write_stringc                 C   sD   |dur|   d¡ |dur$|   d¡ |  |  |¡› d| jj¡ dS )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" insteadr  )r^   r¤  r¢  rB  ræ   )r¡   rŸ  Úskip_eolrå   r§   r§   r¨   Ú	to_stdout¶  s
    

zYoutubeDL.to_stdoutc                 C   sx   | j  d¡r | j d  |¡ dS |du r6| j  d¡rJn|rJ| j  d¡sJdS | jd |  |¡|rbdnd¡| jj|d dS )	z,Print message to screen if not in quiet modeÚloggerNrå   Úverbosez{}{}rì   r  ©r£  )rõ   rú   Údebugr¤  rÛ   r¢  rB  rç   )r¡   rŸ  r¥  rå   r£  r§   r§   r¨   Ú	to_screenÀ  s    &þzYoutubeDL.to_screenc                 C   sP   t |tƒsJ ‚| j d¡r,| jd  |¡ n | j|  |¡› d| jj|d dS )zPrint message to stderrr§  r  r©  N)ra  rö   rõ   rú   r¤   r¤  r¢  rB  ©r¡   rŸ  r£  r§   r§   r¨   Ú	to_stderrË  s    zYoutubeDL.to_stderrc                 C   s$   t | jjƒsdS |  || jj¡ dS )NFT)r„   rB  r  r¤  )r¡   Úcoder§   r§   r¨   Ú_send_console_codeÓ  s    zYoutubeDL._send_console_codec                 C   sp   | j  d¡sd S |rR|  dt|ƒ› d¡}|sRtjdkrRtjj 	¡ rRtjj 
|¡ t|tƒrl|  | |¡¡ d S )NÚconsoletitlez]0;úr   )rõ   rú   r¯  rz   rH  r  ÚctypesÚwindllÚkernel32ZGetConsoleWindowZSetConsoleTitleWra  r“   Zget_ansi_escape)r¡   rŸ  Úprogress_stateÚpercentÚsuccessr§   r§   r¨   Úto_console_titleÙ  s    
zYoutubeDL.to_console_titlec                 C   s*   | j  d¡r| j  d¡rd S |  d¡ d S )Nr°  r  z[22;0t©rõ   rú   r¯  r  r§   r§   r¨   Úsave_console_titleå  s    zYoutubeDL.save_console_titlec                 C   s*   | j  d¡r| j  d¡rd S |  d¡ d S )Nr°  r  z[23;0tr¹  r  r§   r§   r¨   Úrestore_console_titleê  s    zYoutubeDL.restore_console_titlec                 C   s   |   ¡  | jtjd | S ©N)rµ  )rº  r¸  r“   ZINDETERMINATEr  r§   r§   r¨   Ú	__enter__ï  s    zYoutubeDL.__enter__c                 C   s   | j  d¡d ur| j ¡  d S )NÚ
cookiefile)rõ   rú   Ú	cookiejarÚsaver  r§   r§   r¨   Úsave_cookiesô  s    zYoutubeDL.save_cookiesc                 G   s"   |   ¡  | jtjd |  ¡  d S r¼  )r»  r¸  r“   ZHIDDENÚclose)r¡   r¢   r§   r§   r¨   Ú__exit__ø  s    zYoutubeDL.__exit__c                 C   s6   |   ¡  d| jv r | j ¡  | `| jD ]
}|ƒ  q&d S )NÚ_request_director)rÁ  Ú__dict__rÄ  rÂ  r7  )r¡   Z
close_hookr§   r§   r¨   rÂ  ý  s    


zYoutubeDL.closec                 C   s(  |dur|   |¡ | j d¡r°|du r¢t ¡ d rŠd}tt ¡ d dƒrxt ¡ d jd rx|d tjt ¡ d jŽ ¡7 }|t	t 
¡ ƒ7 }nt t ¡ ¡}d |¡}|r°|   |¡ |s¸dS | j d¡st ¡ d rtt ¡ d dƒrt ¡ d jd rt ¡ d j}nt ¡ }t||ƒ‚d| _dS )a¢  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ô   rÆ  r˜  r  Ú	tracebackÚformat_exceptionra   Ú
format_excÚformat_listÚextract_stackrG   r:  )r¡   rŸ  ÚtbÚis_errorZtb_datarÆ  r§   r§   r¨   Útrouble  s*    

$

6
zYoutubeDL.troubleZyellowz
light blueZgreenZblueZredz	light redzlight black)	ÚHEADERSrR  ÚFILENAMEÚIDÚDELIMrS  Ú
BAD_FORMATÚWARNINGÚSUPPRESS©Útest_encodingc          	      C   st   t |ƒ}|rR|}| j d¡p*t|dd ƒp*d}| |d¡ |¡}|d urR||krR|}|du rdt||ƒS |d u rp|S |S )Nr$  r  ÚignoreT)rö   rõ   rú   Úgetattrr›  r•  r   )	r¡   ÚhandleZallow_colorsÚtextÚfÚfallbackrØ  Zoriginal_textr$  r§   r§   r¨   Ú_format_text4  s    zYoutubeDL._format_textc                 O   s"   | j | jj| jjg|¢R i |¤ŽS r“  )rß  rB  ræ   rM  ©r¡   r¢   r£   r§   r§   r¨   Ú_format_out?  s    zYoutubeDL._format_outc                 O   s"   | j | jj| jjg|¢R i |¤ŽS r“  )rß  rB  rç   rM  rà  r§   r§   r¨   Ú_format_screenB  s    zYoutubeDL._format_screenc                 O   s"   | j | jj| jjg|¢R i |¤ŽS r“  )rß  rB  r¤   rM  rà  r§   r§   r¨   rP  E  s    zYoutubeDL._format_errc                 C   sX   | j  d¡dur"| j d  |¡ n2| j  d¡r2dS |  |  d| jj¡› d|› |¡ dS )z‘
        Print the message to stderr, it will be prefixed with 'WARNING:'
        If stderr is a tty file the 'WARNING:' will be colored
        r§  NZno_warningszWARNING:ú )rõ   rú   Úwarningr­  rP  rQ  rÕ  r¬  r§   r§   r¨   r	  H  s
    zYoutubeDL.report_warningr   )Ú
stacklevelc                C   s   t ||d | jdd d S )Nr   F)rå  ÚprinterrÎ  )r^   rŸ   )r¡   rŸ  rå  r§   r§   r¨   r^   T  s    ÿzYoutubeDL.deprecation_warningc                 C   sL   | j  d¡d ur&| j d  d|› ¡ |  |  d| jj¡› d|› d¡ d S )Nr§  zDeprecated Feature: zDeprecated Feature:rã  T)rõ   rú   rä  r­  rP  rQ  rS  )r¡   rŸ  r§   r§   r¨   rN  X  s    zYoutubeDL.deprecated_featurec                 O   s2   | j |  d| jj¡› d|› g|¢R i |¤Ž dS )z
        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Ï  rP  rQ  rS  )r¡   rŸ  r¢   r£   r§   r§   r¨   rŸ   ]  s    zYoutubeDL.report_errorc                 C   sJ   | j  dd¡sdS d|› }| j  d¡r:| j d  |¡ n|  ||¡ dS )z,Log debug message or Print message to stderrr¨  FNú[debug] r§  )rõ   rú   rª  r­  r¬  r§   r§   r¨   r&  d  s    
zYoutubeDL.write_debugc                 C   s8   z|   d|› d¡ W n ty2   |   d¡ Y n0 dS )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_namer§   r§   r¨   Úreport_file_already_downloadedn  s    z(YoutubeDL.report_file_already_downloadedc                 C   s6   z|   d|› ¡ W n ty0   |   d¡ Y n0 dS )z*Report that existing file will be deleted.zDeleting existing file zDeleting existing fileNré  rë  r§   r§   r¨   Úreport_file_deleteu  s    zYoutubeDL.report_file_delete©rp  c                C   sh   |  d¡}| j  d¡t|ƒ }}|p.|r,dp.d}|s8|sZt||d |d |pR|pR|d‚n
|  |¡ d S )NÚ_has_drmÚignore_no_formats_errorzThis video is DRM protectedzNo video formats found!ÚidÚ	extractor)Úvideo_idr‚  Úexpected)rú   rõ   rK  rJ   r	  )r¡   ÚinfoZforcedrp  rÐ   Zignoredrõ  r§   r§   r¨   Úraise_no_formats|  s    

ÿzYoutubeDL.raise_no_formatsc                 C   s   |   d¡ |  ¡  | jd S )NzN"YoutubeDL.parse_outtmpl" is deprecated and may be removed in a future versionÚouttmpl)r^   rf  rõ   r  r§   r§   r¨   Úparse_outtmpl†  s    
zYoutubeDL.parse_outtmplc                    sd   t ‰| j d¡rdd„ ‰| j di ¡‰ tˆ tƒsBdˆ i | jd< ‰ ˆ  ‡ ‡fdd„t ¡ D ƒ¡ d S )Nr  c                 S   s   |   dd¡  dd¡S )Nú - rã  r  ©rO  ©Úxr§   r§   r¨   Ú<lambda>Ž  rä   z*YoutubeDL._parse_outtmpl.<locals>.<lambda>rø  r‡  c                    s(   i | ] \}}ˆ   |¡d u r|ˆ|ƒ“qS r“  ©rú   ©rá   râ   Úv©rø  Úsanitizer§   r¨   rã   “  rä   z,YoutubeDL._parse_outtmpl.<locals>.<dictcomp>)	r;   rõ   rú   rF  ra  rb  Úupdater:   rm  r  r§   r  r¨   rf  ‹  s    
zYoutubeDL._parse_outtmplrì   c                 C   sp   | j  di ¡}t|tƒs J dƒ‚tj t| dd¡ ¡ ƒ|rPt| |d¡ ¡ ƒnd|pXd¡}t	|| j  d¡dS )NÚpathsz&"paths" parameter must be a dictionaryÚhomerì   Úwindowsfilenames)Úforce)
rõ   rú   ra  rb  rH  Úpathr  rc   r(  r~   )r¡   Údir_typeÚfilenamer  r	  r§   r§   r¨   Úget_output_path•  s    ýzYoutubeDL.get_output_pathc                 C   sJ   d  tjtjdd¡}|  dd|› d¡ dd|› d¡} t| ƒ |d¡S )Nrì   é    ©râ   z%%ú%z$$ú$)r  ÚrandomÚchoicesÚstringÚascii_lettersrO  rc   )rø  Úsepr§   r§   r¨   Ú_outtmpl_expandpathž  s    $zYoutubeDL._outtmpl_expandpathc                 C   s   t  t dd¡dd„ | ¡S )z2 Escape any remaining strings like %s, %abc% etc. rì   z	(?![%( ])c                 S   s   |   d¡rdnd|   d¡ S )NÚhas_keyrì   r  r   ©Úgroup©Úmobjr§   r§   r¨   rþ  ²  rä   z*YoutubeDL.escape_outtmpl.<locals>.<lambda>)ru  ÚsubrB   rÛ   ©rø  r§   r§   r¨   Úescape_outtmpl­  s
    
ýzYoutubeDL.escape_outtmplc              
   C   sh   t  t dd¡dd„ |  |¡¡}z|  |¡t t¡  W dS  t	yb } z|W  Y d}~S d}~0 0 dS )z" @return None or Exception object ú[^)]*z
[ljhqBUDS]c                 S   s   |   d¡d d… › dS )Nr   éÿÿÿÿÚsr  r  r§   r§   r¨   rþ  º  rä   z,YoutubeDL.validate_outtmpl.<locals>.<lambda>N)
ru  r  rB   rÛ   r  r  ÚcollectionsÚdefaultdictÚintr‹  )Úclsrø  Úerrr§   r§   r¨   Úvalidate_outtmplµ  s    
ýzYoutubeDL.validate_outtmplc                 C   s$   t | ƒ} |  dd ¡ |  dd ¡ | S )NÚ__postprocessorsÚ__pending_error)rb  r^  ©Ú	info_dictr§   r§   r¨   Ú_copy_infodictÂ  s    zYoutubeDL._copy_infodictc           	   	      sX  ˆ  dtt ¡ ƒ¡ ˆ ˆ¡‰ˆ dd¡durDtˆd ˆr>dndƒndˆd< tˆj dd¡d ˆj ƒˆd	< ˆjˆd
< ˆ d¡du r–ˆj	ˆddˆd< t
ˆ d¡p¤dƒt
ˆ d¡p´dƒˆj d¡pÄddœ‰i ‰t t ddt› d¡¡}tjtjtjdœ‰dddi }d|d|› ddœ }d|› dt› d ‰d! d" ttjˆ ¡ ƒ¡¡‰t d#|› d$ˆ› ˆ› d%¡‰ d&d'„ ‰‡‡fd(d)„‰‡‡‡‡‡fd*d+„‰
ˆj d,d-¡‰‡fd.d/„‰	tˆƒrÀˆ d0¡ nLˆsÈnDtjd1krþˆj d2¡sþˆj d3¡d4u rþd5d6„ ‰n‡	‡fd7d6„‰d8d9„ ‰G d:d;„ d;tjƒ}|ƒ ‰‡ ‡‡‡‡	‡
‡‡‡f	d<d=„}| ||¡ˆfS )>z³ Make 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º   Nr  ú:Úduration_stringZautonumber_startr   r  Zvideo_autonumberrÂ   ©r‡  Ú__last_playlist_indexr   Ú	n_entriesZautonumber_sizeé   )Úplaylist_indexÚplaylist_autonumberr  r  ú[z	ljhqBUDS])ú+r  Ú*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                 S   s@   | dkrdS d| v r(t tt|  d¡ƒŽ S t| ƒd ur<t| ƒS | S )Nr.  .)ÚsliceÚmaprm   Úsplitr$  )r;  r§   r§   r¨   Ú_from_user_inputý  s    z3YoutubeDL.prepare_outtmpl.<locals>._from_user_inputc                    s°   dd„ t  d| ¡D ƒ} dD ]}| r| | s|  |¡ qt| ƒD ]b\}}| d¡s^ˆ |ƒ| |< q>| d¡s|J d|› d| › ƒ‚‡ fd	d
„|dd…  d¡D ƒ| |< q>tˆ| ddS )Nc                 S   s0   g | ](}|  d ¡r|gn| d¡D ]}|‘q"qS )Ú{Ú.©rù   r@  )rá   rý  rÝ  r§   r§   r¨   rz    s   ÿzIYoutubeDL.prepare_outtmpl.<locals>._traverse_infodict.<locals>.<listcomp>z\.({.+?})\.?)r   r   rB  Ú}zNo closing brace for z in c              	      s"   i | ]}|t tˆ | d ¡ƒƒ“qS )rC  )rŠ  r?  r@  rà   )rA  r§   r¨   rã     rä   zIYoutubeDL.prepare_outtmpl.<locals>._traverse_infodict.<locals>.<dictcomp>r   r   rž   T)Ztraverse_string)ru  r@  r^  r}  rù   rø   r‰   )Úfieldsrx  rÝ  )rA  r+  r§   r¨   Ú_traverse_infodict  s    
&z5YoutubeDL.prepare_outtmpl.<locals>._traverse_infodictc              	      s2  ˆ| d ƒ}| d r,t |ƒ}|d ur,|d9 }| d }|rút |ƒ}d }|rút |rTˆ nˆ|¡ d¡}|t|ƒd … }|d u r„ˆ| }qD|d dkr |dd … dfn|df\}}t |ƒ}|d u rÈt ˆ|ƒƒ}z|||| ƒ}W n ttfyò   Y d S 0 d }qD| d rt|| d  d	d
¡ƒ}ˆr.|dkr.d }|S )NrF  Únegater   Zmathsr   r  r   Zstrf_formatz\,rž   rì   )	rf   ru  rv  r  r  Ú	TypeErrorÚZeroDivisionErrorr‚   rO  )ZmdictrA  Z
offset_keyÚoperatorÚitemZ
multiplierÚoffset)ÚMATH_FIELD_REÚMATH_FUNCTIONSÚMATH_OPERATORS_RErG  r  r§   r¨   Ú	get_value  sD    
þþ(
z,YoutubeDL.prepare_outtmpl.<locals>.get_valueZouttmpl_na_placeholderZNAc                    s0   t t|ƒ|dˆ jd v r(tt d| ¡ƒntdS )Nzfilename-sanitizationr  z(^|[_.])id(\.|$))Ú
restrictedZis_id)r}   rö   rõ   rK  ru  Úsearchr>   )r   rA  rR  r  r§   r¨   Úfilename_sanitizer?  s
    
ÿýz5YoutubeDL.prepare_outtmpl.<locals>.filename_sanitizerzHPassing a callable "sanitize" to YoutubeDL.prepare_outtmpl is deprecatedr  r  r  Fc                 S   s   t |ƒ dd¡ dd¡S )Nú/u   â§¸ú rì   )rö   rO  ©r   rA  r§   r§   r¨   r  K  s    z+YoutubeDL.prepare_outtmpl.<locals>.sanitizec                    s   ˆ | |ˆj  d¡dS )Nr  ©rR  ©rõ   rú   rW  )rT  r¡   r§   r¨   r  N  s    c                 S   s   t | ttfƒrt| ƒS t| ƒS r“  )ra  r%  rN   rŠ  Úrepr©Úobjr§   r§   r¨   Ú_dumpjson_defaultQ  s    z4YoutubeDL.prepare_outtmpl.<locals>._dumpjson_defaultc                   @   s   e Zd Zdd„ ZdS )z8YoutubeDL.prepare_outtmpl.<locals>._ReplacementFormatterc                 S   s    |  ¡ r|d dfS tdƒ‚d S )Nr   r   zUnsupported field)Úisdigitr‹  )r¡   Ú
field_namer¢   r£   r§   r§   r¨   Ú	get_fieldW  s    zBYoutubeDL.prepare_outtmpl.<locals>._ReplacementFormatter.get_fieldN)Ú__name__Ú
__module__Ú__qualname__r`  r§   r§   r§   r¨   Ú_ReplacementFormatterV  s   rd  c                    s(  |   d¡s|   d¡S |   d¡}t ˆ |¡}d d ˆdf\}}}}|rª| ¡ }|d d ur^|d n|}ˆ|ƒ}|d |d  }}|d u rª|d rªt ˆ |d	 d
d … ¡}q>qªq>d ||fvräzˆ ||¡}W n tyâ   d ˆ }}Y n0 |   d¡}|dkr |ˆv r t|tƒr dˆ| d›d}|   d¡p.d}|d d… › d}	|d u rZ|d }}n>|d dkr d|v rvdnd}
|
 t	t
t|t
tfdƒ¡|	 }}nø|d dkrÜtj|ˆd|v rÄdnd d|vd|	 }}n¼|d dkr tt
|ƒƒ|	 }}n˜|d dkrBt	t
d|v r$t|ƒn|gƒ}t|dd|	 }}nV|d dkr€d|	›  ¡ t
|ƒ ¡  }| d d!¡d }}n|d d"krÆt d# d|v r¤d$ndd|v r´d%nd&¡|¡|	 }}nÒ|d d%kr|d d…  dd¡d }}t||rd|› d'nd(d|v rd)nd*d+}nz|d d,krFˆ||d|v d-|	 }}nR|d d.krn|rht
|ƒd }n|	}n*|d d/vr˜t|ƒ}|d u r˜|d }}ˆrð|d d0kr¼t|ƒ|	 }}n|d d1krØt|ƒ|	 }}|d d2v rðˆ||ƒ}d3 | dd4¡|   d¡¡}|ˆ|< d5j|||   d6¡d7S )8Nr  r   r   rì   r‡  rF  ÚreplacementÚ	alternateÚ	remainingr   rÛ   r!  Ú0ÚdÚ
conversionr   Úlú#r  ú, )Zallowed_typesÚjé   r7  )r‡  ÚindentÚensure_asciiÚhÚqT)ÚshellÚBr  r"  rÙ  ÚUzNF{}{}ÚKÚDÚCzf%sz%d%si   éè  )ZfactorÚSrX  ÚcÚrsar!  ry  Zcsraz{} {}z% z{prefix}%({key}){fmt}Úprefix)r   Úfmtr~  )r  ru  rv  Ú	groupdictrÛ   r‹  ra  r$  r  r?  rö   r   ÚbytesÚjsonÚdumpsrb   r€   r›  r•  ÚunicodedataÚ	normalizerO  rh   rf   rZ  r  )Z
outer_mobjr   r  rA  re  r‡  Z
last_fieldr  ÚflagsZstr_fmtÚdelimZnum_fmt)	ÚINTERNAL_FORMAT_REÚ	TMPL_DICTr]  Úfield_size_compat_maprT  rQ  ÚnaÚreplacement_formatterr  r§   r¨   Ú
create_key^  s–    



 
&þþ
&ýýÿ


z-YoutubeDL.prepare_outtmpl.<locals>.create_key) rF  r$  Útimer,  rú   rj   rõ   r;  r<  Úformat_resolutionrt   ru  ÚcompilerB   rÛ   rC   ÚfloatÚ__add__Ú__sub__Ú__mul__r?   r  r?  ÚescapeÚkeysrg  r^   rô   rd  r  Ú	Formatterr  )	r¡   rø  r+  r  ZEXTERNAL_FORMAT_REZFIELD_INNER_REZFIELD_RErd  r  r§   )rˆ  rN  rO  rP  r‰  r]  rA  rG  rŠ  rT  rQ  r+  r‹  rŒ  r  r¡   r¨   Úprepare_outtmplÉ  sj    
ÿý 
ýý
þþýý
	'
ÿ
PzYoutubeDL.prepare_outtmplc                 O   s,   | j ||g|¢R i |¤Ž\}}|  |¡| S r“  )r˜  r  )r¡   rø  r+  r¢   r£   r§   r§   r¨   Úevaluate_outtmpl°  s    zYoutubeDL.evaluate_outtmpl)rø  Ú	tmpl_typec             
   C   sh  d ||fv sJ dƒ‚|d u r<| j d  |p,d| j d d ¡}zÚ|  |¡}|  ||d¡}|s`W d S |dv r®| j  d¡| d¡ }}|rÐ|rÐ||krÐ| d|› ¡rÐt|||ƒ}n"|rÐt| }|rÐt||| d¡ƒ}| j  d	d
¡}|r| dd¡^}	}t|	d |… g|¢R ddiŽ}|W S  t	yb }
 z2|  
dt|
ƒ d ttƒ ƒ d ¡ W Y d }
~
d S d }
~
0 0 d S )Nz,outtmpl and tmpl_type are mutually exclusiverø  r‡  T©rì   ÚtempÚ	final_extrË   rC  Útrim_file_nameFé   r‡  zError in output template: z (encoding: r<  )rõ   rú   r  r™  rø   r|   r@   Úrsplitrp   r‹  rŸ   rö   rZ  rx   )r¡   r+  rø  rš  r  r  rË   Z	force_extrž  Zno_extr&  r§   r§   r¨   Ú_prepare_filename´  s0     
 $zYoutubeDL._prepare_filename)rø  Úwarnc                C   s”   |r|rJ dƒ‚d}| j |||d}|s4|dvr4dS |rx| j d¡sFn2|dkr^| jdd	d
 ntj |¡rx| jdd	d
 |dks„|sˆ|S |  ||¡S )zGenerate the output filenamez+outtmpl and dir_type are mutually exclusiveN)rš  rø  r›  rì   r  r  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ú   r	  rH  r	  Úisabsr  )r¡   r+  r
  rø  r¢  r  r§   r§   r¨   Úprepare_filenameÓ  s     zYoutubeDL.prepare_filenamec           	   
      s<  dˆj d v rdn
ˆ dd¡‰ ˆs2ˆ dks2J dƒ‚ˆ dˆ dd¡¡‰‡ ‡‡‡‡fd	d
„}ˆ ˆ¡r´d tˆdˆ dˆjj¡› dƒtˆdˆ dˆjj¡› dƒdf¡}dt	 }}nPz
|ƒ }W n: t
yø } z"|jdt|ƒ  }}}W Y d}~nd}~0 0 dt }}|dur8|s"ˆ d| ¡ ˆj  |d¡r8|ƒ ‚|S )z-Returns None if the file should be downloadedzplaylist-match-filterr  rÞ   Ú_typez,Only video result can be considered completeÚtitlerò  Úentryc               
      sž  ˆ dv rd S ˆ dv r*t ‡‡fdd„ƒs*d S dˆv r¦ˆd } ˆj dd¡}|rpt || tj¡spd|  d	 | d S ˆj d
d¡}|r¦t || tj¡r¦d|  d | d S ˆ d¡}|d uræˆj dtƒ ¡}||vræt|ƒ ¡ › d|› S ˆ d¡}|d urVˆj d¡}|d ur(||k r(dˆ||f S ˆj d¡}|d urV||krVdˆ||f S t	ˆ d¡ˆj d¡ƒr|dˆ› dS ˆj d¡}|d u r–d S d }	z<z|ˆˆd}
W n& t
yÒ   ˆrÆd n|ˆƒ}
Y n0 W n@ ty } z&|jturö‚ |j| }
}	W Y d }~n
d }~0 0 |
tu ršˆ ˆ ˆ¡ˆjj¡}tˆ d|› dˆjj¡ƒ ¡  ¡ }|dv rjd S |dkr"|	rŒt|	ƒdˆ› ƒ‚dˆ› S q"|
S )N©ÚplaylistZmulti_video©rÜ   Úurl_transparentc                      s   ˆ  ˆ d ¡ ˆ d ¡S )Nr  rÜ   )r   Zis_single_videor§   ©r+  r¡   r§   r¨   rþ  ó  rä   z>YoutubeDL._match_entry.<locals>.check_filter.<locals>.<lambda>r¦  Ú
matchtitleFú"z" title did not match pattern "Úrejecttitlez " title matched reject pattern "Úupload_dateZ	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ú   ru  rS  Ú
IGNORECASErE   r]   Ú	isoformatr[   rI  rF   rp  r>   râ  r¤  rQ  rÑ  ÚinputrR  rJ  r(  r€  )r¦  r­  r¯  ÚdateZ
date_rangerÁ   r±  r²  r³  Z	cancelledÚretr&  r  Zreply©r¥  rµ  r+  r¡   Zvideo_titler§   r¨   Úcheck_filterï  sp    
ÿ



"
ÿ

z,YoutubeDL._match_entry.<locals>.check_filterrì   ú%sú: rã  z(has already been recorded in the archiveÚbreak_on_existingr³  NZbreak_on_rejectrè  F)rõ   rú   Úin_download_archiver  ri   râ  rQ  rÒ  rR  rI   rF   rp  r€  rV   r«  )	r¡   r+  rµ  Zsilentr¾  ÚreasonZ	break_optZ	break_errro  r§   r½  r¨   Ú_match_entryè  s,    @
ý
,

zYoutubeDL._match_entryc                 C   s"   |  ¡ D ]\}}|  ||¡ qdS )z=Set the keys from extra_info in info dict if they are missingN)rm  rF  )r+  Ú
extra_infor   rA  r§   r§   r¨   Úadd_extra_infoC  s    zYoutubeDL.add_extra_infoc                 C   s(  |du ri }|s|rd}|r:|| j v r4|| j | ini }n| j }| ¡ D ]˜\}}	|	 |¡s\qH|	 ¡ sn|  d¡ |	 |¡}
|
durÆ|  |
|dœ¡rÆ|  d|  |
| j	j
¡› d¡ | j dd¡rÀt‚ q$|  ||  |¡|||¡  S | j d	¡dd
gfv}| jdt|ddƒ› d|› |rdndd dS )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 ©rÍ  )r2  rm  ÚsuitableÚworkingr	  Úget_temp_idrÂ  r«  râ  rQ  rÒ  rõ   rú   rI   Ú_YoutubeDL__extract_infor   rŸ   ri   )r¡   rÜ   Údownloadr  rÅ  ÚprocessÚforce_generic_extractorZiesr   r‚  Ztemp_idZextractors_restrictedr§   r§   r¨   Úextract_infoI  s.    


ÿzYoutubeDL.extract_infoc                    s   t  ˆ ¡‡ fdd„ƒ}|S )Nc                    sŒ  zˆ | g|¢R i |¤ŽW S  t ttjtjfy:   ‚ Y qˆ tyš } zJ|jr`|  |› d¡ n|  d¡ |  	|› d¡ W Y d }~q W Y d }~nðd }~0  t
yø } zH|j}|jrÒ|d d ttj|jƒ¡¡7 }|d7 }|  |¡ W Y d }~n’d }~0  ty0 } z |  t|ƒ| ¡ ¡ W Y d }~nZd }~0  ty€ } z8| j d¡rj| jt|ƒtt ¡ ƒd n‚ W Y d }~n
d }~0 0 qˆq d S )Nz; Re-extracting dataúz
This video is available in {}.rm  zL
You might want to use a VPN or a proxy server (with --proxy) to workaround.rÇ  rÉ  )r   rF   rN   Ú
IndexErrorrQ   rU   rõ  r«  r­  r	  rL   rp  Z	countriesrÛ   r  r?  rM   Z
short2fullrŸ   rJ   rö   Zformat_tracebackrC  rõ   rú   ra   rÈ  rÊ  )r¡   r¢   r£   ro  rp  r¥   r§   r¨   r©   |  s2    
 
ÿ(z8YoutubeDL._handle_extraction_exceptions.<locals>.wrapperrª   r­   r§   r¥   r¨   Ú_handle_extraction_exceptions{  s    z'YoutubeDL._handle_extraction_exceptionsc           	   
      sÐ  ˆj  d¡r0| dd¡dks0| d¡s0| d¡r4d S dd„ }d‰ ‡ ‡fd	d
„}ˆj  d¡\}}t|dd„ ƒ}|d u r°| d¡dkr°t|r˜|r˜t ||¡n|pž|dƒ}ˆ d¡ n|rÊ|pºddkrÊˆ d¡ tt|pÔd|pÚdƒ|pæt	dƒƒ}ˆ 
d||ƒ› d¡ t ¡ | }zZ|t ¡  }|dkr8|dƒ tddd‚|dˆ ||ƒˆjj¡› ƒ t d¡ qW nd tyŽ   |dƒ tddd‚Y n> tyÊ } z$t|tƒs´ˆ 
d¡ ‚ W Y d }~n
d }~0 0 d S )NÚwait_for_videor¥  rÞ   ÚformatsrÜ   c                 S   s   dt | d ƒd d…  S )Nz%02d:%02d:%02drz  r   )r‡   )Zdurr§   r§   r¨   rþ  ¡  rä   z+YoutubeDL._wait_for_video.<locals>.<lambda>rì   c                    sR   | › d}ˆj  d¡s4| dtˆ ƒt| ƒ   d }nˆ r<d S ˆj|dd | ‰ d S )Nr  Ú
noprogressrã  rÒ  T)r¥  )rõ   rú   r  r«  )rp  Zfull_msg©Zlast_msgr¡   r§   r¨   Úprogress¤  s    
z+YoutubeDL._wait_for_video.<locals>.progressc                 S   s   | d t   ¡  S )Nr¶   )rŽ  rü  r§   r§   r¨   rþ  ¯  rä   Úlive_statusZ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 nowz[wait] Wait period endedT)rõ  z*[wait] Remaining time until next attempt: r   z[wait] Interrupted by user)rõ   rú   r‹   Úroundr  Úuniformr	  ÚminÚmaxr‘  r«  rŽ  rU   râ  rQ  rR  ÚsleepÚKeyboardInterruptÚBaseExceptionra  )	r¡   Ú	ie_resultZ
format_durrÙ  Zmin_waitZmax_waitÚdiffZ	wait_tillro  r§   rØ  r¨   Ú_wait_for_video›  sF    ÿþþ
"
 

zYoutubeDL._wait_for_video©Ú	autoscopec                C   s  t |ƒ ¡ D ]}|r*t| ¡ ƒr*tdƒ‚| d¡p6d}| d¡}|dkrNd}tj | d¡p`d|j|j	dd|d	d	| d
¡p~dt
| d
¡ƒ| d¡p–d|dddi ¡}|r¶| j |¡ q|d	u rÖ|  d¡ | j |¡ q|r| jdtdd› d	d |  ||g¡ q| jdddd qdS )an  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	  Úsecurez³Passing 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©rÍ  rÎ  )r   r’  r÷   r‹  rú   Úhttpr¿  r  r   rA  rK  Ú
set_cookierN  r@  rG  r	  r\   Ú_apply_header_cookiesrŸ   )r¡   Údatarç  Úcookierè  ZexpiryZprepared_cookier§   r§   r¨   r]  É  s<    
ýÿÿýÿzYoutubeDL._load_cookiesc                 C   sL   t j |¡}|jsdS ttj|p$| jƒD ]}d|j› |_| j 	|¡ q(dS )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.
        NrC  )
r   ÚparseÚurlparseÚhostnamer?  Úcopyr@  rè  r¿  rï  )r¡   rÜ   rØ   Úparsedrò  r§   r§   r¨   rð  ó  s    zYoutubeDL._apply_header_cookiesc              
   C   sè   |   |¡ z| |¡}W nH ty` } z0|rJ| j d¡rB|  |¡ |  ¡  ‚ W Y d }~n
d }~0 0 |d u rˆ|  d|j› dtƒ › ¡ d S t	|t
ƒrœd|dœ}| d¡r¶| d|d ¡ |  |||¡ |rà|  |¡ |  |||¡S |S d S )NrÕ  z
Extractor z returned nothingÚcompat_list)r¥  ÚentriesÚoriginal_url)rð  ÚextractrY   rõ   rú   r	  rå  r„  r\   ra  rŠ  rF  Úadd_default_extra_infoÚprocess_ie_result)r¡   rÜ   r‚  rÎ  rÅ  rÏ  rã  ro  r§   r§   r¨   Z__extract_info  s.    


þ

zYoutubeDL.__extract_infoc                 C   sf   |d ur|   |||dœ¡ | d¡}|rB|   |t|ƒt|ƒdœ¡ |d urb|   ||j| ¡ dœ¡ d S )N)Úwebpage_urlrú  rþ  )Úwebpage_url_basenameÚwebpage_url_domain)ró  Úextractor_key)rÆ  rú   rŒ   rl   r„  r  )r¡   rã  r‚  rÜ   rþ  r§   r§   r¨   rü     s     þ
þþz YoutubeDL.add_default_extra_infoc              	      sà  ˆdu ri ‰ˆ  dd¡}|dv r6tˆd ˆj  d¡r:dndd	ˆd< ˆ  d
¡rjˆ  d
¡sjd
ˆd
 iˆ¥‰ˆj  dd¡}|dkrˆdˆv s’|du r6ˆ ¡ }tˆ  d¡ˆjƒ}|rÌˆ  d¡sÌ| ˆd ¡|d< ˆ ||ˆd ¡ ˆ |ˆ¡ ˆ 	|¡\}}ˆ 
|d¡ ˆ |¡ ˆ |¡ ˆj  dd¡r2ˆ |¡ ˆS |dkrÚˆ ˆˆ¡ ˆjˆˆd‰ˆ ˆ¡ ˆpli   d¡}	|	rÖt|	tƒrŒ|	g}	ˆ d ˆd t|	ƒ¡¡ ˆ d d |	¡¡¡ ‡‡‡fdd„|	D ƒˆd< ˆS |dkr ˆjˆd ˆˆ  d¡ˆdS |dkrªˆjˆd ˆ  d¡ˆddd}
|
s2|
S h d£‰ˆ  d¡sbˆ  d ¡du rbˆh d!£O ‰|
 ¡ }| tˆ‡fd"d#„ƒ¡ |  d¡dkršd|d< ˆj|ˆˆd$S |d%v r|ˆ  d&¡}|rö|ˆjv röˆ d' ˆ  d(¡¡pîˆ  d¡¡ dS ˆ jd)7  _ˆj |¡ ˆ 
ˆd¡ ˆ ˆ¡ z0ˆ ˆˆ¡W ˆ jd)8  _ˆjsTˆj ¡  S n"ˆ jd)8  _ˆjsxˆj ¡  0 n`|d*krÎˆ  d+ ˆ  d,¡¡¡ ‡‡fd-d.„‰ ‡ ‡‡‡fd/d„ˆd0 D ƒˆd0< ˆS t!d1|› ƒ‚dS )2zã
        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Ü   Zprefer_insecurerî  Úhttps)Úschemerú  Úextract_flatFZin_playlistr©  Tr  rò  Úforce_write_download_archive©rÎ  Úadditional_urlsz)[info] {}: {} additional URL(s) requestedzAdditional URLs: "{}"ú", "c              	      s&   g | ]}ˆj |ˆ ˆˆj d ¡d‘qS )rÐ  )rÅ  rÐ  )rÑ  rõ   rú   )rá   rÜ   )rÎ  rÅ  r¡   r§   r¨   rz  a  s
   ý
þz/YoutubeDL.process_ie_result.<locals>.<listcomp>Zadditional_entries)r  rÅ  r«  )r  rÅ  rÎ  rÏ  >   r¥  rÜ   r  Úsection_endÚsection_start>   r  rò  ró  c                    s   |d uo| ˆ vS r“  r§   ©râ   r  )Úexempted_fieldsr§   r¨   rþ    rä   z-YoutubeDL.process_ie_result.<locals>.<lambda>©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              	      s8   ˆ  | ˆ d ˆ d tˆ d ƒtˆ d ƒˆ d dœ¡ | S )Nró  rþ  r  )ró  rþ  rÿ  r   r  )rÆ  rŒ   rl   )r!  )rã  r¡   r§   r¨   Ú_fixup§  s    

ûz+YoutubeDL.process_ie_result.<locals>._fixupc                    s   g | ]}ˆ  ˆ |ƒˆˆ¡‘qS r§   ©rý  )rá   r!  )r  rÎ  rÅ  r¡   r§   r¨   rz  °  s   ÿ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_resultra  rö   r«  rÛ   r  r&  r  rÑ  r  re   rý  r>  r=  r'  Ú_sanitize_thumbnailsÚ_YoutubeDL__process_playlistÚclearr	  rC  )r¡   rã  rÎ  rÅ  Zresult_typer  Ú	info_copyr‚  r–  r  rö  Z
new_resultrþ  r§   )r  rÎ  r  rÅ  rã  r¡   r¨   rý  2  sÎ    
ÿ
ÿ




ÿü

ý
þÿ

ÿþ

ü  þ
ÿÿ	þ
zYoutubeDL.process_ie_resultc                 C   s   t || jƒS r“  )rs   rŸ   )r¡   r	  r§   r§   r¨   Ú_ensure_dir_exists¸  s    zYoutubeDL._ensure_dir_existsc                 K   sÀ   |   d¡|   d¡p|   d¡|   d¡|   d¡|   d¡|   d¡|   d¡|   d¡|   d¡d	œ	|¥}|rd|S |   d¡r”| | d t| d ƒt| d ƒd
œ¡ i |¥dt|   d¡pªdƒ| d | d dœ¥S )NÚplaylist_countr¦  rò  ZuploaderZuploader_idZchannelZ
channel_idrþ  )	r  r©  Zplaylist_idZplaylist_titleZplaylist_uploaderZplaylist_uploader_idZplaylist_channelZplaylist_channel_idZplaylist_webpage_url)rþ  rÿ  r   r   Úrequested_entries)r   r   ró  r  )r4  r1  ró  r  )rú   r  rŒ   rl   rß  )rã  Ústrictr£   rö  r§   r§   r¨   Ú_playlist_infodict»  s8    ÷
ö


ýÿûzYoutubeDL._playlist_infodictc                    sp  ˆ d dv sJ ‚| j ˆ dd}| d¡p*d}| j|dddurBdS |  d	ˆ d › d
|› ¡ t| ˆ ƒ}t| ¡ dd}| j d¡}|r¢g d }}	d\ˆ d< ˆ d< n4t|ƒ }}t	|ƒ}	t
t|Ž ƒpÈg g f\ˆ d< ˆ d< ˆ  d¡sì| ¡ ˆ d< | j ˆ t|	ƒd}
t ˆ |
¡}d}| j dd¡}|r:| j d¡r:|  ˆ ¡ |r¨| j d¡s¨|  dˆ |  |d¡¡}|du rrdS |  dˆ |  |d¡¡du r’dS |  dˆ |  |d¡¡ |rÚ| j d¡sÊ| j d¡r
| jddd n0| j d¡rò| ¡  n| j d¡r
t |¡ |  dˆ d › d |› d!|	› d"tˆ dd#ƒ› ¡ | j d$¡d%k}| j d$¡d&krfˆ d dk}|rv|  d'¡ d(}| j d)¡pŽtd*ƒ}t|ƒD ]>\}\}}|rº| ||f¡ |sÄq˜ˆ  d+¡|d+< |sôd,| jd- v rôˆ d | }t |i |¥t|	ƒ||d. d/œ¥¡}| j|dddur<|tf||< q˜|  d0|  |d. | j j!¡› d1|  |	| j j"¡› ¡ |  #||t ||d. d2œ|
¡¡}|sœ|d.7 }||krÄ|  $d3|› d4|› d5¡  qÚ|r˜||f||< q˜d6d7„ |D ƒˆ d< d8d7„ |D ƒˆ d< ˆ d t%‡ fd9d:„ƒkr"ˆ  &d¡ |du rP| jd;ˆ |  |d¡dd<du rPdS |  'dˆ ¡‰ |  d=|› ¡ ˆ S )>z"Process each entry in the playlistr¥  r¨  T)r  r©  z
<Untitled>r´  Nz[download] Downloading rÀ  )ÚlazyZlazy_playlistzN/A)NNr  rù  r  )r2  FZallow_playlist_filesr  r  Zpl_infojsonZpl_descriptionZpl_thumbnailZplaylistreverseZplaylistrandomzGplaylistreverse and playlistrandom are not supported with lazy_playlistr©  r6  ró  z] Playlist z: Downloading z itemsz of %sr  ÚdiscardZdiscard_in_playlistz>The information of all playlist entries will be held in memoryr   Zskip_playlist_after_errorsrÛ  Ú__x_forwarded_for_ipzplaylist-indexr  r   )r2  r4  r5  z[download] Downloading item z of )r4  r5  z,Skipping the remaining entries in playlist "z" since z items failed extractionc                 S   s   g | ]\}}|t ur|‘qS r§   ©r>   )rá   r–  ro  r§   r§   r¨   rz  ?  rä   z0YoutubeDL.__process_playlist.<locals>.<listcomp>c                 S   s   g | ]\}}|t ur|‘qS r§   r"  )rá   rx  ro  r§   r§   r¨   rz  @  rä   c                      s   t tdˆ d d ƒƒS )Nr   r  )rŠ  rž  r§   ©rã  r§   r¨   rþ  A  rä   z.YoutubeDL.__process_playlist.<locals>.<lambda>zupdated playlist)Ú	overwritez*[download] Finished downloading playlist: )(r  rú   rÄ  r«  rR   ru   Zget_requested_itemsrõ   rŠ  r  ÚtupleÚzipZget_full_countrm   r"  ÚChainMapr  Ú_write_info_jsonr¤  Ú_write_descriptionÚ_write_thumbnailsr	  Úreverser  Úshuffleri   r&  r‘  r}  rG  r>   râ  rQ  rÒ  rR  Ú"_YoutubeDL__process_iterable_entryrŸ   rŠ   r^  Úrun_all_pps)r¡   rã  rÎ  Zcommon_infor¦  Zall_entriesrù  r  Zresolved_entriesr2  ÚextraZie_copyÚ_infojson_writtenZwrite_playlist_filesZkeep_resolved_entriesZfailuresZmax_failuresrx  r4  r§  Z
entry_copyZentry_resultr§   r#  r¨   Z__process_playlistÙ  sÒ    

 

ÿ

ÿÿ


ÿ
ÿü
ÿÿþý
ÿ
þþzYoutubeDL.__process_playlistc                 C   s   | j |||dS )Nr  r  )r¡   r§  rÎ  rÅ  r§   r§   r¨   Z__process_iterable_entryO  s    ÿz"YoutubeDL.__process_iterable_entryc              
      s¬  t jt jt jt jt jt jdœ}t d 	d 
ttj| ¡ ƒ¡¡¡}| |¡‰ˆrÈztˆ d¡ƒ‰ W nX ty¸   tˆ d¡ƒ‰ ˆ du r–tˆ d¡d ƒ‰ ˆ du r´td 	ˆ d¡|¡ƒ‚Y n0 |ˆ d¡ ‰ˆs„t jd	d
„ dd
„ dd
„ dd
„ dœ}t d 	d 
ttj| ¡ ƒ¡¡¡}| |¡‰ˆr„ˆ d¡dkrDt ˆ d¡¡‰ nt ddˆ d¡¡‰ |ˆ d¡ ‰ˆ d¡r€‡fdd
„‰nˆ‰ˆs˜td|›ƒ‚‡ ‡‡fdd„}|S )zG Returns 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=  rA  Nru  z/Invalid value {!r} in format specification {!r}Úopc                 S   s
   |   |¡S r“  ©rù   ©ÚattrrA  r§   r§   r¨   rþ  u  rä   z0YoutubeDL._build_format_filter.<locals>.<lambda>c                 S   s
   |   |¡S r“  )rø   r6  r§   r§   r¨   rþ  v  rä   c                 S   s   || v S r“  r§   r6  r§   r§   r¨   rþ  w  rä   c                 S   s   |  | ¡d uS r“  )rS  r6  r§   r§   r¨   rþ  x  rä   )r3  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*
                r8  z
\\([\\"'])z\1Znegationc                    s   ˆ | |ƒ S r“  r§   r6  )Ústr_opr§   r¨   rþ  ‰  rä   zInvalid filter specification c                    s,   |   ˆ d¡¡}|d u r"ˆ d¡S ˆ|ˆ ƒS )Nr   Znone_inclusive)rú   r  )rÝ  Zactual_value)Úcomparison_valueÚmr4  r§   r¨   Ú_filter  s    
z/YoutubeDL._build_format_filter.<locals>._filter)rK  ÚltÚleÚgtÚgeÚeqÚneru  r  rÛ   r  r?  r•  r–  Ú	fullmatchr‘  r  r‹  rw   r  ÚSyntaxError)r¡   Zfilter_specZ	OPERATORSZoperator_rexZSTR_OPERATORSZstr_operator_rexr<  r§   )r:  r;  r4  r9  r¨   Ú_build_format_filterT  s`    úü

ÿÿ
ûú
zYoutubeDL._build_format_filterc                 c   s´  |D ]¨}|  d¡}|d ur(|r|V  q|  d |d ¡¡ |  d¡}|  |› d¡sXqtjdd|pfd d}| ¡  | j}zŒz| j	|j
|d	d
\}}	W n" tttgt¢R y¸   d}Y n0 W tj |j
¡rTzt |j
¡ W n( ty   |  d|j
› d¡ Y n0 nLtj |j
¡rRzt |j
¡ W n( tyP   |  d|j
› d¡ Y n0 0 || _||d< |r|| dd ¡ |V  qd|d › d}
|rž|  |
¡ q|  d|
› ¡ qd S )NZ	__workingz[info] Testing format {}rÇ   rœ  rU  z.tmpF)ÚsuffixÚdeleteÚdirT)Útestz!Unable to delete temporary file "r®  Ú__needs_testingzUnable to download format ú. Skipping...ú[info] )rú   r«  rÛ   r  r  ÚtempfileÚNamedTemporaryFilerÂ  r:  Údlr  rG   r)  r‹  r#   rH  r	  ÚexistsÚremover	  r^  )r¡   rÖ  rä  rÝ  rË  r	  Ú	temp_fileZoriginal_retcoder·  r–  rp  r§   r§   r¨   Ú_check_formats—  sH    


üzYoutubeDL._check_formatsc                 C   sB   t ||tdd„ |D ƒƒtdd„ |D ƒƒp8tdd„ |D ƒƒdœƒƒS )Nc                 s   s&   | ]}d |  d¡|  d¡fvV  qdS )ÚnonerÌ   rÍ   Nrÿ  ©rá   rÝ  r§   r§   r¨   r—  Á  rä   z,YoutubeDL._select_formats.<locals>.<genexpr>c                 s   s   | ]}|  d ¡dkV  qdS )rÍ   rT  Nrÿ  rU  r§   r§   r¨   r—  Â  rä   c                 s   s   | ]}|  d ¡dkV  qdS )rÌ   rT  Nrÿ  rU  r§   r§   r¨   r—  Ã  rä   )rÖ  Úhas_merged_formatÚincomplete_formats)rŠ  r÷   rˆ  )r¡   rÖ  Úselectorr§   r§   r¨   Ú_select_formats¾  s    üzYoutubeDL._select_formatsc                    s¤   ˆj d d dkp(| d¡o(ˆj  d¡ }‡fdd„}|sv|ƒ svd}ˆ |¡‰ ‡ ‡fd	d
„}|dƒ|dƒkrvˆ d¡ ˆj  d¡pŽdˆj d v }|r˜dS |r dS dS )Nrø  r‡  r  Úis_liveÚlive_from_startc                     s   t ˆ ƒ} | jo|  ¡ S r“  )r/   Ú	availableÚ	can_merge)Úmergerr  r§   r¨   r]  Ë  s    z1YoutubeDL._default_format_spec.<locals>.can_mergeTc                    s   ˆ  ˆ ˆ | ¡¡S r“  )rY  rh  )Úspec©rÖ  r¡   r§   r¨   rþ  Ò  rä   z0YoutubeDL._default_format_spec.<locals>.<lambda>zb/bv+bazbv*+ba/bzŸffmpeg 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_formatsr	  )r¡   r+  Zprefer_bestr]  Zevaluate_formatsÚcompatr§   r`  r¨   Ú_default_format_specÆ  s"    þ


ÿþzYoutubeDL._default_format_specc              	      sT  ‡fdd„‰d‰d‰d‰d‰t  dg d¢¡‰ ˆj d	d
¡ˆj dd
¡dœ‰
dd„ ‰dd„ }d$‡ ‡‡‡‡‡‡	‡fdd„	‰	‡
‡fdd„‰‡fdd„‰‡‡‡‡‡‡‡‡fdd„‰d tjtjdd¡‰t	 
t dˆ› dˆ¡ ¡ ¡}z&t|‡fdd„t |j¡D ƒƒƒ}W n( tjy,   ˆd d!tˆƒfƒ‚Y n0 G d"d#„ d#ƒ}ˆ	t||ƒƒƒ}ˆ|ƒS )%Nc                    s   d  | ˆ d|d  ¡}t|ƒS )Nz)Invalid format specification: {}
	{}
	{}^rã  r   )rÛ   rD  )ÚnoteÚstartrŸ  ©Úformat_specr§   r¨   Úsyntax_errorß  s
    ÿÿz5YoutubeDL.build_format_selector.<locals>.syntax_errorÚ	PICKFIRSTÚMERGEÚSINGLEÚGROUPÚFormatSelector)r€  rX  Úfiltersra  FZallow_multiple_video_streams©rÝ   rÞ   c                 S   sF   g }| D ]8\}}}}}|t jkr6|dkr6d |¡  S | |¡ qd S )Nú]rì   )ÚtokenizeÚOPr  rG  )ÚtokensZfilter_partsÚtype_Ústring_Ú_startr–  r§   r§   r¨   Ú_parse_filterî  s
    z6YoutubeDL.build_format_selector.<locals>._parse_filterc                 s   s&  d}d\}}}}| D ]ô\}}}}	}
|t jkrš|dkrš|rNt j||||fV  d }||||	|
fV  | D ]4\}}}}	}
||||	|
fV  |t jkrb|dkrb q˜qbq|t jkrØ||v rØ|rÆt j||||fV  d }||||	|
fV  q|t jt jt jfv r|s |}|}|	}q||7 }q|r"t j||||fV  d S )N)rU  r7  rž   ú(r<  )NNNNr6  rq  )rr  rs  ÚNAMEÚNUMBER)rt  ZALLOWED_OPSZlast_stringZ
last_startZlast_endÚ	last_lineru  rv  rf  r…  r/  r§   r§   r¨   Ú_remove_unused_opsö  s2    
z;YoutubeDL.build_format_selector.<locals>._remove_unused_opsc                    s   g }d }| D ]Ü\}}}}	}	|t tdd ƒkr0qq|tjtjfv rNˆ ˆ|g ƒ}q|tjkrÚ|dkrx|sn|  ¡   qìqê|r–|dv r–|  ¡   qìqê|r´|dkr´|  ¡   qìqê|dkrÚ|sÊˆd|ƒ‚| |¡ d }nþ|dkr|sòˆd|ƒ‚|}
ˆ| dd	}ˆ ˆ|
|fg ƒ}nÄ|d
krF|s0ˆ ˆdg ƒ}ˆ| ƒ}|j |¡ n’|dkrz|r`ˆd|ƒ‚ˆ| dd}ˆ ˆ|g ƒ}n^|dkrÆ|s”ˆd|ƒ‚|}ˆ| dd}|s´ˆd|ƒ‚ˆ ˆ||fg ƒ}nˆd|› d|ƒ‚q|tjkr qìq|rü| |¡ |S )NÚENCODINGr<  )rU  rž   rž   z!"," must follow a format selectorrU  z!"/" must follow a format selectorT)Úinside_choicer6  Úbestry  zUnexpected "(")Úinside_groupr7  zUnexpected "+")Úinside_mergezExpected a selectorzOperator not recognized: "r®  )	rÚ  rr  rz  r{  rs  Úrestore_last_tokenrG  ro  Ú	ENDMARKER)rt  r‚  r  r  Ú	selectorsZcurrent_selectorru  rv  rf  r–  Zfirst_choiceZsecond_choiceZformat_filterr  Ú
selector_1Ú
selector_2)rn  rm  rk  rj  rl  rx  Ú_parse_format_selectionri  r§   r¨   rˆ  	  sj    














z@YoutubeDL.build_format_selector.<locals>._parse_format_selectionc                    s¸  | \}}g ‰ ˆ   | d|f¡¡ ˆ   | d|f¡¡ ˆd rDˆd sÖdddœ}tˆ ƒD ]~\}}| d¡| d¡  kr~dkrŽn nˆ  |¡ qVd	D ]@}ˆ| s’| |d
 d ¡dkr’|| rÊˆ  |¡  qVd||< q’qVtˆ ƒdkrêˆ d
 S dd„ ˆ D ƒ}dd„ ˆ D ƒ}t|ƒdkr|d
 nd }	t|ƒdkr6|d
 nd }
tdd„ |D ƒdd„ |D ƒdd„ |D ƒdd„ |D ƒt‡fdd„ƒpŽˆj d¡oŽdd}‡ fdd„}ˆ d |dƒ¡d |dƒ¡|d t	t
ˆ ƒ¡d t|dƒƒ¡pàd d t|dƒƒ¡pöd t|d d!ƒƒpd t|d"d#d$ƒƒd%œ	}|	r‚| |	 d&¡|	 d'¡|	 d(¡pJˆ |	¡|	 d)¡|	 d*¡|	 d¡|	 d#¡|	 d+¡|	 d,¡d-œ	¡ |
r´| |
 d¡|
 d$¡|
 d.¡|
 d/¡d0œ¡ |S )1NÚrequested_formatsrÞ   rÝ   F)rÞ   rÝ   rÌ   rÍ   rT  rp  r   ÚcodecTr   c                 S   s   g | ]}|  d ¡dkr|‘qS )rÍ   rT  rÿ  ©rá   Úfmt_infor§   r§   r¨   rz  f	  rä   zCYoutubeDL.build_format_selector.<locals>._merge.<locals>.<listcomp>c                 S   s   g | ]}|  d ¡dkr|‘qS )rÌ   rT  rÿ  r‹  r§   r§   r¨   rz  g	  rä   c                 S   s   g | ]}|  d ¡‘qS )rÍ   rÿ  rU  r§   r§   r¨   rz  m	  rä   c                 S   s   g | ]}|  d ¡‘qS )rÌ   rÿ  rU  r§   r§   r¨   rz  n	  rä   c                 S   s   g | ]}|d  ‘qS ©rË   r§   rU  r§   r§   r¨   rz  o	  rä   c                 S   s   g | ]}|d  ‘qS r  r§   rU  r§   r§   r¨   rz  p	  rä   c                      s   ˆ j d  d¡S )NÚmerge_output_formatrU  )rõ   r@  r§   r  r§   r¨   rþ  q	  rä   zAYoutubeDL.build_format_selector.<locals>._merge.<locals>.<lambda>Zprefer_free_formats)ÚwebmÚmkv)ZvcodecsZacodecsZvextsZaextsÚpreferencesc                     s   t d ‡ fdd„ˆD ƒƒS )Nc                 3   s   | ]}t |gˆ ¢R Ž V  qd S r“  )r‰   )rá   r  ©r–  r§   r¨   r—  t	  rä   zTYoutubeDL.build_format_selector.<locals>._merge.<locals>.<lambda>.<locals>.<genexpr>)rE  r’  ©Zformats_infor’  r¨   rþ  t	  rä   r7  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  rk   rŠ   rõ   r  r?  r`   ru   Úsumr  r  )Zformats_pairZformat_1Zformat_2Zget_no_morerx  rŒ  Zaud_vidZ
video_fmtsZ
audio_fmtsZthe_only_videoZthe_only_audioZ
output_extÚfilteredZnew_dict)Úallow_multiple_streamsr¡   r“  r¨   Ú_mergeO	  sz    
$

ú÷÷üz/YoutubeDL.build_format_selector.<locals>._mergec                 3   sŠ   ˆ j  d¡dkr$ˆ  | ¡E d H  d S ˆ j  d¡d us@ˆ j  d¡rN| E d H  d S | D ]2}| d¡sj| d¡r~ˆ  |g¡E d H  qR|V  qRd S )NÚcheck_formatsÚselectedr  rÐ   rJ  )rõ   rú   rS  )rÖ  rÝ  r  r§   r¨   rS  ™	  s    
ÿ
z7YoutubeDL.build_format_selector.<locals>._check_formatsc                    sl  t | tƒr,‡fdd„| D ƒ‰‡fdd„‰ˆS | jˆkrDˆ| jƒ‰n| jˆkrr‡fdd„| jD ƒ‰‡fdd„‰nÔ| jˆkr tˆ| jƒ\‰
‰‡‡
‡fdd„‰n¦| jˆkrF| jp´d‰ˆd	krÎ‡fd
d„‰nxˆdkrè‡‡fdd„‰n^d\‰‰‰‰t dˆ¡}|d ur¾t| d¡dd‰| d¡d dk‰| d¡p>d gd ‰dddœ 	ˆ¡‰	| d¡d u}ˆ on| ‰ˆrˆ|rˆ‡fdd„n&ˆrš‡	fdd„n|s¨dd„ ndd„ ‰ ‡ fdd„‰nrˆˆj
d  v rÜ‡fd!d„‰nTˆˆj
d" v r‡fd#d„‰‡fd$d„‰n*ˆˆj
d% v r$‡fd&d„‰n‡fd'd„‰‡‡‡‡‡‡fd(d„‰‡fd)d„| jD ƒ‰‡‡fd*d+„}|S ),Nc                    s   g | ]}ˆ |ƒ‘qS r§   r§   ©rá   r!  ©Ú_build_selector_functionr§   r¨   rz  ª	  rä   zUYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.<listcomp>c                 3   s   ˆ D ]}|| ƒE d H  qd S r“  r§   )ÚctxrÝ  ©Úfsr§   r¨   Úselector_function¬	  s    z\YoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.selector_functionc                    s   g | ]}ˆ |ƒ‘qS r§   r§   r›  rœ  r§   r¨   rz  µ	  rä   c                    s&   ˆ D ]}t || ƒƒ}|r|  S qg S r“  ©rŠ  )rž  rÝ  Zpicked_formatsrŸ  r§   r¨   r¡  ·	  s
    
c                 3   s(   t  ˆ| ƒˆ| ƒ¡D ]}ˆ |ƒV  qd S r“  )Ú	itertoolsÚproduct)rž  Úpair)r˜  r†  r‡  r§   r¨   r¡  Á	  s    r€  rˆ  c                 3   s    ˆ | d d d d… ƒE d H  d S )NrÖ  r   r§   )rž  )rS  r§   r¨   r¡  Ê	  s    Zmergeallc                 3   sT   t ˆ dd„ | d D ƒƒƒ}|s"d S |d }|dd d… D ]}ˆ||fƒ}q8|V  d S )Nc                 s   s.   | ]&}|  d ¡dks"|  d¡dkr|V  qdS )rÍ   rT  rÌ   Nrÿ  rU  r§   r§   r¨   r—  Î	  s   zoYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.selector_function.<locals>.<genexpr>rÖ  r   éþÿÿÿr¢  )rž  rÖ  Zmerged_formatrÝ  )rS  r˜  r§   r¨   r¡  Í	  s    
ÿ
)FNTr   zS(?P<bw>best|worst|b|w)(?P<type>video|audio|v|a)?(?P<mod>\*)?(?:\.(?P<n>[1-9]\d*))?$r·  r   r0  Zbwr   Úbr€  ry  r  )r  ry  Úmodc                    s   |   ˆ › d¡dkS ©NrŠ  rT  rÿ  ©rÝ  )Úformat_typer§   r¨   rþ  å	  rä   zSYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.<lambda>c                    s   |   ˆ › d¡dkS r©  rÿ  rª  )Únot_format_typer§   r¨   rþ  ç	  rä   c                 S   s   |   d¡dko|   d¡dkS ©NrÍ   rT  rÌ   rÿ  rª  r§   r§   r¨   rþ  é	  rä   c                 S   s   dS ©NTr§   rª  r§   r§   r¨   rþ  ë	  rä   c                    s$   ˆ | ƒo"|   d¡dkp"|   d¡dkS r­  rÿ  rª  )Ú	_filter_fr§   r¨   rþ  ì	  s   rÝ   c                    s   |   d¡ˆ ko|   d¡dkS )NrË   rÌ   rT  rÿ  rª  rg  r§   r¨   rþ  ð	  rä   rÞ   c                    s*   |   d¡ˆ ko(|   d¡dko(|   d¡dkS ©NrË   rÌ   rT  rÍ   rÿ  rª  rg  r§   r¨   rþ  ò	  rä   c                    s   |   d¡ˆ ko|   d¡dkS )NrË   rÍ   rT  rÿ  rª  rg  r§   r¨   rþ  ó	  rä   rß   c                    s*   |   d¡ˆ ko(|   d¡dko(|   d¡dkS r°  rÿ  rª  rg  r§   r¨   rþ  õ	  rä   c                    s   |   d¡ˆ kS )NrÇ   rÿ  rª  rg  r§   r¨   rþ  ÷	  rä   c                 3   s°   t | d ƒ}ˆd ur"t tˆ|ƒƒn|}|sdˆrJ| d rJt tdd„ |ƒƒ}nˆrd| d sdt tˆ|ƒƒ}tˆ |d d ˆrvdnd… ƒƒ}z|ˆd  V  W n tjyª   Y d S 0 d S )NrÖ  rW  c                 S   s   |   d¡dkp|   d¡dkS r­  rÿ  rª  r§   r§   r¨   rþ  
  rä   znYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.selector_function.<locals>.<lambda>rV  r   r   )rŠ  rE  rN   rÓ  )rž  rÖ  Úmatches)rS  Úfilter_fÚformat_fallbackÚ
format_idxÚformat_reverseÚseperate_fallbackr§   r¨   r¡  ù	  s    c                    s   g | ]}ˆ   |¡‘qS r§   )rE  rU  r  r§   r¨   rz  
  rä   c                    s0   t | ƒ}ˆ D ]}tt||d ƒƒ|d< qˆ|ƒS )NrÖ  )rb  rŠ  rE  )rž  Zctx_copyr<  )ro  r¡  r§   r¨   Úfinal_selector
  s    zYYoutubeDL.build_format_selector.<locals>._build_selector_function.<locals>.final_selector)ra  rŠ  r€  rX  r?  ru  rv  rm   r  rú   Ú_format_selection_extsro  )rX  r  Zformat_modifiedr·  )rm  rk  rj  rl  r  rS  r˜  r¡   )r¯  r²  ro  r³  r´  rµ  rh  r«  r   r¬  r†  r‡  r¡  r¶  r¨   r  ¨	  sj    




þ
ÿÿÿÿùzAYoutubeDL.build_format_selector.<locals>._build_selector_functionrì   r  r  z\d[_\d]*z\g<0>c                 3   s$   | ]}|j |j ˆ d ¡dV  qdS )rì   )r  N)Ú_replacer  rO  )rá   Útoken)r~  r§   r¨   r—  
  s   ÿz2YoutubeDL.build_format_selector.<locals>.<genexpr>z/Missing closing/opening brackets or parenthesisr   c                   @   s0   e Zd Zdd„ Zdd„ Zdd„ ZeZdd„ Zd	S )
z6YoutubeDL.build_format_selector.<locals>.TokenIteratorc                 S   s   || _ d| _d S )Nr   )rt  Úcounter)r¡   rt  r§   r§   r¨   rt  "
  s    z?YoutubeDL.build_format_selector.<locals>.TokenIterator.__init__c                 S   s   | S r“  r§   r  r§   r§   r¨   Ú__iter__&
  s    z?YoutubeDL.build_format_selector.<locals>.TokenIterator.__iter__c                 S   s2   | j t| jƒkrt‚| j| j  }|  j d7  _ |S ©Nr   )r»  r  rt  ÚStopIteration)r¡   rA  r§   r§   r¨   Ú__next__)
  s
    z?YoutubeDL.build_format_selector.<locals>.TokenIterator.__next__c                 S   s   |  j d8  _ d S r½  )r»  r  r§   r§   r¨   rƒ  2
  s    zIYoutubeDL.build_format_selector.<locals>.TokenIterator.restore_last_tokenN)ra  rb  rc  rt  r¼  r¿  rD  rƒ  r§   r§   r§   r¨   ÚTokenIterator!
  s
   rÀ  )FFF)r"  Ú
namedtuplerõ   rú   r  r  r  r  r  ÚioÚBytesIOru  r  r›  rŠ  rr  r”  Ú
TokenErrorr  Úiter)r¡   rh  r}  rû   rt  rÀ  Zparsed_selectorr§   )rn  rm  rk  rj  rl  r  rS  r˜  rx  rˆ  r—  rh  r~  r¡   ri  r¨   rh  Þ  s4    ÿ:Jp
þzYoutubeDL.build_format_selectorc                 C   sP  t | jd | d¡ƒ}t|ƒ |rN| j| d¡|d d | j| d¡dd | dd ¡ | j |d ¡}|r*tƒ }g }|D ]œ}| 	|j
¡\}}	| |j› d|	› ¡ |jrÀ| d|j› ¡ |jrØ| d	|j› ¡ |jrè| d
¡ |jr| d|j› ¡ |jr~| d|j› ¡ q~d |¡|d< d|vrL| d¡}
|
rL|
|d< |S )NrÎ   r  rÜ   ræ  rØ   Fr3  zDomain=zPath=ÚSecurezExpires=zVersion=z; zX-Forwarded-Forr!  )r”   rõ   rú   r•   r]  r^  r¿  Zget_cookies_for_urlr   Úvalue_encoderA  rG  r  rè  r	  rë  ré  rê  r  )r¡   r+  r   r¡  rØ   Úencoderr’  rò  r–  rA  Zx_forwarded_for_ipr§   r§   r¨   Ú_calc_headers8
  s:    


zYoutubeDL._calc_headersc                 C   s   |   d¡ | j |¡S )NzN"YoutubeDL._calc_cookies" is deprecated and may be removed in a future version)r^   r¿  Úget_cookie_header)r¡   rÜ   r§   r§   r¨   Ú_calc_cookies\
  s    
zYoutubeDL._calc_cookiesc                 C   s   |j dd„ d d S )Nc                 S   st   |   d¡d ur|   d¡nd|   d¡d ur2|   d¡nd|   d¡d urL|   d¡nd|   d¡d urf|   d¡nd|   d¡fS )NrÆ   r   r·   rÀ   rò  rì   rÜ   rÿ  )Útr§   r§   r¨   rþ  a
  s    ûz,YoutubeDL._sort_thumbnails.<locals>.<lambda>©r   )Úsort)r¡   Ú
thumbnailsr§   r§   r¨   Ú_sort_thumbnails`
  s    zYoutubeDL._sort_thumbnailsc                    sô   |  d¡}|d u r2|  d¡}|r2d|ig |d< }|s:d S ‡ fdd„}ˆ  |¡ t|ƒD ]^\}}|  d¡d u rzt|ƒ|d< |  d¡r¦|  d¡r¦d	|d |d f |d
< t|d ƒ|d< qXˆ j  d¡du rèt||d d d… ƒdd|d< n||d< d S )NrÏ  Ú	thumbnailrÜ   c                 3   s–   | D ]Œ}ˆ   d|d › ¡ zˆ  t|d ƒ¡ W nV tyˆ } z>ˆ   d|d › d|d ›d|› d¡ W Y d }~qW Y d }~n
d }~0 0 |V  qd S )Nz[info] Testing thumbnail rò  rÜ   z&[info] Unable to connect to thumbnail z URL rú  rK  )r«  Úurlopenr   r#   )rÏ  rÌ  r&  r  r§   r¨   Úcheck_thumbnailsq
  s    &"z8YoutubeDL._sanitize_thumbnails.<locals>.check_thumbnailsrò  r·   rÀ   ú%dx%drÂ   r™  Tr   ©r+  )rú   rÐ  r}  rö   r   rõ   rN   )r¡   r+  rÏ  rÑ  rÓ  rx  rÌ  r§   r  r¨   r  h
  s$    



 zYoutubeDL._sanitize_thumbnailsc              	      s¶  |rZˆ   d¡ }ˆ d< |sZ|dkr.|  d¡ n
|  d¡ ˆ d  dd¡› d	ˆ d
 › ˆ d< ˆ   d¡d urxtˆ d ƒˆ d< dD ]v\}}ˆ   |¡d u r|ˆ   |¡d ur|t ttt	¡4 t
j ˆ | t
jj¡}| d¡ˆ |< W d   ƒ q|1 sè0    Y  q|ˆ   d¡stˆ ddd„ hfƒˆ d< d}ˆ   d¡}|d u r‚|D ]0}	ˆ   |	¡du rLq4ˆ   |	¡r\|	} qfq4t‡ fdd„|D ƒƒr‚d}|r¸|ˆ d< |D ]"}	ˆ   |	¡d u r”||	kˆ |	< q”|dkrÊdˆ d< dD ]L}
|rÎˆ   |
› d¡d urÎˆ   |
¡sÎd|
 ¡ ˆ |
› d f ˆ |
< qÎ| j ¡ D ]Š\}}|ˆ v rf|ˆ v rfdˆ vr®|  d |›d!|›d"¡ nHˆ   |¡ }r†| d#¡ˆ |< n(ˆ   |¡ }r&d# d$d„ |D ƒ¡ˆ |< q&d S )%Nr¦  Z	fulltitlerì   z4Extractor gave empty title. Creating a generic titlezDExtractor failed to obtain "title". Creating a generic title insteadró  r.  r  z video #rò  rº   r/  ))r½   r°  )r¶   Úrelease_date)Zmodified_timestampZmodified_datez%Y%m%dr³   rÖ  c                 S   s   t | d d… ƒS )Nro  )r$  rü  r§   r§   r¨   rþ  £
  rä   z/YoutubeDL._fill_common_fields.<locals>.<lambda>)rZ  Úwas_liverÚ  Fc                 3   s   | ]}ˆ   |¡d u V  qdS )FNrÿ  )rá   r   r*  r§   r¨   r—  ®
  rä   z0YoutubeDL._fill_common_fields.<locals>.<genexpr>Znot_liveZ	post_liveTr×  )ÚchapterZseasonZepisodeZ_numberz%s %dÚ_versionzDo not return z when z is presentrm  c                 s   s   | ]}|  d d¡V  qdS )rž   u   ï¼ŒNrû  )rá   r  r§   r§   r¨   r—  Å
  rä   )rú   r&  r	  rO  rj   Ú
contextlibÚsuppressr‹  ÚOverflowErrorr)  ÚdtÚdatetimeÚfromtimestampÚtimezoneÚutcÚstrftimer‰   rˆ  Ú
capitalizeÚ_deprecated_multivalue_fieldsrm  r^   r@  r  )r¡   r+  Úfinalr¦  Zts_keyZdate_keyr°  Z	live_keysrÚ  r   r;  Zold_keyZnew_keyÚ	old_valueÚ	new_valuer§   r*  r¨   r  ˆ
  sZ    
".



("
zYoutubeDL._fill_common_fieldsc                 C   s"   |  dd ¡}|r| j|dd d S )Nr)  FrÉ  )r^  rŸ   )r¡   rö  r&  r§   r§   r¨   r  Ç
  s    zYoutubeDL._raise_pending_errorsc                 C   s,   |   |¡}|jt| | d¡pg ƒjd d S )NÚ_format_sort_fieldsrÍ  )rb  rÎ  rK   rú   Zcalculate_preference)r¡   r+  rÖ  r§   r§   r¨   Úsort_formatsÌ
  s    
ÿzYoutubeDL.sort_formatsc           /   
      s¸  ˆ  dd¡dksJ ‚ˆ jd7  _dˆvr<tdˆd d‚nˆ  d¡sVtdˆd d‚‡fd	d
„‰‡fdd„‰‡‡fdd„}ˆˆdƒ |ˆƒ ˆ  d¡rÀˆ  d¡d urÀtˆd ˆd  dƒˆd< ˆ  d¡pÌddkrèˆ dd ¡rèˆ d¡ ˆ  d¡pôg }|r|d   d¡r| dddi¡ dˆ  d¡dœ}tt|g|¢R |g |dd … ¢|‘R ƒdƒD ]d\}\}}}	|  d¡d u r„|  d¡|d< |  d¡sž|	  d¡|d< |  d¡sXd|› d|d< qXdˆvrØd ˆd< d ˆd< ˆ 	ˆ¡ ˆ  d¡}
ˆ  d¡}|
r
t
|
ƒˆd< n|r |d  d! ˆd< ˆ  d"¡d u rFdˆv rFˆd ˆd"< ˆ ˆ¡ d#D ]v}ˆ  |¡}|rT| ¡ D ]V\}}|D ]F}|  d!¡rœt
|d! ƒ|d!< |  d$¡d u r|t|d! ƒ ¡ |d$< q|qpqTˆ  d%¡}ˆ  d&¡}ˆ ˆd ||¡ˆd'< ˆ ˆ¡}|p
i gd  d(d ¡}|r&|ˆd)< td*d+„ |D ƒƒp<d ˆd,< ˆj  d-¡s^d.d/„ |D ƒ}|rštd0d+„ |D ƒƒršˆ ˆd, rŠd1nd2› d3 ¡ ¡ ˆ  d4¡ p¶tˆj  d5¡ƒ‰ˆsÞˆd  d6tj ¡  d7¡ 7  < ˆ  d4¡r|r‡fd8d/„|D ƒ}ˆr|sˆjˆd9d: ‡‡fd;d<„}tt||p8g ƒƒ}|sNˆ ˆ¡ |D ]2‰ ˆˆ d=ƒ |ˆ ƒ t
ˆ d! ƒˆ d!< t ˆ ¡ ˆ d$ d>v r®ˆ   d?¡d u r®ˆ d$ ˆ d?< ˆ   d@¡d u rÐˆjˆ d dAˆ d@< ˆ   dB¡d u røˆ   dC¡dDkrødEˆ dB< ˆ   dF¡d u rt ‡ fdGdH„ƒˆ dF< dIˆjdJ v s8ˆ   dK¡sjˆ   dL¡sjˆ   dM¡sjt!ˆ   dN¡ˆ  d¡ƒˆ dM< ˆj"t# $ˆ ˆ¡dOdPˆ dQ< qRˆ  dQ¡r´t%ˆdQ ƒˆdQ< ˆdQ  dRd ¡ dSˆv rÄˆdS= ˆ &|ˆ  d)¡dTœ¡ i }t|ƒD ]P\}‰ ˆ   d=¡st'|ƒˆ d=< nt( )dUdVˆ d= ¡ˆ d=< | *ˆ d= g ¡ +ˆ ¡ qæt,t-j.ˆj/ 0¡ Ž ƒ}| ¡ D ]ª\}}t1|ƒdk}t|ƒD ]Š\}‰ |r|› dW|› ˆ d=< ˆ d= ˆ d$ krÂˆ d= |v rÂdX 2ˆ d= ¡ˆ d=< ˆ   dY¡d u rpdZj2ˆ d= ˆ ˆ ¡t3ˆ d[d\ƒd]ˆ dY< qpqTˆj  d^¡dOu r2t4ˆj5|d d d … d_d`dOda}|rF|d ˆurN|ˆdb< ˆ 6ˆ¡\‰}ˆj7ˆˆj8dcd urvˆS ˆ 9ˆ¡ ˆ 6ˆdd¡\‰}ˆ ˆ¡}ˆj  de¡dfk}| oºˆj:dWk}ˆj  dg¡rÔˆ ;ˆ¡ ˆj  dh¡rd%ˆv rþˆ <ˆd |di¡ ˆ <ˆd |d&¡ ˆj  dj¡s$|r.ˆ =ˆ¡ |rBˆ >ˆ¡ ˆS ˆj:}|rÔt?ˆ @dkˆjAjB¡dl ˆ @dmˆjAjB¡ ƒ}z|rˆˆ C|¡nd }W nD tDyÒ }  z*ˆjE| d_d_dn W Y d } ~ qHW Y d } ~ n
d } ~ 0 0 |d u 	rˆ Fˆ¡}ˆ Gdo|› ¡ ˆ C|¡}ˆ H||¡}!|	r6|!	s6ˆjEdpd_d_dn qH	q6qH|!	srˆj  dq¡	sbtdrdOˆd ˆd ds‚ˆ dp¡ i g}!tIˆj  dtdudH„ ¡ˆˆƒƒ}"|!d  g  }#}$|rª|#
r|"
r‡‡fdvdw„}%|%dxt1|!ƒ› dydzd+„ |!D ƒƒ |"i fk
r|%dxt1|"ƒ› d{d|d+„ |"D ƒƒ d_}&t- J|!|"¡D ]0\‰ }'ˆ Kˆ¡}(|( Lˆ ¡ ˆ  d¡
pDdˆ  d¡
pVtMd}ƒ })}*|)tN|'  d|*¡|*ƒ }+|+tMd}ƒk
s’|+|)|* d k
r–d }+|'
s¢|)
rÎ|( L|)|'  dd¡ |+|'  d¡|'  d~¡dœ¡ |$ +|(¡ zˆ O|(¡ W n tP
yþ   dO}&Y n0 ˆ Q|(¡ tI|( ¡ ƒD ]$\},}-ˆ  |,¡|-kr|( |,¡ q|&
r qL
qd€d„ |$D ƒ}.|. Rh d‚£¡snJ ‚dO|.v rŒd_|.vrŒˆ Sˆ¡ |$ˆdƒ< ˆ Td„ˆ¡‰|&rªtP‚ˆ L|#¡ ˆS )…Nr¥  rÞ   r   rò  z&Missing "id" field in extractor resultró  )r‚  zExtractor failed to obtain "id"c              	      s"   ˆ   d| › d|› d|› d¡ d S )Nr®  z" field is not z - forcing z+ conversion, there is an error in extractor)r	  )r;  Z	field_notrj  r  r§   r¨   Úreport_force_conversionÚ
  s    ÿz?YoutubeDL.process_video_result.<locals>.report_force_conversionc                    s<   |   |¡}|d u st|tƒr d S ˆ |ddƒ t|ƒ| |< d S )Nza stringr  )rú   ra  rö   )rö  Zstring_fieldr;  )rê  r§   r¨   Úsanitize_string_fieldß
  s
    
z=YoutubeDL.process_video_result.<locals>.sanitize_string_fieldc                    sJ   ˆj D ]>}|  |¡}|d u st|ttfƒr,qˆ |ddƒ t|ƒ| |< qd S )NÚnumericr$  )Ú_NUMERIC_FIELDSrú   ra  r$  r‘  rm   )rö  Znumeric_fieldr;  )rê  r¡   r§   r¨   Úsanitize_numeric_fieldsæ
  s    

z?YoutubeDL.process_video_result.<locals>.sanitize_numeric_fieldsr	  r
  é   rº   r   z<"duration" field is negative, there is an error in extractorÚchaptersr°   )r²   r°   r²   r¦  z<Untitled Chapter r2  r©  r4  rÑ  rÏ  r   rÜ   Z
display_id)Ú	subtitlesÚautomatic_captionsrË   rò  rñ  Úrequested_subtitlesZ__sort_fieldsrè  c                 s   s$   | ]}|  d ¡o|d  dkV  qdS )rÐ   ÚmaybeNrÿ  rU  r§   r§   r¨   r—  -  s   z1YoutubeDL.process_video_result.<locals>.<genexpr>rð  r  c                 S   s&   g | ]}|  d ¡r|d  dkr|‘qS )rÐ   rô  rÿ  rU  r§   r§   r¨   rz  0  rä   z2YoutubeDL.process_video_result.<locals>.<listcomp>c                 s   s2   | ]*}|  d ¡|  d¡  ko$dkn  V  qdS )rÌ   rÍ   rT  Nrÿ  rU  r§   r§   r¨   r—  2  rä   z This video is DRM protected and rì   zFonly images are available for download. Use --list-formats to see themrZ  r[  rã  z%Y-%m-%d %H:%Mc                    s"   g | ]}t | d ¡ƒˆ kr|‘qS )r×   )rK  rú   rU  )Úget_from_startr§   r¨   rz  ;  rä   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                    s4   |   d¡}|sˆ d¡ dS t|tƒr0ˆ | dƒ dS )NrÜ   zQ"url" field is missing or empty - skipping format, there is an error in extractorFT)rú   r	  ra  r  )rÝ  rÜ   )rë  r¡   r§   r¨   Úis_wellformedA  s    
ÿ

z5YoutubeDL.process_video_result.<locals>.is_wellformedrÇ   )ZaacZopusZmp3ZflacZvorbisrÌ   rÂ   r0  rÔ   rÍ   rT  ÚSDRrÒ   c                      s   t ˆ d ˆ d  dƒS )Nr·   rÀ   rŸ  )rÜ  r§   )r  r§   r¨   rþ  _  rä   z0YoutubeDL.process_video_result.<locals>.<lambda>zmanifest-filesize-approxr  rÃ   r´   r¾   r¼   T)r   rÎ   r  r!  )rÖ  rè  z[\s,/+\[\]()]r–  r  úf{}rÛ   z{id} - {res}{note}rÉ   rÈ  )rò  r¡  re  r™  F)rä  rÕ  rÖ  r´  Zafter_filterr  r  r  r  zautomatic captionsr  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‚  Zdownload_rangesc                  W   s   i gS r“  r§   )r–  r§   r§   r¨   rþ  Ö  rä   c               	      s.   ˆ  dˆ d › dd dd„ | D ƒ¡› ¡ d S )NrL  rò  rÀ  rã  c                 s   s   | ]}d   t|ƒ¡V  qdS )rm  N)r  r   ©rá   r;  r§   r§   r¨   r—  Û  rä   zDYoutubeDL.process_video_result.<locals>.to_screen.<locals>.<genexpr>)r«  r  rï  r¬  r§   r¨   r«  Ú  s    z1YoutubeDL.process_video_result.<locals>.to_screenzDownloading z format(s):c                 s   s   | ]}|d  V  qdS )rÇ   Nr§   rU  r§   r§   r¨   r—  Þ  rä   z time ranges:c                 s   s(   | ] }|d  d›d|d d›V  qdS )r°   z.1fr  r²   Nr§   )rá   r|  r§   r§   r¨   r—  á  rä   rÛ  Úindex)r
  r	  Zsection_titleZsection_numberc                 S   s   h | ]}|  d d¡’qS )Ú__write_download_archiveFrÿ  rU  r§   r§   r¨   Ú	<setcomp>   rä   z1YoutubeDL.process_video_result.<locals>.<setcomp>>   FTrÙ  Úrequested_downloadsZafter_video)Urú   r<  rJ   rÜ  r^  r	  Úinsertr}  r&  r  r   r  rm  r_   rJ  Úprocess_subtitlesrb  r÷   rõ   rˆ  rã  rK  rÝ  rÞ  Únowrâ  r÷  rŠ  rE  rK   Z_fill_sorting_fieldsr  rŠ   r†   rÉ  r"  r'  r”   ré  rö   ru  r  rF  rG  r%  r£  Úchainr¸  r’  r  rÛ   ri   rN   rS  r  rÄ  Ú_format_fieldsÚpost_extractri  r  Úlist_subtitlesÚlist_formatsr  rº  râ  rQ  rR  rh  rD  rŸ   rd  r&  rY  r%  r¤  r,  r  r‘  rÞ  Úprocess_inforO   r  Úissubsetr  r.  )/r¡   r+  rÎ  rî  rð  Zdummy_chapterÚidxÚprevÚcurrentZnext_rÑ  rÏ  Zcc_kindÚccr–  ÚsubtitleZsubtitle_formatrò  rñ  rÖ  Zfield_preferencerö  Zformats_dictrx  Zcommon_extsrÇ   Zambiguous_formatsZambigious_idr  Zinteractive_format_selectionri  Z
req_formatr&  Zformats_to_downloadZrequested_rangesZbest_formatZdownloaded_formatsr«  Zmax_downloads_reachedrØ  Únew_inforM  rº   r²   r   ÚvalZwrite_archiver§   )r  rõ  r+  rê  rë  r¡   r¨   r  Ñ
  sÚ   


 ÿÿ





 


ÿ
ÿ
ÿÿ ÿ



 ÿÿ
þ 
ý 




ÿ

ÿþ$


þ
ÿÿ

& ü





zYoutubeDL.process_video_resultc              
      sZ  i g  }}|r0| j  d¡r0| |¡ t| ¡ ƒ}|rb| j  d¡rb| ¡ D ]\}}||vrH|||< qH|r~| j  d¡s‚| j  d¡s‚dS t| ¡ ƒ}| j  dd¡r¢|}	n¾| j  dd¡rzt| j  d¡d|idd	}	W n8 tjy }
 zt	d
|
j
› ƒ‚W Y d}
~
n
d}
~
0 0 nTtt d|v r"dgng tdd„ |ƒd|v r@dgng tdd„ |ƒ||¡ƒdd… }	|	r‚|  d|› dd |	¡› ¡ | j  dd¡}|r | d¡ng }i }|	D ]¨}| |¡}|du rÜ|  |› d|› ¡ q¬|D ]H‰ ˆ dkrü|d } qJtt‡ fdd„|ƒƒ}|rà|d } qJqà|d }|  d |||d ¡¡ |||< q¬|S )z/Select the requested subtitles and their formatÚwritesubtitlesÚwriteautomaticsubNZallsubtitlesFZsubtitleslangsrˆ  Tr‰  zWrong regex for subtitlelangs: Úenc                 S   s
   |   d¡S ©Nr  r5  rª  r§   r§   r¨   rþ  *  rä   z-YoutubeDL.process_subtitles.<locals>.<lambda>c                 S   s
   |   d¡S r  r5  rª  r§   r§   r¨   rþ  ,  rä   r   rL  z: Downloading subtitles: rm  Zsubtitlesformatr€  rU  z subtitles not available for r   c                    s   | d ˆ kS )NrË   r§   rª  r  r§   r¨   rþ  >  rä   zsNo subtitle format found matching "{}" for language {}, using {}. Use --list-subs for a list of available subtitlesrË   )rõ   rú   r  r%  r–  rm  rv   ru  r¤   r‹  rŒ  rN   r£  r  rE  r«  r  r@  r	  rŠ  rÛ   )r¡   rô  Znormal_subtitlesrò  Zavailable_subsZnormal_sub_langsÚlangZcap_infoZall_sub_langsZrequested_langsro  Zformats_queryZformats_preferenceÚsubsrÖ  rÝ  r±  r§   r  r¨   rÿ    sv    



ÿ
þÿ
(ûú




ÿÿzYoutubeDL.process_subtitlesc           	   	   C   s¢  |d u rd S |  ¡ }| d|  |¡¡ | d¡d urRd dd„ |d D ƒ¡|d< n"| d¡rt|d | dd	¡ |d< |  |¡|d
< |  |¡|d< |  | d¡| d¡¡|d< |  | d¡| d¡¡|d< dd„ }| jd  |g ¡D ]}|  	|  
||ƒ|¡¡ qâ| jd  |g ¡D ]Œ\}}| j||d}||ƒ}|  d|›d|› ¡ |  |¡rt|ddd	d(}| |  
||¡tj ¡ W d   ƒ n1 s0    Y  q|S )Nr  r‰  r  c                 s   s"   | ]}|d  |  dd¡ V  qdS )rÜ   rÅ   rì   Nrÿ  rU  r§   r§   r¨   r—  Q  rä   z(YoutubeDL._forceprint.<locals>.<genexpr>ÚurlsrÜ   rÅ   rì   Zformats_tableZthumbnails_tablerò  rñ  Zsubtitles_tablerò  Zautomatic_captions_tablec                 S   sv   t  d| ¡}|s| S d}|  d¡r2d| › d } }|  d¡rN| d d… d } }d	 t|j| d
¡rh| gn|  d¡ƒ¡S )Nz+([\w.:,]|-\d|(?P<dict>{([\w.:,]|-\d)+}))+=?z%({})srB  rC  z%({})jr3  r   z{0} = %({0})#jr  rb  rž   )	ru  rC  rù   rø   r  r?  rÛ   r  r@  )Útmplr  r  r§   r§   r¨   Úformat_tmplY  s    

z*YoutubeDL._forceprint.<locals>.format_tmplr  r  r  ú[info] Writing ú to: ry  r"  ©r$  Únewline)rö  rF  r¤  rú   r  Úrender_formats_tableÚrender_thumbnails_tableÚrender_subtitles_tablerõ   r¦  r™  r«  r  Úopenrš  rH  Úlinesep)	r¡   r   r+  r  r  r  Z	file_tmplr  rÝ  r§   r§   r¨   Ú_forceprintJ  s.    
<zYoutubeDL._forceprintc                    sô   ˆj  d¡s,ˆj d  d¡s,ˆj d  d¡r6ˆ |¡ |rB||d< ˆ d|¡‰d‡ ‡‡fdd„	}|d	ƒ |d
ƒ |ddƒ |ddd |ddd |dƒ ˆj  d¡rÆˆ d¡d urÆˆ tˆd ƒ¡ |dƒ ˆj  d¡rðˆ t ˆ |¡¡¡ d S )NZ	forcejsonr  rÞ   r  r  Fc                    sF   |d u r| }ˆj  d| › ¡rBˆ | ¡d us4|sBˆ sBˆ ˆ| ¡ d S )Nr  )rõ   rú   r¦  )r;  Zactual_fieldÚoptional©rµ  r  r¡   r§   r¨   Úprint_field{  s    ÿÿÿz1YoutubeDL.__forced_printings.<locals>.print_fieldr¦  rò  rÜ   r  rÑ  T)r"  ÚdescriptionZforcedurationrº   rÛ   )NF)	rõ   rú   r  r!  r¦  rj   r‚  rƒ  Úsanitize_info)r¡   r+  r  rµ  r$  r§   r#  r¨   Z__forced_printingsr  s*    ÿþ

zYoutubeDL.__forced_printingsc              
   C   sú   |  d¡s|  |d¡ |rR| j  d¡}| j  d¡p6| }d|||ddddddœ	}n| j}t|||dkd| |ƒ}|sÆ| jD ]}	| |	¡ qzd	 d
d„ |  dg ¡p¤|gD ƒ¡}
|  d|j› d|
› d¡ |  	|¡}|  d¡d u rì|  
|¡|d< | |||¡S )NrÜ   Tr¨  rå   F)	rI  rå   r¨  r×  ZnopartZskip_unavailable_fragmentsZkeep_fragmentsr  Z_no_ytdl_filer  ©r¦  r  c                 s   s:   | ]2}|d    d¡r*|d   d¡d d n|d  V  qdS )rÜ   zdata:rž   r   z,<data>NrD  rU  r§   r§   r¨   r—  ¨  s   ÿzYoutubeDL.dl.<locals>.<genexpr>r‰  z	Invoking z downloader on "r®  rÎ   )rú   r÷  rõ   r
   r8  rk  r  r&  ÚFD_NAMEr,  rÉ  rÎ  )r¡   r  rö  r  rI  r¨  rå   rõ   Úfdrs  r  r  r§   r§   r¨   rO    s8    
÷

þ
zYoutubeDL.dl©Údefault_overwritec                C   sR   t ttjjt|ƒƒƒ}|r0| j d|¡s0|d S |D ]}|  |¡ t 	|¡ q4d S )Nr  r   )
rŠ  rE  rH  r	  rP  ru   rõ   rú   rî  rQ  )r¡   Ú	filepathsr+  Zexisting_filesÚfiler§   r§   r¨   Úexisting_file´  s    
zYoutubeDL.existing_filec           "   
      sÎ	  ˆ  dd¡dksJ ‚ˆ}dˆvr4dˆv r4ˆd ˆd< ˆ ˆ¡durNdˆd< dS ˆ ˆ¡ ‡fdd	„}ˆ ˆd¡\}}||ƒ ˆ jd
7  _ˆjˆdd ˆd< }ˆ ˆd¡}i }ˆjˆ|dˆvd ‡fdd„}	ˆj  d¡röˆj  d¡ˆd< |	ƒ  dS |du rdS ˆ |¡sdS ˆ |¡s$dS ˆ 	dˆˆ ˆd¡¡du rDdS ˆ 
ˆ|¡}
|
du r^dS | t|
ƒ¡ ˆ dˆ|ˆ ˆd¡¡}|du r’dS | t|ƒ¡ ˆ ˆd¡}ˆ dˆ|¡}|rÒ|ˆd< |ˆd< n|du ràdS d}ˆj  dd¡r ˆ ˆd¡}|rîˆ |¡sdS ˆj  dd¡s@tj |¡r@ˆ d¡ n®ˆ  d¡sXˆ d¡ n–zPˆ d | ¡ t|d!d"d#}| ˆd ¡ W d  ƒ n1 sœ0    Y  W nD ttfyÊ   ˆ d¡ Y n$ tyì   ˆ d$| ¡ Y dS 0 ‡‡fd%d&„‰ ˆj  d'¡ˆj  d(¡ˆj  d)¡d*œ}ˆj  d+¡r\tjd,kr>d-ntj d.¡rPd/nd0}d||< t‡ fd1d2„| ¡ D ƒƒr|dS ˆ ˆd3|¡\}}||ƒ ˆj  d4¡rö|ˆd5< tj tj  |¡¡ˆd6< |ˆd7< |ˆ !t"ˆdƒˆ¡ƒ ˆj  d¡ˆd< nªˆ #d8g ¡ z‡‡fd9d:„}d;\‰}ˆ  d<¡s4ˆ  d0¡r¢t$ˆˆj|d=kd>‰ˆt%kr¢d?ˆjd@ vr¢ˆ  dA¡szˆ  dB¡r¢t% &¡ rˆdCndD}ˆ |› dE¡ W dS ˆ  dF¡dur²ˆd ‰ˆj  dG¡du rˆd dHkrˆ  dI¡rtdJd2„ ˆj'dK D ƒƒrdLˆd< ˆ dM¡ ˆd ‰ˆf‡‡fdNdO„	}||ƒ}||ƒ}|||ƒ}dˆdP< t(t)tˆdF ƒƒˆdF< t*ˆƒ}g }|durˆˆ +|¡ nØˆrˆt%kr ˆdF ng D ]<}t,||ˆd ƒdQ -|dR ¡ˆd ƒ |d5< }| .|¡ q¤dS /dTd2„ ˆdF D ƒ¡ˆd0< ˆ 0|ˆ¡\}}|ˆdP< nFˆj  dU¡r4ˆ dV¡ n@|j&stdW}ˆj  dX¡sdˆ |› dY¡ W dS ˆ |› dZ¡ |d=kr¸t% 1ˆˆj¡r’d[n|j&ržd\nd]}ˆ d^|› d_¡ |}ˆdF D ]ž}tˆƒ}|dF= | |¡ |d=kr0t,|||d ƒdQ -|dR ¡|d ƒ}ˆ |¡s W dS ||d5< | .|¡ ˆ 0||¡\}}ˆdP pL|ˆdP< |oZ|}qÀ|rœ|j&rœˆj  dU¡sœˆd8  .|¡ |ˆd`< dˆdP< n|D ]}d||< q nB|||ƒ}|du sÐ||krêˆ 0|ˆ¡\}}|ˆdP< n
ˆ +|¡ |pü|}tj tj  |¡¡ˆd6< W n¦ t2yP } zˆ da|› ¡ W Y d}~dS d}~0  ty| } zt3|ƒ‚W Y d}~nLd}~0  t4y¾ } z*ˆ db|j5› dc|j6› dd¡ W Y d}~dS d}~0 0 ˆ 7ˆ¡ |	r |d=k	r ‡‡‡fdedf„} | ƒ  z|ˆ 8|ˆ|¡ƒ W n8 t9	y> } zˆ dg|› ¡ W Y d}~dS d}~0 0 zˆj:D ]}!|!ˆd5 ƒ 	qHW n8 t;	y– } zˆ dh|› ¡ W Y d}~dS d}~0 0 dˆd< ˆ|u 	s®J ‚ˆj  d¡	rÄdˆd< |	ƒ  dS )iz;Process a single resolved IE result. (Modifies it in-place)r¥  rÞ   rÛ   rË   NrÙ  rû  c                    s"   | ˆ krd S ˆ   ¡  ˆ  | ¡ d S r“  )r  r  )r  r*  r§   r¨   Úreplace_info_dictÏ  s    z1YoutubeDL.process_info.<locals>.replace_info_dictr   T)r¢  Ú	_filenamerœ  r´  c                      s"   ˆ j tˆ j d¡pdƒkrt‚d S )NÚmax_downloadsrÛ  )r;  r‘  rõ   rú   rO   r§   r  r§   r¨   Úcheck_max_downloadsâ  s    z3YoutubeDL.process_info.<locals>.check_max_downloadsr  r  r%  rÑ  ZinfojsonÚinfojson_filenameZ__infojson_filenameZwriteannotationsFÚ
annotationr  z,[info] Video annotations are already presentÚannotationsz"There are no annotations to write.z%[info] Writing video annotations to: Úwr"  r#  zCannot write annotations file: c                    sH  t ˆ d tƒ}|s,ˆ dˆ d › d¡ dS tˆ ˆ d¡| ˆ  d¡ƒ}ˆ |¡sTdS ˆj dd¡r„tj	 
|¡r„ˆ d	| › d
¡ dS z˜ˆ d| › d|› ¡ tt|ƒdd| dkr´dnddL}d|i}| dkrè|d t| ƒd  … |d< | t|  | ¡ W d   ƒ n1 s0    Y  W n& tyB   ˆ d|› ¡ Y dS 0 dS )Nrþ  z?Cannot write internet shortcut file because the actual URL of "z" is unknownTÚlinkrË   Fr  z[info] Internet shortcut (.z) is already presentz#[info] Writing internet shortcut (.z) to: r6  r"  rÜ   z
r  r  Údesktopr   r  zCannot write internet shortcut )r‹   rn   r	  r|   r¤  rú   r  rõ   rH  r	  rP  r«  r  rˆ   r  rš  r<   r)  rŸ   )Ú	link_typerÜ   ZlinkfnZlinkfileZtemplate_varsr¬  r§   r¨   Ú_write_link_file!  s4    ÿ
ÿ6z0YoutubeDL.process_info.<locals>._write_link_fileZwriteurllinkZwritewebloclinkZwritedesktoplink)rÜ   Úweblocr8  Z	writelinkÚdarwinr;  Úlinuxr8  rÜ   c                 3   s    | ]\}}|oˆ |ƒ V  qd S r“  r§   )rá   r9  Zshould_write)r:  r§   r¨   r—  E  s   ÿz)YoutubeDL.process_info.<locals>.<genexpr>Z	before_dlZskip_downloadÚfilepathZ
__finaldirÚ__files_to_mover(  c                     s\   ˆ  d¡‰ ‡ ‡fdd„}ˆjtjtt|| ƒ| ƒŽ dd}|rXtj |¡d dd … ˆd< |S )NrË   c                    s   t | ˆj d¡pˆ ˆ ƒS )Nr  )r|   rõ   rú   )r-  )rË   r¡   r§   r¨   rþ  Y  rä   zEYoutubeDL.process_info.<locals>.existing_video_file.<locals>.<lambda>Fr*  r   )	rú   r.  r£  r  r&  r?  rH  r	  Úsplitext)r,  Z	convertedr-  r¬  r  r¨   Úexisting_video_fileW  s    
ÿz3YoutubeDL.process_info.<locals>.existing_video_filer®  rÄ   r  r'  zno-direct-merger  r
  r	  z*This format cannot be partially downloadedzOYou have requested downloading the video partially, but ffmpeg is not installedz
. Abortingr‰  rŽ  r  rÏ  c                 s   s   | ]}t |ƒtkV  qd S r“  )r€  r(   ©rá   rŽ  r§   r§   r¨   r—  q  rä   r  r  z<webm doesn't support embedding a thumbnail, mkv will be usedc                    sR   | dkr| S t j | ¡d dd … }|ˆˆ fv r@t j | ¡d n| }|› d|› S )Nr  r   r   rC  )rH  r	  r@  )r  rË   Zfilename_real_extZfilename_wo_ext)Únew_extÚold_extr§   r¨   Úcorrect_extw  s    
ÿýz+YoutubeDL.process_info.<locals>.correct_extÚ__real_downloadrø  rÇ   r  c                 s   s   | ]}|d  V  qdS )rÜ   Nr§   rU  r§   r§   r¨   r—  ”  rä   r  zŸYou 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 installedrÇ  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 otherZ__files_to_mergezunable to download video data: zcontent too short (expected z bytes and served r<  c                     s–  d‰ ˆj  d¡} ˆd ‰| dv r$d S | dkr2d‰ n"| dkrT| dv sFJ ‚ˆ d¡sTd	‰ ‡ ‡‡‡fd
d„}ˆ d¡}||dvd|› tƒ dˆv rštˆˆj ƒnd }|r¨|jnd }ˆ d¡‰ˆ d¡pÚt‡fdd„ˆjd D ƒƒ}|sr|ˆtkoˆdkoˆ d¡dkdtƒ ||dkr(ˆj  d¡ pBˆ d¡oBˆj  d¡d u dt	ƒ ||dkojˆ d¡pjˆ d¡dt
ƒ ||d kd!tƒ ||d kd"tƒ d S )#NTÚfixuprò  )rÙ  ró   r¢  r  )Zdetect_or_warnNrF  Fc                    sd   ˆ r| sd S ˆ dkr,ˆ  ˆ› d|› ¡ d S |ˆƒ}|jrJˆd  |¡ nˆ  ˆ› d|› d¡ d S )Nr¢  rÀ  r(  z*. Install ffmpeg to fix this automatically)r	  r\  rG  )Zcndnrp  r%  rŽ  )Údo_fixupr+  r¡   Úvidr§   r¨   Úffmpeg_fixupì  s    z;YoutubeDL.process_info.<locals>.fixup.<locals>.ffmpeg_fixuprÓ   )r   NzNon-uniform pixel ratio rÄ   rË   r‰  c                 3   s0   | ](}t |tƒo&tˆ |jƒd  ˆ dfvV  qdS )r   N)ra  r1   Úresolve_recode_mappingÚmappingrB  r  r§   r¨   r—    s   þ
z8YoutubeDL.process_info.<locals>.fixup.<locals>.<genexpr>r  Zm4arÖ   Zm4a_dashz:writing DASH m4a. Only some players support this containerZ	hlsnativeZhls_use_mpegtsrZ  z=Possible MPEG-TS in MP4 container or malformed AAC timestampsZdashsegmentsrÈ   zPossible duplicate MOOV atomsZweb_socket_fragmentzMalformed timestamps detectedzMalformed duration detected)rõ   rú   r-   r
   r(  r÷   r4  r	   r,   r+   r)   r.   r*   )Zfixup_policyrJ  rÓ   Ú
downloaderZpostprocessed_by_ffmpeg)r)  r+  r¡   )rH  rË   rI  r¨   rG  Þ  sP    

þ
ýýýþz%YoutubeDL.process_info.<locals>.fixupzPostprocessing: zpost hooks: )<rú   rÄ  r  r  r;  r¤  r  rõ   r  r)  Ú_write_subtitlesr  rb  r*  r(  rH  r	  rP  r«  r	  r  rš  ÚKeyErrorrI  r)  rŸ   rô   rd  rù   r÷   rm  ÚdirnameÚabspathÚrun_ppr2   rF  r
   r	   r\  r4  rŠ  r?  r/   rí  ry   rÛ   rG  r  rO  Zcan_merge_formatsr#   rX   rD   rõ  Ú
downloadedr  r  rT   r6  rC  )"r¡   r+  Zoriginal_infodictr/  r  r–  Zfull_filenameZtemp_filenameÚfiles_to_mover2  Z	sub_filesZthumb_filesÚinfofnr0  ZannofnZannofileZwrite_linksr9  rA  r·  rp  rE  Zdl_filenamer^  rS  rÝ  ÚfnameZreal_downloadrÃ  Zpartial_successr-  r&  rG  rs  r§   )r:  r)  r+  rC  rD  r¡   r¨   r  ¾  s²   


ÿÿ
ÿ


2


ýþÿ
	ÿÿÿÿüÿ

þÿ
þ
ÿ

þ






8
zYoutubeDL.process_infoc                    s   t  ˆ ¡‡ ‡fdd„ƒ}|S )Nc               
      sÌ   zˆ | i |¤Ž}W n† t y&   ‚ Y n¢ tyR } zˆ |¡ W Y d }~n~d }~0  ty˜ } z0ˆ d|› ¡ ˆj d¡s~‚ dˆ_W Y d }~n8d }~0 0 ˆj dd¡rÈˆ |¡ ˆ 	t
 ˆ |¡¡¡ d S )NrL  Zbreak_per_urlr   Zdump_single_jsonF)r   rX   rŸ   rF   r«  rõ   rú   r;  r  r¦  r‚  rƒ  r&  )r¢   r£   r¡  ro  ©r¦   r¡   r§   r¨   r©   *  s    
z-YoutubeDL.__download_wrapper.<locals>.wrapperrª   )r¡   r¦   r©   r§   rW  r¨   Z__download_wrapper)  s    zYoutubeDL.__download_wrapperc                 C   sx   t |ƒ}| jd d }t|ƒdkrJ|dkrJd|vrJ| j d¡dkrJt|ƒ‚|D ]"}|  | j¡|| j dd¡d	 qN| jS )
zDownload a given list of URLs.rø  r‡  r   r  r  r1  rÐ  F)rÐ  )r   rõ   r  rú   rW   Ú_YoutubeDL__download_wrapperrÑ  r:  )r¡   Zurl_listrø  rÜ   r§   r§   r¨   rÎ  =  s    ÿþý
ÿzYoutubeDL.downloadc                    s,  t  tj|gdt d¡d¡2}‡ fdd„tt d |¡¡ƒD ƒ}W d   ƒ n1 sV0    Y  |D ]À}zˆ  	ˆ j
¡|dd W qd tttfyô } zVt|tƒsªˆ  d	¡ | d
¡}|d u r¾‚ ˆ  d|› d|› ¡ ˆ  |g¡ W Y d }~qdd }~0  ty" } zˆ  |¡ W Y d }~qdd }~0 0 qdˆ jS )Nr!  r"  )ÚmodeZopenhookc              	      s"   g | ]}ˆ   |ˆ j d d¡¡‘qS )Úclean_infojsonT)r&  rõ   rú   )rá   rö  r  r§   r¨   rz  R  s   ÿz5YoutubeDL.download_with_info_file.<locals>.<listcomp>r  Tr  rÒ  rþ  zThe info failed to download: z; trying with URL )rÚ  ÚclosingÚ	fileinputZ	FileInputZhook_encodedr   r‚  Úloadsr  rX  rý  rG   rH   rU   ra  r­  rú   r	  rÎ  rJ   rŸ   r:  )r¡   Zinfo_filenamerÝ  Úinfosrö  ro  rþ  r§   r  r¨   Údownload_with_info_fileM  s,    þ
ÿ$


 "z!YoutubeDL.download_with_info_filec                    sp   | du r| S |   dtt ¡ ƒ¡ |   dd¡ |   dttƒ ttdœ¡ |rRdd„ ‰nd	d„ ‰‡ ‡fd
d„‰ ˆ | ƒS )z. Sanitize the infodict for converting to json Nr-  r¥  rÞ   rÙ  )rê  r8   Zrelease_git_headÚ
repositoryc                 S   s   |d u p|   d¡p| dv S )NÚ__>   r0  r‰  r  r3  ró  r5  rù  r  rý  rú  r>  r5  r  r§   r§   r¨   rþ  r  rä   z)YoutubeDL.sanitize_info.<locals>.<lambda>c                 S   s   dS )NFr§   r  r§   r§   r¨   rþ  x  rä   c                    s~   t | tƒr"‡ ‡fdd„|  ¡ D ƒS t | ttttfƒrBttˆ | ƒƒS t | tƒrTt	| ƒS | d u snt | t	t
ttfƒrr| S t| ƒS d S )Nc                    s$   i | ]\}}ˆ||ƒs|ˆ |ƒ“qS r§   r§   r   ©Ú	filter_fnÚrejectr§   r¨   rã   |  rä   z>YoutubeDL.sanitize_info.<locals>.filter_fn.<locals>.<dictcomp>)ra  rb  rm  rŠ  r%  r%  rN   r?  r%   rö   r$  r‘  rK  rZ  r[  rb  r§   r¨   rc  z  s    

z*YoutubeDL.sanitize_info.<locals>.filter_fn)rF  r$  rŽ  rœ   r8   rš   r™   )r+  Zremove_private_keysr§   rb  r¨   r&  c  s    ü
zYoutubeDL.sanitize_infoc                 C   s   t  | |¡S )z3 Alias of sanitize_info for backward compatibility )r¯   r&  )r+  Zactually_filterr§   r§   r¨   Úfilter_requested_infoˆ  s    zYoutubeDL.filter_requested_info©rö  rp  c             	   G   sv   t td |ƒƒD ]b}|r$|  || ¡ zt |¡ W n" tyT   |  d|› ¡ Y n0 || dg ¡v r|d |= qd S )NzUnable to delete file r?  )r%  rE  r«  rH  rQ  r)  r	  rú   )r¡   rö  rp  Úfiles_to_deleter  r§   r§   r¨   Ú_delete_downloaded_files  s    z"YoutubeDL._delete_downloaded_filesc                    s   ‡ fdd„‰ ˆ | pi ƒ d S )Nc                    sP   |   d¡dv r0|   di ¡D ]}ˆ |p&i ƒ qd S |  dd ¡p>t}|  |ƒ ¡ d S )Nr¥  r¨  rù  Z__post_extractor)rú   r^  rb  r  )r+  Z
video_dictZpost_extractor©Úactual_post_extractr§   r¨   rj  š  s    z3YoutubeDL.post_extract.<locals>.actual_post_extractr§   r*  r§   ri  r¨   r  ˜  s    	zYoutubeDL.post_extractc              
   C   sÀ   g }d|vri |d< z|  |¡\}}W nP tyv } z8| j d¡du r`|  |¡ |W  Y d }~S ‚ W Y d }~n
d }~0 0 |s€|S | j dd¡rª|D ]}|d  |d¡ q’n| j||ddœŽ |S )	Nr?  rÇ  TZ	keepvideoFrì   z+Deleting original file %s (pass -k to keep)rf  )ÚrunrT   rõ   rú   rŸ   rF  rh  )r¡   rŽ  Zinfodictrg  ro  rÝ  r§   r§   r¨   rR  ¥  s&    
ÿzYoutubeDL.run_pp©Úadditional_ppsc                C   s<   |dkr|   ||¡ |pg | j|  D ]}|  ||¡}q&|S )NrÞ   )r!  r4  rR  )r¡   r   rö  rm  rŽ  r§   r§   r¨   r.  ¼  s
    zYoutubeDL.run_all_ppsr  c              
   C   s~   t |ƒ}|pi |d< z|  ||¡}W nH tyl } z0d|› }| d|¡ | j|dd W Y d }~n
d }~0 0 || dd ¡fS )Nr?  zPreprocessing: r)  F)rÎ  )rb  r.  rT   rF  rŸ   r^  )r¡   Zie_infor   rT  rö  r&  rp  r§   r§   r¨   r  Ã  s    
$zYoutubeDL.pre_processc                 C   sL   ||d< |pi |d< | j d|| d¡d}|  t| ƒ|¡}|d= |   d|¡S )z-Run all the postprocessors on the given file.r>  r?  r  r(  rl  Z
after_move)r.  rú   rR  r2   )r¡   r  rö  rT  r§   r§   r¨   r  Î  s    zYoutubeDL.post_processc                 C   sx   |  d¡}|sd S |  d¡p$|  d¡}|d u rnt|  d¡ƒ}|sDd S | j ¡ D ]\}}| |¡rN|} qnqNd S t||ƒS )Nrò  r  r  rÜ   )rú   r   r2  rm  rÊ  rr   )r¡   r+  rô  ró  rÜ   r  r‚  r§   r§   r¨   Ú_make_archive_id×  s    

zYoutubeDL._make_archive_idc                    s@   ˆ j s
dS ˆ  |¡g}| | d¡p&g ¡ t‡ fdd„|D ƒƒS )NFZ_old_archive_idsc                 3   s   | ]}|ˆ j v V  qd S r“  )r-  )rá   Zid_r  r§   r¨   r—  ñ  rä   z0YoutubeDL.in_download_archive.<locals>.<genexpr>)r-  rn  r”  rú   r÷   )r¡   r+  Zvid_idsr§   r  r¨   rÂ  ë  s
    zYoutubeDL.in_download_archivec                 C   sŽ   | j  d¡}|d u rd S |  |¡}|s*J ‚|  d|› ¡ t|ƒr~t|ddd}| |d ¡ W d   ƒ n1 st0    Y  | j |¡ d S )Nr1  zAdding to archive: ry  r"  r#  r  )	rõ   rú   rn  r&  ro   rq   rš  r-  r'  )r¡   r+  r,  Zvid_idr.  r§   r§   r¨   r  ó  s    
,z!YoutubeDL.record_download_archiveÚunknownc                 C   s   |   d¡dkr |   d¡dkr dS |   d¡d ur6| d S |   d¡r^|   d¡r^d| d | d f S |   d¡rvd	 | d ¡S |   d¡rŒd
| d  S |S )NrÍ   rT  rÌ   ú
audio onlyrÂ   r·   rÀ   rÔ  z{}pz%dx?)rú   rÛ   )rÛ   r‡  r§   r§   r¨   r     s    

zYoutubeDL.format_resolutionc                    s(   ˆ j  dd¡dur$‡ fdd„|D ƒS |S )Nr  TFc                    s   g | ]}ˆ   |ˆ jj¡‘qS r§   )rá  rQ  rÐ  )rá   Úheaderr  r§   r¨   rz    rä   z2YoutubeDL._list_format_headers.<locals>.<listcomp>rY  )r¡   Úheadersr§   r  r¨   Ú_list_format_headers  s    zYoutubeDL._list_format_headersc                 C   sœ  d}|  d¡dv r|d7 }|  d¡rB|r0|d7 }|d |d ¡7 }|  d¡d urh|r\|d7 }||d 7 }|  d	¡d ur’|r‚|d
7 }|d|d	  7 }|  d¡d ur¾|r¬|d
7 }|d |d ¡7 }|  d¡d ur|  d¡dkr|rê|d
7 }||d 7 }|  d¡d ur8|d7 }n(|  d¡d ur8|  d¡d ur8|d7 }|  d¡d urX|d|d  7 }|  d¡d urˆ|rv|d
7 }|d |d ¡7 }|  d¡d urÐ|r¦|d
7 }|d dkr¾|d7 }n|d|d  7 }n&|  d¡d urö|rî|d
7 }|d7 }|  d¡d ur|d|d  7 }|  d¡d ur6|d|d  7 }|  d¡d urf|rT|d
7 }|t|d ƒ7 }n2|  d¡d ur˜|r„|d
7 }|dt|d ƒ 7 }|S ) Nrì   rË   ©Zf4fZf4mz(unsupported)rÙ   rã  z[{}]rÉ   r¼   rm  z%4dkrÖ   z{} containerrÍ   rT  r¿   ú@r±   zvideo@r»   z{}fpsrÌ   ú
video onlyz%-5srÝ   z@%3dkr¹   z (%5dHz)r´   r¾   ú~)rú   rÛ   rg   )r¡   Zfdictr¡  r§   r§   r¨   Ú_format_note  st    
ÿ
 
zYoutubeDL._format_notec                 C   s:   |  d¡d u r2|  d¡r.|  dd¡dkr.|gS g S |d S )NrÖ  rÜ   r¥  rÞ   rÿ  ©r¡   r+  r§   r§   r¨   rb  O  s
    zYoutubeDL._get_formatsc                    sÎ   ˆ  ˆ¡}|sd S ˆj dd¡du rH‡fdd„|D ƒ}tg d¢|ddS ‡fd	d
„‰ˆjdˆjjddd‰ ‡ ‡‡‡fdd„|D ƒ}ˆ ddddddˆ dddˆ dddddd¡}t||dˆjdˆjjdddd S )!Nr  TFc                    sB   g | ]:}|  d ¡pddkrt|dƒt|dƒˆ  |¡ˆ  |¡g‘qS )rÆ   r   éüÿÿrÇ   rË   )rú   ri   r  rx  rU  r  r§   r¨   rz  [  s   üüz2YoutubeDL.render_formats_table.<locals>.<listcomp>)zformat coder    rÂ   re  r   )Z	extra_gapc                    sŽ   |dv sJ ‚|   |¡}|sdS |dkr>d | d¡d d… ¡S |dkrX|   d¡dkrXdS |dkrr|   d¡dkrrd	S ˆ  |dkr‚d
ndˆ jj¡S )N)rÌ   rÍ   ro  rT  rC  ro  rÍ   rÌ   Úimagesrì   rp  rv  )rú   r  r@  rá  rQ  rÖ  )rÝ  r;  rŠ  r  r§   r¨   Úsimplified_codecd  s    
ÿz8YoutubeDL.render_formats_table.<locals>.simplified_codecu   â”‚r=  r×  c                     sà  g | ]Ö}|  d ¡du s$|d  dkrˆ t|dƒˆjj¡t|dƒt|ˆjddt|ddtd	t|d
ddd dd¡t|ddƒˆ t|ddtd	pÊt|ddtd	pÊtt	|  d¡ˆ  d¡ƒdˆ dˆjj
¡td	t|ddtd	t|  dd¡ƒˆ ˆ|dƒt|ddtd	ˆ|dƒt|ddtd	t|ddtd	tt|d d!ƒt|  d¡d"v rPˆ d#ˆjj¡nd|  d$¡d%krrˆ d&ˆjj¡n|  d$¡rŽˆ d'ˆjj¡nd|  d(¡r¬ˆ d)ˆjj¡ndt|d*ƒt|d+d|  d¡fdd,d-d.d-g‘qS )/rÆ   Nrz  rÇ   rË   )rp  r{  )r¦   rÙ  r»   z	%dr¥   rÔ   r¿  )Nr÷  )rÙ  ÚHDRrì   rµ   z	%sr´   z 	%sr¾   u   â‰ˆ	%sr¼   rº   z~	%sz	%dkrÄ   rÍ   r¿   rÌ   r±   r¹   rÙ   z[%s]rt  ZUNSUPPORTEDrÐ   rô  z	Maybe DRMZDRMrJ  ZUntestedrÉ   rÖ   rm  ©r‡  rã  )rú   rá  ri   rQ  rÒ  r  rÜ  rO  rg   r†   rÖ  r   rh   rp   rÔ  rÕ  rU  ©r‡  r+  r¡   r|  r§   r¨   rz  t  sD   å
ÿÿ" ùùìrÒ  ZEXTZ
RESOLUTIONz	FPSr}  ZCHz		FILESIZEz	TBRÚPROTOZVCODECz	VBRZACODECz	ABRz	ASRz	MORE INFOu   â”€r  )Ú
hide_emptyr‡  )rb  rõ   rú   r{   rá  rQ  rÓ  rs  )r¡   r+  rÖ  ÚtableZheader_liner§   r  r¨   r  V  s*    

úãþþzYoutubeDL.render_formats_tablec                 C   s:   t | d¡pg ƒ}|sd S t|  dddd¡dd„ |D ƒƒS )NrÏ  rÒ  ZWidthZHeightÚURLc                 S   s6   g | ].}|  d ¡|  d¡pd|  d¡p(d|d g‘qS )rò  r·   ro  rÀ   rÜ   rÿ  ©rá   rÌ  r§   r§   r¨   rz     rä   z5YoutubeDL.render_thumbnails_table.<locals>.<listcomp>)rŠ  rú   r{   rs  )r¡   r+  rÏ  r§   r§   r¨   r  š  s    þz!YoutubeDL.render_thumbnails_tablec                    s:   dd„ ‰ |sd S t |  ddd¡‡ fdd„| ¡ D ƒdd	S )
Nc                 S   s\   t dd„ t|ƒD ƒŽ \}}tt|ƒƒdkrF|d dkr:g n
|d d… }| d |¡d |¡gS )Nc                 s   s$   | ]}|d  |  d¡pdfV  qdS )rË   r  ro  Nrÿ  rU  r§   r§   r¨   r—  ¤  rä   zAYoutubeDL.render_subtitles_table.<locals>._row.<locals>.<genexpr>r   r   ro  rm  )r&  Úreversedr  r%  r  )r  rÖ  ÚextsÚnamesr§   r§   r¨   Ú_row£  s    z.YoutubeDL.render_subtitles_table.<locals>._rowZLanguageÚNameZFormatsc                    s   g | ]\}}ˆ ||ƒ‘qS r§   r§   )rá   r  rÖ  ©rˆ  r§   r¨   rz  ­  rä   z4YoutubeDL.render_subtitles_table.<locals>.<listcomp>T)r  )r{   rs  rm  )r¡   rô  rñ  r§   rŠ  r¨   r  ¢  s    ýz YoutubeDL.render_subtitles_tablec                 G   sJ   ||Ž }|s$|   |› d|› ¡ d S |   d|› d|› d¡ |  |¡ d S )Nz has no z[info] Available z for r.  )r«  r¦  )r¡   rô  r  r¦   r¢   r‚  r§   r§   r¨   Z__list_table°  s    zYoutubeDL.__list_tablec                 C   s   |   |d d| j|¡ d S )Nrò  rÖ  )Ú_YoutubeDL__list_tabler  ry  r§   r§   r¨   r  ¸  s    zYoutubeDL.list_formatsc                 C   s   |   |d d| j|¡ d S )Nrò  rÏ  )r‹  r  ry  r§   r§   r¨   r  »  s    zYoutubeDL.list_thumbnailsrñ  c                 C   s   |   ||| j||¡ d S r“  )r‹  r  )r¡   rô  rñ  r  r§   r§   r¨   r  ¾  s    zYoutubeDL.list_subtitlesc              
      s  ˆj  d¡sd S dd„ ‰ d t ¡ t ¡ ˆ ¡ d ‡ fdd„ˆj	j
D ƒ¡¡}ˆj  d¡‰ˆrr‡fd	d
„}||ƒ n td|› dd d ‡fdd
„}tƒ }tdvr¨|d7 }tˆƒ}|tt d¡d › dttt d¡d pÚttƒtrödtd d… › dnd|dkrdn
d|› dtjrdn |tkr*dndˆj› d|j› dd ƒ tjs^|d!ˆj › ƒ tƒ  tj}|d u r~|d"ƒ n|sŒ|d#ƒ ˆj d$ r²|d% d ˆj d$ ¡¡ƒ tƒ rÊ|d&tƒ › ƒ |t ƒ ƒ t! "ˆ¡\}}d'd(„ | #¡ D ƒ}|r|d)  d* d+ t$|ƒ¡¡7  < t%ƒ |d,< t& '¡ |d-< d d.d„ t$| #¡ ƒD ƒ¡pPd/}|d0|› ƒ d1d2l(m)‰ d1d3l*m+}	 |d4d t$‡fd5d(„|	 ,¡ D ƒƒ¡p d/ ƒ |d6ˆj-› ƒ |d7d d8d„ ˆj.j/ ,¡ D ƒ¡› ƒ d9t0fd:t1ffD ]h\}
}d;d<„ |j #¡ D ƒ}|
d9kr,| 2d=d„ t3j #¡ D ƒ¡ |s6qì||
› d>d t$|ƒ¡› ƒ qìd/}t4jshd?}nt5ƒ }|r~d |¡}|d@|› ƒ d S )ANr¨  c                 S   sŠ   t t| ddt| ƒj› dƒƒ}g }tj dd¡ ¡ dkrB| d¡ t	| ƒslddl
m} | |d	u rfd
nd¡ |r†|› dd |¡› d}|S )Nr$  z	missing (r<  rë   rì   rí   r   )ÚWINDOWS_VT_MODEFzNo VTzNo ANSIú (rž   )rö   rÚ  r€  ra  rH  Úenvironrú   rJ  rG  r„   ÚutilsrŒ  r  )rû   r¼  Zadditional_inforŒ  r§   r§   r¨   Úget_encodingÅ  s    
z2YoutubeDL.print_debug_header.<locals>.get_encodingz(Encodings: locale {}, fs {}, pref {}, {}rm  c                 3   s4   | ],\}}|d ur|dkr|› dˆ |ƒ› V  qd S )Nr  rã  r§   )rá   r   rû   )r  r§   r¨   r—  Õ  s   ÿz/YoutubeDL.print_debug_header.<locals>.<genexpr>r§  c                    s   ˆ   d| › ¡S )Nrç  )rª  rï  )r§  r§   r¨   rþ  Ü  rä   z.YoutubeDL.print_debug_header.<locals>.<lambda>rç  r  r#  c                    s   ˆ   d| › d¡S )Nrç  r  )r¤  rï  r  r§   r¨   rþ  à  rä   )NÚpipr8  rU  rŸ  z versionru  r6  é	   rq  rì   ro  ry  r<  ZAPIzAPI:rC  rã  r~  zparams: z#Lazy loading extractors is disabledz,Lazy loading extractors is forcibly disabledr  zCompatibility options: {}z
Git HEAD: c                 S   s   h | ]\}}|r|’qS r§   r§   )rá   r   r  r§   r§   r¨   rü  ÿ  rä   z/YoutubeDL.print_debug_header.<locals>.<setcomp>Zffmpegz ({})rž   ZrtmpdumpZ	phantomjsc                 s   s$   | ]\}}|r|› d |› V  qdS )rã  Nr§   )rá   Zexer  r§   r§   r¨   r—    s   rT  zexe versions: r   ©Úget_package_info)Úavailable_dependencieszOptional libraries: %sc                    s   h | ]}t ˆ |ƒŽ ’qS r§   )rp   rù  r“  r§   r¨   rü    s   zProxy map: zRequest Handlers: c                 s   s   | ]}|j V  qd S r“  )ÚRH_NAME©rá   Úrhr§   r§   r¨   r—    rä   Z	ExtractorzPost-Processorc                 S   s0   g | ](\}}|j |kr|j n|j › d |› ‘qS )z as )ra  )rá   r  Úklassr§   r§   r¨   rz    s   ÿz0YoutubeDL.print_debug_header.<locals>.<listcomp>c                 s   s4   | ],\}}|d  j  d¡d › d|j› dV  qdS )r   r7  rŸ  r  r<  N)r„  Ú	partitionra  )rá   ÚparentÚpluginsr§   r§   r¨   r—    s   ÿz
 Plugins: znone (disabled)zPlugin directories: )6rõ   rú   rÛ   ÚlocaleÚgetpreferredencodingrô   re  r  r  rB  rL  r   r9   r›   r€  rp   r5   Ú
rpartitionr7   r™   r˜   rš  rœ   rš   r   rA  r¯   rb  rc  r   r   r8   r…   r0   Zget_versions_and_featuresrm  Úsortedr   r   rÙ  Zcompat.compat_utilsr”  Zdependenciesr•  r’  ÚproxiesrÄ  Úhandlersr   r   r”  r   r   Úplugin_directories)r¡   Zencoding_strr&  Úsourcer™  Zlazy_extractorsZexe_versionsZffmpeg_featuresZexe_strr•  Zplugin_typerœ  Zdisplay_listZplugin_dirs_msgZfound_plugin_directoriesr§   )r  r”  r§  r¡   r¨   r_  Á  s¢    ÿü	
,ú


 


ÿ
þÿþ&þ

ÿ 
zYoutubeDL.print_debug_headerc                 C   sT   | j  d¡}|dur*|dkr d}d|i}n&tj ¡ }d|v rPd|vrP|d |d< |S )zGlobal proxy configurationÚproxyNrì   Z__noproxy__rˆ  rî  r  )rõ   rú   r   ÚrequestÚ
getproxies)r¡   Z
opts_proxyr¡  r§   r§   r¨   r¡  )  s    

zYoutubeDL.proxiesc                 C   st   zt | j d¡| j d¡| ƒW S  tyn } z8|j}| jt|ƒd t 	d||j
¡¡d ‚ W Y d}~n
d}~0 0 dS )zGlobal cookiejar instancer¾  Zcookiesfrombrowserrì   NrÉ  )r   rõ   rú   r   Ú__context__rŸ   rö   r  rÈ  rÉ  Ú__traceback__)r¡   r¤   Úcauser§   r§   r¨   r¿  9  s    ÿ$zYoutubeDL.cookiejarc                 C   s(   |   d¡ | jjd }|j| j| jdS )zS
        Get a urllib OpenerDirector from the Urllib handler (deprecated).
        z8YoutubeDL._opener is deprecated, use YoutubeDL.urlopen()ÚUrllib)r¿  r¡  )r^   rÄ  r¢  Z_get_instancer¿  r¡  )r¡   Úhandlerr§   r§   r¨   Ú_openerE  s    
zYoutubeDL._openerc                 C   s   dd„ | j j ¡ D ƒS )Nc                 S   s0   g | ](}t |tƒrt|jƒD ]}||jf‘qqS r§   )ra  r$   r…  Zsupported_targetsr–  )rá   r˜  Útargetr§   r§   r¨   rz  P  s   
ýz@YoutubeDL._get_available_impersonate_targets.<locals>.<listcomp>)rÄ  r¢  r’  r  r§   r§   r¨   Ú"_get_available_impersonate_targetsN  s    
þz,YoutubeDL._get_available_impersonate_targetsc                    s   t ‡ fdd„| jj ¡ D ƒƒS )Nc                 3   s"   | ]}t |tƒr| ˆ ¡V  qd S r“  )ra  r$   Zis_supported_targetr—  ©r®  r§   r¨   r—  Y  s   
þz:YoutubeDL._impersonate_target_available.<locals>.<genexpr>)r÷   rÄ  r¢  r’  )r¡   r®  r§   r°  r¨   r`  W  s    
þz'YoutubeDL._impersonate_target_availablec                 C   sB   |dv rt ƒ }|r$dd„ t|ƒD ƒng }tt| j|ƒd ƒ}||fS )N)Trì   c                 S   s$   g | ]}t |tƒr|nt |¡‘qS r§   )ra  r%   Zfrom_strr„  r§   r§   r¨   rz  b  s   ÿz8YoutubeDL._parse_impersonate_targets.<locals>.<listcomp>)r%   r   rD  rE  r`  )r¡   r  Úrequested_targetsZavailable_targetr§   r§   r¨   Ú_parse_impersonate_targets^  s    ýþýz$YoutubeDL._parse_impersonate_targetsc                 C   sN   |pd}d  td tt| ƒƒ¡}|s&dnd|› }|› d|› d|rDdnd› d	S )
Nz>The extractor specified to use impersonation for this downloadrm  z"no impersonate target is availablez1none of these impersonate targets are available: z, but z. ZSeez!If you encounter errors, then seezi  https://github.com/yt-dlp/yt-dlp#impersonation  for information on installing the required dependencies)r  rE  r?  rö   )r±  re  rÎ  Zspecific_targetsrŸ  r§   r§   r¨   Ú_unavailable_targets_messagek  s    þÿz&YoutubeDL._unavailable_targets_messagec              
   C   sð  t |tƒrt|ƒ}n t |tjjƒr4|  d¡ t|ƒ}t |tƒsBJ ‚t|jƒ\}}|r^||j	d< t
|ƒ|_t|j|j	d t|j	ƒ z| j |¡W S  tyŠ } zà|jD ]Ê}|jr¨|jsºq¨|jjdkrâd|j ¡ v râtd|d|‚d|j ¡ v rd	| jjvrd
| jjvrtdƒ‚q¨t d|j ¡ ¡rJd| jjvrJtd|d|‚q¨t d|j ¡ ¡r¨td|jd › dƒ‚q¨‚ W Y d}~njd}~0  tyê } zHdt|ƒv r¸td|d|‚ndt|ƒv rÔtd|d|‚‚ W Y d}~n
d}~0 0 dS )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¡  rr  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"ÚrequestsZ	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?"Z
websocketszkThis request requires WebSocket support. Ensure one of the following dependencies are installed: websocketsz:unsupported (?:extensions: impersonate|impersonate target)r  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.NZ$UNSAFE_LEGACY_RENEGOTIATION_DISABLEDzGUNSAFE_LEGACY_RENEGOTIATION_DISABLED: Try using --legacy-server-connectZSSLV3_ALERT_HANDSHAKE_FAILUREztSSLV3_ALERT_HANDSHAKE_FAILURE: The server may not support the current cipher list. Try using --legacy-server-connect)ra  rö   r   r   r¦  r^   r   rd   rÜ   rr  r   r–   r¡  r•   rÄ  Úsendr    Zunsupported_errorsr¬  rp  ÚRH_KEYrJ  r!   r¢  ru  rv  Ú
extensionsr"   )r¡   ÚreqrÜ   Zbasic_auth_headerro  Zuer§   r§   r¨   rÒ  w  s|    

ÿ



þþÿ
þ
ýÿÿ
þýýÿþþzYoutubeDL.urlopenc                 C   sÚ   t | ƒ}| jd  ¡ }| j ¡ }t|ƒ t||ƒ t|| j d¡d}|D ]\}| |f ||| j	|d| jd v | j d¡ dœt
| jddd	d
ddddddœdœƒ¤Ž¡ qJ|j |p´g ¡ d| jd v rÖ|j dd„ ¡ |S )NrÎ   Zdebug_printtraffic)r§  r¨  z
no-certifir  Znocheckcertificate)r§  rr  r¿  r¡  Zprefer_system_certsÚverifyÚsource_addressÚsocket_timeoutZlegacyserverconnectÚenable_file_urlsr  Úclient_certificateÚclient_certificate_keyÚclient_certificate_password)r¾  r¿  rÀ  )r¨  r»  ÚtimeoutZlegacy_ssl_supportr½  r  Úclient_certzprefer-legacy-http-handlerc                 S   s   | j dkrdS dS )Nr«  iô  r   )r·  )r˜  r–  r§   r§   r¨   rþ  ×  rä   z2YoutubeDL.build_request_director.<locals>.<lambda>)r’   rõ   rö  r¡  r•   r–   r   rú   Úadd_handlerr¿  r‰   r‘  r  r'  )r¡   r¢  r‘  r§  rr  r¡  Zdirectorr¬  r§   r§   r¨   Úbuild_request_director·  s@    

úýùù
z YoutubeDL.build_request_directorc                 C   s   |   t ¡ t¡S r“  )rÄ  r   r’  r   r  r§   r§   r¨   rÄ  Ú  s    zYoutubeDL._request_directorc              
   C   sV   t |tƒr|S z| |  ¡ ¡W S  tyP } z|jd |_‚ W Y d }~n
d }~0 0 d S )NzH. Check your system encoding configuration or use the --encoding option.)ra  r  r›  r  rê  rÃ  )r¡   r!  r&  r§   r§   r¨   r›  Þ  s    
zYoutubeDL.encodec                 C   s   | j  d¡}|d u rtƒ }|S )Nr$  )rõ   rú   rx   )r¡   r$  r§   r§   r¨   r  è  s    zYoutubeDL.get_encodingc              	   C   sà   |du r| j  dd¡}| j  d¡s&dS |s@|  d|› d¡ dS |  |¡sNdS |sxtj |¡rx|  d| ¡ › d	¡ d
S |  d|› d|› ¡ z"t	|  
|| j  dd¡¡|ƒ W dS  tyÚ   |  d|› d|› ¡ Y dS 0 dS )zb Write infojson and returns True = written, 'exists' = Already exists, False = skip, None = error Nr  TZwriteinfojsonFúSkipping writing z	 infojsonrL  z metadata is already presentrP  r  z metadata as JSON to: rZ  úCannot write z metadata to JSON file )rõ   rú   r&  r  rH  r	  rP  r«  r¦  r   r&  r)  rŸ   )r¡   Úlabelrã  rU  r$  r§   r§   r¨   r(  î  s&    
zYoutubeDL._write_info_jsonc              	   C   s  | j  d¡sdS |s*|  d|› d¡ dS |  |¡s8dS | j  dd¡sjtj |¡rj|  d| ¡ › d	¡ n¨| d
¡du rŽ|  d|› d¡ dS zV|  d|› d|› ¡ t	|ddd}| 
|d
 ¡ W d  ƒ n1 sØ0    Y  W n, ty   |  d|› d|› ¡ Y dS 0 dS )zJ Write description and returns True = written, False = skip, None = error ZwritedescriptionFrÅ  z descriptionNr  TrL  z description is already presentr%  z[info] There's no z description to writer  z description to: r6  r"  r#  rÆ  z description file )rõ   rú   r&  r  rH  r	  rP  r«  r¦  r  rš  r)  rŸ   )r¡   rÇ  rã  ZdescfnZdescfiler§   r§   r¨   r)    s(    
0zYoutubeDL._write_descriptionc                 C   sR  g }|  d¡}| j  d¡s*| j  d¡s*|S |s<|  d¡ |S |  |d¡}|sZ|  d¡ |S | ¡ D ]è\}}|d }t||||  d¡ƒ}	t||||  d¡ƒ}
|  |
|	f¡}|rÞ|  d|› d	|› d
¡ ||d< | ||
f¡ qb|  d|	› ¡ |  d¡dur†z^t|	dddd}| 	|d ¡ W d  ƒ n1 s60    Y  |	|d< | |	|
f¡ W qbW n( t
y„   |  d|	› ¡ Y  dS 0 zD| ¡ }| d|  d¡¡ | j|	|dd |	|d< | |	|
f¡ W qb ttt
tgt¢R yJ } zXd|›d|› }| j  d¡dur,| j  d¡s$|  |¡ t|ƒ‚|  |¡ W Y d}~qbd}~0 0 qb|S )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 rC  z is already presentr>  z#[info] Writing video subtitles to: rñ  Nr6  r"  rì   r  z"Cannot write video subtitles file rÎ   T)r  z'Unable to download video subtitles for rÀ  rÇ  )rú   rõ   r«  r¤  rm  rƒ   r.  rG  r  rš  r)  rŸ   rö  rF  rO  rG   rJ   r‹  r#   r	  )r¡   r+  r  r¼  rñ  Zsub_filename_baseZsub_langZsub_infoZ
sub_formatZsub_filenameZsub_filename_finalZexisting_subZsubfileZsub_copyr&  rp  r§   r§   r¨   rN    s\    


.

"zYoutubeDL._write_subtitlesc                 C   s˜  | j  dd¡}g g  }}|s*| j  dd¡rR| d¡p6g }|sR|  d|› d¡ |S |o`t|ƒdk}|du rn|}|rŒ|sŒ|  d	|› d
¡ |S |rž|  |¡sždS tt|ƒƒddd… D ]Ü\}	}
|
 d¡pÔt|
d dƒ}|rì|
d › d|› }|› d|
d › }t	||| d¡ƒ}t	||| d¡ƒ}|  
||f¡}|rt|  d |rH|n|› d
 ¡ ¡¡ ||
d< | ||f¡ n|  d|› d¡ z†|  t|
d |
 di ¡d¡}|  d|› d|› ¡ t|dƒ}t ||¡ W d  ƒ n1 sê0    Y  | ||f¡ ||
d< W nv ty‚ } z\t|tƒrN|jdkrN|  d| ¡ › d¡ n|  d|› d|› ¡ | |	¡ W Y d}~n
d}~0 0 |r´|s´ q”q´|S ) zf Write thumbnails to file and return list of (thumb_filename, final_thumb_filename); or None if error Zwrite_all_thumbnailsFZwritethumbnailrÏ  z[info] There are no z thumbnails to downloadr   NrÅ  z
 thumbnailr   rË   rÜ   Zjpgrò  rC  z thumbnail z[info] {} is already presentr>  z[info] Downloading z ...rÎ   )rr  r  r  Úwbi”  rL  z does not existzUnable to download rÀ  )rõ   rú   r«  r  r&  r  rŠ  r}  r_   r|   r.  rÛ   rã  rG  rÒ  r   r  rV  Úcopyfileobjr#   ra  r   Ústatusr¦  r	  r^  )r¡   rÇ  r+  r  Zthumb_filename_baseZ	write_allrÏ  r¼  Úmultipler  rÌ  Z	thumb_extZthumb_display_idZthumb_filenameZthumb_filename_finalZexisting_thumbZufZthumbfr&  r§   r§   r¨   r*  U  sZ    
 ÿ
, zYoutubeDL._write_thumbnails)NT)r  )NF)FN)FNF)F)NNN)NNT)N)F)F)F)rì   N)F)rì   )FF)TNNTF)N)TN)F)T)F)T)T)NT)FF)F)T)r  N)N)ro  )rñ  )NF)N)N)N)ra  rb  rc  Ú__doc__rí  r  rä  r%  r=   Zcommon_audioZcommon_videorß   r¸  rt  r~  rƒ  r   rc  rn  rj  r‘  rk  rl  r¢  r¤  r¦  r«  r­  r¯  r¸  rº  r»  r½  rÁ  rÃ  rÂ  rÏ  rP   rQ  rß  rá  râ  rP  r	  r^   rN  rŸ   r&  rí  rî  r÷  rù  rf  r  Ústaticmethodr  r  Úclassmethodr'  r,  r˜  r™  r®   r¡  r¤  rÄ  rÆ  rÑ  rÔ  rå  r]  rð  rÍ  rü  rý  r  r  r  r-  rE  rS  rY  rd  rh  rÉ  rË  rÐ  r  r  r  ré  r  rÿ  r!  r  rO  r.  r  rX  rÎ  r_  r&  re  rh  r  rR  r.  r  r  rn  rÂ  r  r  rs  rx  rb  r  r  r  r‹  r  r  r  r_  r«   Úcached_propertyr¡  r¿  Úpropertyr­  r¯  r`  r²  r³  rÒ  rÄ  rÄ  r›  r  r(  r)  rN  r*  r§   r§   r§   r¨   r¯   Ã   sf     ûý ]
	"÷


	



 h[
 ÿ
2 .*
 v
C'  \$ ?  ?<(%

  l$
	<Dh


	@#
8r¯   )Ñr"  rÚ  rö  rÞ  rÝ  r*  r\  r«   Úhttp.cookiejarrî  rÂ  r£  r‚  r  rK  rH  r  ru  rV  r  rX  rô   rM  rŽ  rr  rÈ  r„  r?  r   rc  r   r   rØ   r   r   r   rM  r	   r
   r   Zdownloader.rtmpr   ró  r   r   r   Zextractor.commonr   Zextractor.openloadr   Úglobalsr   r   r   r   r   r   r   Z
minicursesr   Z
networkingr   r   r   Znetworking.commonr   r   Znetworking.exceptionsr   r    r!   r"   r#   Znetworking.impersonater$   r%   rœ  r&   r£  r'   Zpostprocessorr(   r)   r*   r+   r,   r-   r.   r/   r0   r1   r2   r3   Zpostprocessor.ffmpegr4   rK  r  r5   r6   r7   r8   r9   r  r:   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`   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   Zutils._utilsr‘   r’   r“   Zutils.networkingr”   r•   r–   r—   rê  r˜   r™   rš   r›   rœ   r  r²  r®   r¯   r§   r§   r§   r¨   Ú<module>   sh   $	8ÿ eY