
    V|hY                    |   S SK r S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SK	r	S SK
r
S SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrS SKrSSKJrJrJr  SSKJr  SSK J!r!J"r"  SSK#J$r$  SSK%J&r&  SSK'J(r(J)r)  SS	K*J+r+J,r,J-r-J.r.  SS
K/J0r0J1r1J2r2J3r3J4r4J5r5J6r6J7r7J8r8J9r9J:r:J;r;J<r<J=r=J>r>J?r?J@r@JArAJBrBJCrCJDrDJErEJFrFJGrGJHrHJIrIJJrJJKrKJLrLJMrMJNrNJOrOJPrPJQrQJRrRJSrSJTrTJUrUJVrVJWrWJXrXJYrYJZrZJ[r[J\r\J]r]J^r^J_r_J`r`JaraJbrbJcrcJdrdJereJfrfJgrgJhrhJiriJjrjJkrk  SSKlJmrm  SSKnJoro   " S S5      rp " S S\p5      rq " S S\p5      rrg)    N   )compat_etree_fromstringcompat_expanduserurllib_req_to_req)LenientSimpleCookie)get_base_urlremove_encrypted_media)HlsFD)plugin_ies_overrides)HEADRequestRequest)	HTTPErrorIncompleteReadTransportErrornetwork_exceptions)<IDENTITY
JSON_LD_RE
NO_DEFAULTExtractorErrorFormatSorterGeoRestrictedErrorGeoUtilsISO639UtilsLenientJSONDecoderPopenRegexNotFoundErrorRetryManagerUnsupportedErrorage_restrictedbase_urlbug_reports_messageclassproperty
clean_htmldeprecation_warningdetermine_extdict_getencode_data_uriextract_attributesfilter_dictfix_xml_ampersandsfloat_or_noneformat_fieldint_or_nonejoin_nonempty
js_to_jsonmimetype2extnetrc_from_content
orderedSetparse_bitrateparse_codecsparse_durationparse_iso8601parse_m3u8_attributesparse_resolution	qualitiessanitize_urlsmuggle_urlstr_or_none
str_to_intstrip_or_nonetraverse_objtruncate_stringtry_calltry_getunescapeHTMLunified_strdateunified_timestampurl_basenameurl_or_noneurlhandle_detect_exturljoinvariadicxpath_element
xpath_textxpath_with_ns)_request_dump_filename)devaluec                   	  ^  \ rS rSrSrSrSrSrSrSr	Sr
SrSrSrSrSrSr/ r\S4S jrSS jr\S 5       r\S	 5       r\S
 5       r\S 5       r\S 5       r\S 5       rS rS rS rS rS r \!S 5       r"\!S 5       r#S r$S r%S r&S r'\S 5       r(\)S 5       r*\+S 5       r,SS jr-  SS jr.SSSSS0 0 SSS4
S jr/\+S 5       r0S  r1S! r2  SS" jr3S# r4SS$ jr5SS% jr6S& r7S' r8\8" S(S)S*S+S,5      u  r9r:\8" S-S.S/S0S15      u  r;r<\8" S2S3S4S5S15      u  r=r>\8" S6SSSS75      S8   r?SSSS8\4S9 jr@SSS:.S; jjrAS< rBS= rCSS> jrD\4S? jrES@ rFSA rGSB rHSC rISDS\4SE jrJ  SSF jrKSSG jrL\+SSSH.SI jj5       rM\SS\NSS4SJ j5       rO\+SSSK.SL jj5       rP\SSMS4SN jrQSOSPS\SQ.SR jrR\SSMS4SS jrSSST jrTSSU jrUSSV jrV\+SW 5       rW\+SX 5       rXSSY jrYSZ rZS[ r[SS\.S] jr\SS^ jr]S_ r^SSS\.S` jjr_SSa jr`Sb ra\+Sc 5       rbSd rcSe rdSf reS\Sg.Sh jrfSS\Sg.Si jjrgSSj jrhS\Sg.Sk jriSSl jrjSSSmSn.So jjrkS\Sg.Sp jrlS\Sg.Sq jrm\+Sr 5       rnSs ro\)" SSt9Su 5       rp/ 4Sv jrqSw rr\+Sx 5       rsSy0 4Sz jrtS{ ruSS| jrvSS} jrwSSSS~ SSS0 0 4	S jrxSSSS SS4S jrySS jrzS r{S r|SSSSSSSSSS0 0 4S jr}SSSSSSSSSSS0 0 S4S jr~SSS0 0 4S jrS rSSS0 0 4S jr\+SS j5       rSS jrS rSS jrSS jrSS jrS rS r SS jrSS jrSS jrSS jrS rS rSSSSS0 0 4S jrS rS rS rSS jrS rSSSSS0 0 4S jrSS jrSS jrS r0 4S jrS/ 4S jrS\4S jr\S.S jr  SS jr  SS jrS rSS jrSS jrSSSSS0 4S jrS rS r\SS j5       r\S 5       r\)" SSt9S 5       r\)" SSt9S 5       r\S 5       r\S 5       r\SSS.S j5       rS rS r " S S\5      rS rS r\+S 5       r\SS.S j5       rS rS r\GRr                  S 5       rS rS rS r\+S 5       rSSS.S jjrSS jrS r\+SS j5       r\4SSS.S jjrSSSyS.S jjrSSS\.S jjrS r0 SS.S jr\S 5       r\S 5       r\S 5       r " S S\5      r\S 5       r\SS.U 4S jj5       rSrU =r$ )InfoExtractork   am  Information Extractor class.

Information extractors are the classes that, given a URL, extract
information about the video (or videos) the URL refers to. This
information includes the real video URL, the video title, author and
others. The information is stored in a dictionary which is then
passed to the YoutubeDL. The YoutubeDL processes this
information possibly downloading the video to the file system, among
other possible outcomes.

The type field determines the type of the result.
By far the most common value (and the default if _type is missing) is
"video", which indicates a single video.

For a video, the dictionaries must include the following fields:

id:             Video identifier.
title:          Video title, unescaped. Set to an empty string if video has
                no title as opposed to "None" which signifies that the
                extractor failed to obtain a title

Additionally, it must contain either a formats entry or a url one:

formats:        A list of dictionaries for each format available, ordered
                from worst to best quality.

                Potential fields:
                * url        The mandatory URL representing the media:
                               for plain file media - HTTP URL of this file,
                               for RTMP - RTMP URL,
                               for HLS - URL of the M3U8 media playlist,
                               for HDS - URL of the F4M manifest,
                               for DASH
                                 - HTTP URL to plain file media (in case of
                                   unfragmented media)
                                 - URL of the MPD manifest or base URL
                                   representing the media if MPD manifest
                                   is parsed from a string (in case of
                                   fragmented media)
                               for MSS - URL of the ISM manifest.
                * request_data  Data to send in POST request to the URL
                * manifest_url
                             The URL of the manifest file in case of
                             fragmented media:
                               for HLS - URL of the M3U8 master playlist,
                               for HDS - URL of the F4M manifest,
                               for DASH - URL of the MPD manifest,
                               for MSS - URL of the ISM manifest.
                * manifest_stream_number  (For internal use only)
                             The index of the stream in the manifest file
                * ext        Will be calculated from URL if missing
                * format     A human-readable description of the format
                             ("mp4 container with h264/opus").
                             Calculated from the format_id, width, height.
                             and format_note fields if missing.
                * format_id  A short description of the format
                             ("mp4_h264_opus" or "19").
                            Technically optional, but strongly recommended.
                * format_note Additional info about the format
                             ("3D" or "DASH video")
                * width      Width of the video, if known
                * height     Height of the video, if known
                * aspect_ratio  Aspect ratio of the video, if known
                             Automatically calculated from width and height
                * resolution Textual description of width and height
                             Automatically calculated from width and height
                * dynamic_range The dynamic range of the video. One of:
                             "SDR" (None), "HDR10", "HDR10+, "HDR12", "HLG, "DV"
                * tbr        Average bitrate of audio and video in kbps (1000 bits/sec)
                * abr        Average audio bitrate in kbps (1000 bits/sec)
                * acodec     Name of the audio codec in use
                * asr        Audio sampling rate in Hertz
                * audio_channels  Number of audio channels
                * vbr        Average video bitrate in kbps (1000 bits/sec)
                * fps        Frame rate
                * vcodec     Name of the video codec in use
                * container  Name of the container format
                * filesize   The number of bytes, if known in advance
                * filesize_approx  An estimate for the number of bytes
                * player_url SWF Player URL (used for rtmpdump).
                * protocol   The protocol that will be used for the actual
                             download, lower-case. One of "http", "https" or
                             one of the protocols defined in downloader.PROTOCOL_MAP
                * fragment_base_url
                             Base URL for fragments. Each fragment's path
                             value (if present) will be relative to
                             this URL.
                * fragments  A list of fragments of a fragmented media.
                             Each fragment entry must contain either an url
                             or a path. If an url is present it should be
                             considered by a client. Otherwise both path and
                             fragment_base_url must be present. Here is
                             the list of all potential fields:
                             * "url" - fragment's URL
                             * "path" - fragment's path relative to
                                        fragment_base_url
                             * "duration" (optional, int or float)
                             * "filesize" (optional, int)
                * hls_media_playlist_data
                             The M3U8 media playlist data as a string.
                             Only use if the data must be modified during extraction and
                             the native HLS downloader should bypass requesting the URL.
                             Does not apply if ffmpeg is used as external downloader
                * is_from_start  Is a live format that can be downloaded
                            from the start. Boolean
                * preference Order number of this format. If this field is
                             present and not None, the formats get sorted
                             by this field, regardless of all other values.
                             -1 for default (order by other properties),
                             -2 or smaller for less than default.
                             < -1000 to hide the format (if there is
                                another one which is strictly better)
                * language   Language code, e.g. "de" or "en-US".
                * language_preference  Is this in the language mentioned in
                             the URL?
                             10 if it's what the URL is about,
                             -1 for default (don't know),
                             -10 otherwise, other values reserved for now.
                * quality    Order number of the video quality of this
                             format, irrespective of the file format.
                             -1 for default (order by other properties),
                             -2 or smaller for less than default.
                * source_preference  Order number for this video source
                              (quality takes higher priority)
                             -1 for default (order by other properties),
                             -2 or smaller for less than default.
                * http_headers  A dictionary of additional HTTP headers
                             to add to the request.
                * stretched_ratio  If given and not 1, indicates that the
                             video's pixels are not square.
                             width : height ratio as float.
                * no_resume  The server does not support resuming the
                             (HTTP or RTMP) download. Boolean.
                * has_drm    True if the format has DRM and cannot be downloaded.
                             'maybe' if the format may have DRM and has to be tested before download.
                * extra_param_to_segment_url  A query string to append to each
                             fragment's URL, or to update each existing query string
                             with. If it is an HLS stream with an AES-128 decryption key,
                             the query parameters will be passed to the key URI as well,
                             unless there is an `extra_param_to_key_url` given,
                             or unless an external key URI is provided via `hls_aes`.
                             Only applied by the native HLS/DASH downloaders.
                * extra_param_to_key_url  A query string to append to the URL
                             of the format's HLS AES-128 decryption key.
                             Only applied by the native HLS downloader.
                * hls_aes    A dictionary of HLS AES-128 decryption information
                             used by the native HLS downloader to override the
                             values in the media playlist when an '#EXT-X-KEY' tag
                             is present in the playlist:
                             * uri  The URI from which the key will be downloaded
                             * key  The key (as hex) used to decrypt fragments.
                                    If `key` is given, any key URI will be ignored
                             * iv   The IV (as hex) used to decrypt fragments
                * impersonate  Impersonate target(s). Can be any of the following entities:
                            * an instance of yt_dlp.networking.impersonate.ImpersonateTarget
                            * a string in the format of CLIENT[:OS]
                            * a list or a tuple of CLIENT[:OS] strings or ImpersonateTarget instances
                            * a boolean value; True means any impersonate target is sufficient
                * available_at  Unix timestamp of when a format will be available to download
                * downloader_options  A dictionary of downloader options
                             (For internal use only)
                             * http_chunk_size Chunk size for HTTP downloads
                             * ffmpeg_args     Extra arguments for ffmpeg downloader (input)
                             * ffmpeg_args_out Extra arguments for ffmpeg downloader (output)
                             * ws              (NiconicoLiveFD only) WebSocketResponse
                             * ws_url          (NiconicoLiveFD only) Websockets URL
                             * max_quality     (NiconicoLiveFD only) Max stream quality string
                * is_dash_periods  Whether the format is a result of merging
                             multiple DASH periods.
                RTMP formats can also have the additional fields: page_url,
                app, play_path, tc_url, flash_version, rtmp_live, rtmp_conn,
                rtmp_protocol, rtmp_real_time

url:            Final video URL.
ext:            Video filename extension.
format:         The video format, defaults to ext (used for --get-format)
player_url:     SWF Player URL (used for rtmpdump).

The following fields are optional:

direct:         True if a direct video file was given (must only be set by GenericIE)
alt_title:      A secondary title of the video.
display_id:     An alternative identifier for the video, not necessarily
                unique, but available before title. Typically, id is
                something like "4234987", title "Dancing naked mole rats",
                and display_id "dancing-naked-mole-rats"
thumbnails:     A list of dictionaries, with the following entries:
                    * "id" (optional, string) - Thumbnail format ID
                    * "url"
                    * "ext" (optional, string) - actual image extension if not given in URL
                    * "preference" (optional, int) - quality of the image
                    * "width" (optional, int)
                    * "height" (optional, int)
                    * "resolution" (optional, string "{width}x{height}",
                                    deprecated)
                    * "filesize" (optional, int)
                    * "http_headers" (dict) - HTTP headers for the request
thumbnail:      Full URL to a video thumbnail image.
description:    Full video description.
uploader:       Full name of the video uploader.
license:        License name the video is licensed under.
creators:       List of creators of the video.
timestamp:      UNIX timestamp of the moment the video was uploaded
upload_date:    Video upload date in UTC (YYYYMMDD).
                If not explicitly set, calculated from timestamp
release_timestamp: UNIX timestamp of the moment the video was released.
                If it is not clear whether to use timestamp or this, use the former
release_date:   The date (YYYYMMDD) when the video was released in UTC.
                If not explicitly set, calculated from release_timestamp
release_year:   Year (YYYY) as integer when the video or album was released.
                To be used if no exact release date is known.
                If not explicitly set, calculated from release_date.
modified_timestamp: UNIX timestamp of the moment the video was last modified.
modified_date:   The date (YYYYMMDD) when the video was last modified in UTC.
                If not explicitly set, calculated from modified_timestamp
uploader_id:    Nickname or id of the video uploader.
uploader_url:   Full URL to a personal webpage of the video uploader.
channel:        Full name of the channel the video is uploaded on.
                Note that channel fields may or may not repeat uploader
                fields. This depends on a particular extractor.
channel_id:     Id of the channel.
channel_url:    Full URL to a channel webpage.
channel_follower_count: Number of followers of the channel.
channel_is_verified: Whether the channel is verified on the platform.
location:       Physical location where the video was filmed.
subtitles:      The available subtitles as a dictionary in the format
                {tag: subformats}. "tag" is usually a language code, and
                "subformats" is a list sorted from lower to higher
                preference, each element is a dictionary with the "ext"
                entry and one of:
                    * "data": The subtitles file contents
                    * "url": A URL pointing to the subtitles file
                It can optionally also have:
                    * "name": Name or description of the subtitles
                    * "http_headers": A dictionary of additional HTTP headers
                              to add to the request.
                    * "impersonate": Impersonate target(s); same as the "formats" field
                "ext" will be calculated from URL if missing
automatic_captions: Like 'subtitles'; contains automatically generated
                captions instead of normal subtitles
duration:       Length of the video in seconds, as an integer or float.
view_count:     How many users have watched the video on the platform.
concurrent_view_count: How many users are currently watching the video on the platform.
like_count:     Number of positive ratings of the video
dislike_count:  Number of negative ratings of the video
repost_count:   Number of reposts of the video
average_rating: Average rating given by users, the scale used depends on the webpage
comment_count:  Number of comments on the video
comments:       A list of comments, each with one or more of the following
                properties (all but one of text or html optional):
                    * "author" - human-readable name of the comment author
                    * "author_id" - user ID of the comment author
                    * "author_thumbnail" - The thumbnail of the comment author
                    * "author_url" - The url to the comment author's page
                    * "author_is_verified" - Whether the author is verified
                                             on the platform
                    * "author_is_uploader" - Whether the comment is made by
                                             the video uploader
                    * "id" - Comment ID
                    * "html" - Comment as HTML
                    * "text" - Plain text of the comment
                    * "timestamp" - UNIX timestamp of comment
                    * "parent" - ID of the comment this one is replying to.
                                 Set to "root" to indicate that this is a
                                 comment to the original video.
                    * "like_count" - Number of positive ratings of the comment
                    * "dislike_count" - Number of negative ratings of the comment
                    * "is_favorited" - Whether the comment is marked as
                                       favorite by the video uploader
                    * "is_pinned" - Whether the comment is pinned to
                                    the top of the comments
age_limit:      Age restriction for the video, as an integer (years)
webpage_url:    The URL to the video webpage, if given to yt-dlp it
                should allow to get the same result again. (It will be set
                by YoutubeDL if it's missing)
categories:     A list of categories that the video falls in, for example
                ["Sports", "Berlin"]
tags:           A list of tags assigned to the video, e.g. ["sweden", "pop music"]
cast:           A list of the video cast
is_live:        True, False, or None (=unknown). Whether this video is a
                live stream that goes on instead of a fixed-length video.
was_live:       True, False, or None (=unknown). Whether this video was
                originally a live stream.
live_status:    None (=unknown), 'is_live', 'is_upcoming', 'was_live', 'not_live',
                or 'post_live' (was live, but VOD is not yet processed)
                If absent, automatically set from is_live, was_live
start_time:     Time in seconds where the reproduction should start, as
                specified in the URL.
end_time:       Time in seconds where the reproduction should end, as
                specified in the URL.
chapters:       A list of dictionaries, with the following entries:
                    * "start_time" - The start time of the chapter in seconds
                    * "end_time" - The end time of the chapter in seconds
                                   (optional: core code can determine this value from
                                   the next chapter's start_time or the video's duration)
                    * "title" (optional, string)
heatmap:        A list of dictionaries, with the following entries:
                    * "start_time" - The start time of the data point in seconds
                    * "end_time" - The end time of the data point in seconds
                    * "value" - The normalized value of the data point (float between 0 and 1)
playable_in_embed: Whether this video is allowed to play in embedded
                players on other sites. Can be True (=always allowed),
                False (=never allowed), None (=unknown), or a string
                specifying the criteria for embedability; e.g. 'whitelist'
availability:   Under what condition the video is available. One of
                'private', 'premium_only', 'subscriber_only', 'needs_auth',
                'unlisted' or 'public'. Use 'InfoExtractor._availability'
                to set it
media_type:     The type of media as classified by the site, e.g. "episode", "clip", "trailer"
_old_archive_ids: A list of old archive ids needed for backward
               compatibility. Use yt_dlp.utils.make_archive_id to generate ids
_format_sort_fields: A list of fields to use for sorting formats
__post_extractor: A function to be called just before the metadata is
                written to either disk, logger or console. The function
                must return a dict which will be added to the info_dict.
                This is useful for additional information that is
                time-consuming to extract. Note that the fields thus
                extracted will not be available to output template and
                match_filter. So, only "comments" and "comment_count" are
                currently allowed to be extracted via this method.

The following fields should only be used when the video belongs to some logical
chapter or section:

chapter:        Name or title of the chapter the video belongs to.
chapter_number: Number of the chapter the video belongs to, as an integer.
chapter_id:     Id of the chapter the video belongs to, as a unicode string.

The following fields should only be used when the video is an episode of some
series, programme or podcast:

series:         Title of the series or programme the video episode belongs to.
series_id:      Id of the series or programme the video episode belongs to, as a unicode string.
season:         Title of the season the video episode belongs to.
season_number:  Number of the season the video episode belongs to, as an integer.
season_id:      Id of the season the video episode belongs to, as a unicode string.
episode:        Title of the video episode. Unlike mandatory video title field,
                this field should denote the exact title of the video episode
                without any kind of decoration.
episode_number: Number of the video episode within a season, as an integer.
episode_id:     Id of the video episode, as a unicode string.

The following fields should only be used when the media is a track or a part of
a music album:

track:          Title of the track.
track_number:   Number of the track within an album or a disc, as an integer.
track_id:       Id of the track (useful in case of custom indexing, e.g. 6.iii),
                as a unicode string.
artists:        List of artists of the track.
composers:      List of composers of the piece.
genres:         List of genres of the track.
album:          Title of the album the track belongs to.
album_type:     Type of the album (e.g. "Demo", "Full-length", "Split", "Compilation", etc).
album_artists:  List of all artists appeared on the album.
                E.g. ["Ash Borer", "Fell Voices"] or ["Various Artists"].
                Useful for splits and compilations.
disc_number:    Number of the disc or other physical medium the track belongs to,
                as an integer.

The following fields should only be set for clips that should be cut from the original video:

section_start:  Start time of the section in seconds
section_end:    End time of the section in seconds

The following fields should only be set for storyboards:
rows:           Number of rows in each storyboard fragment, as an integer
columns:        Number of columns in each storyboard fragment, as an integer

The following fields are deprecated and should not be set by new code:
composer:       Use "composers" instead.
                Composer(s) of the piece, comma-separated.
artist:         Use "artists" instead.
                Artist(s) of the track, comma-separated.
genre:          Use "genres" instead.
                Genre(s) of the track, comma-separated.
album_artist:   Use "album_artists" instead.
                All artists appeared on the album, comma-separated.
creator:        Use "creators" instead.
                The creator of the video.

Unless mentioned otherwise, the fields should be Unicode strings.

Unless mentioned otherwise, None is equivalent to absence of information.


_type "playlist" indicates multiple videos.
There must be a key "entries", which is a list, an iterable, or a PagedList
object, each element of which is a valid dictionary by this specification.

Additionally, playlists can have "id", "title", and any other relevant
attributes with the same semantics as videos (see above).

It can also have the following optional fields:

playlist_count: The total number of videos in a playlist. If not given,
                YoutubeDL tries to calculate it from "entries"


_type "multi_video" indicates that there are multiple videos that
form a single show, for examples multiple acts of an opera or TV episode.
It must have an entries key like a playlist and contain all the keys
required for a video at the same time.


_type "url" indicates that the video must be extracted from another
location, possibly by a different extractor. Its only required key is:
"url" - the next URL to extract.
The key "ie_key" can be set to the class name (minus the trailing "IE",
e.g. "Youtube") if the extractor class is known in advance.
Additionally, the dictionary may have any properties of the resolved entity
known in advance, for example "title" if the title of the referred video is
known ahead of time.


_type "url_transparent" entities have the same specification as "url", but
indicate that the given additional information is more precise than the one
associated with the resolved URL.
This is useful when a site employs a video service that hosts the video and
its technical metadata, but that video service does not embed a useful
title, description etc.


Subclasses of this should also be added to the list of extractors and
should define _VALID_URL as a regexp or a Sequence of regexps, and
re-define the _real_extract() and (optionally) _real_initialize() methods.

Subclasses may also override suitable() if necessary, but ensure the function
signature is preserved and that this function imports everything it needs
(except other extractors), so that lazy_extractors works correctly.

Subclasses can define a list of _EMBED_REGEX, which will be searched for in
the HTML of Generic webpages. It may also override _extract_embed_urls
or _extract_from_webpage as necessary. While these are normally classmethods,
_extract_from_webpage is allowed to be an instance method.

_extract_from_webpage may raise self.StopExtraction to stop further
processing of the webpage and obtain exclusive rights to it. This is useful
when the extractor cannot reliably be matched using just the URL,
e.g. invidious/peertube instances

Embed-only extractors can be defined by setting _VALID_URL = False.

To support username + password (or netrc) login, the extractor must define a
_NETRC_MACHINE and re-define _perform_login(username, password) and
(optionally) _initialize_pre_login() methods. The _perform_login method will
be called between _initialize_pre_login and _real_initialize if credentials
are passed by the user. In cases where it is necessary to have the login
process as part of the extraction rather than initialization, _perform_login
can be left undefined.

_GEO_BYPASS attribute may be set to False in order to disable
geo restriction bypass mechanisms for a particular extractor.
Though it won't disable explicit geo restriction bypass based on
country code provided with geo_bypass_country.

_GEO_COUNTRIES attribute may contain a list of presumably geo unrestricted
countries for this extractor. One of these countries will be used by
geo restriction bypass mechanism right away in order to bypass
geo restriction, of course, if the mechanism is not disabled.

_GEO_IP_BLOCKS attribute may contain a list of presumably geo unrestricted
IP blocks in CIDR notation for this extractor. One of these IP blocks
will be used by geo restriction bypass mechanism similarly
to _GEO_COUNTRIES.

The _ENABLED attribute should be set to False for IEs that
are disabled by default and must be explicitly enabled.

The _WORKING attribute should be set to False for broken IEs
in order to warn the users and skip the tests.
FNTc                     SU=(       d    U R                    S3nSnSSU SU 3SU 3SU 3S	U 3S
.U[        La  U   $ U R                  5       (       a  S   $ S   $ )Nz4--username and --password, --netrc-cmd, or --netrc (z ) to provide account credentialszpSee  https://github.com/yt-dlp/yt-dlp/wiki/FAQ#how-do-i-pass-cookies-to-yt-dlp  for how to manually pass cookies z'Use --cookies, --cookies-from-browser, z. zUse z@Use --cookies-from-browser or --cookies for the authentication. zNUse --cookies for the authentication (--cookies-from-browser might not work). )Nanypasswordcookiessession_cookiesrU   rW   )_NETRC_MACHINEr   supports_login)selfmethodnetrcpassword_hintcookies_hints        Q/home/james-whalen/.local/lib/python3.13/site-packages/yt_dlp/extractor/common.py_login_hintInfoExtractor._login_hintS  s    NuOkX\XkXkNl  mM  N J<]O2l^\}o.YZfYgh!op|o}~
 *,&a 	a <@;N;N;P;P%a 	a W`a 	a    c                 `    SU l         SU l        [        5       U l        U R	                  U5        g)zConstructor. Receives an optional downloader (a YoutubeDL instance).
If a downloader is not passed during initialization,
it must be set using "set_downloader()" before "extract()" is calledFN)_ready_x_forwarded_for_ipset_printed_messagesset_downloaderr[   
downloaders     r`   __init__InfoExtractor.__init__^  s+     #' !$J'rc   c                   ^ U R                   SL a  g SU R                  ;  a;  [        [        [        R
                  [        U R                   5      5      5      U l        [        [        S U4S jU R                   5       5      S 5      $ )NF_VALID_URL_REc              3   D   >#    U  H  oR                  T5      v   M     g 7fN)match).0regexurls     r`   	<genexpr>1InfoExtractor._match_valid_url.<locals>.<genexpr>p  s     !R@Qu++c"2"2@Qs    )

_VALID_URL__dict__tuplemaprecompilerJ   ro   nextfilterclsru   s    `r`   _match_valid_urlInfoExtractor._match_valid_urlg  sb    >>U" #,,. %c"**hs~~6N&O PCF4!R@Q@Q!RSUYZZrc   c                 (    U R                  U5      SL$ )z8Receives a URL and returns True if suitable for this IE.N)r   r   s     r`   suitableInfoExtractor.suitabler  s    
 ##C(44rc   c                 B    U R                  U5      R                  S5      $ )Nid)r   groupr   s     r`   	_match_idInfoExtractor._match_idy  s    ##C(..t44rc   c                 R     U R                  U5      $ ! [        [        4 a     g f = frq   )r   
IndexErrorAttributeErrorr   s     r`   get_temp_idInfoExtractor.get_temp_id}  s-    	==%%N+ 		s    &&c                     U R                   $ )zGetter method for _WORKING.)_WORKINGr   s    r`   workingInfoExtractor.working  s     ||rc   c                 ,    [        U R                  5      $ rq   )boolrY   r   s    r`   rZ   InfoExtractor.supports_login  s    C&&''rc   c                    [        5       U l        U R                  U R                  U R                  S.5        U R
                  (       d  U R                  5         U R                  5       (       a+  U R                  5       u  pU(       a  U R                  X5        OUU R                  S5      (       a?  SU R                  U R                  4;  a#  U R                  SU R                  S5       35        U R                  5         SU l        gg)z.Initializes an instance (authentication, etc).)	countries	ip_blocksusernameFz7Login with password is not supported for this website. rW   TN)rg   rh   _initialize_geo_bypass_GEO_COUNTRIES_GEO_IP_BLOCKSre   _initialize_pre_loginrZ   _get_login_info_perform_login	get_paramIE_DESCrY   report_warningra   _real_initializer[   r   rV   s      r`   
initializeInfoExtractor.initialize  s    !$##,,,,%
 	 {{&&(""$$%)%9%9%;"'';
++dllDL_L_=`0`##&]^b^n^nox^y]z${|!!#DK rc   c                 H   U R                   (       Gd  U R                  SS5      (       d  gU(       d  0 n[        U[        [        45      (       a  SU0nU R                  SS5      nU(       d?  UR                  S5      nU R                  (       a  U(       a  [        R                  " U5      nU(       a;  [        R                  " U5      U l         U R                  SU R                    S35        gU R                  S	S5      nU(       d?  UR                  S5      nU R                  (       a  U(       a  [        R                  " U5      nU(       aV  [        R                  " U5      U l         U R                  R                  SU R                    S
UR                  5        S35        ggg)a  
Initialize geo restriction bypass mechanism.

This method is used to initialize geo bypass mechanism based on faking
X-Forwarded-For HTTP header. A random country from provided country list
is selected and a random IP belonging to this country is generated. This
IP will be passed as X-Forwarded-For HTTP header in all subsequent
HTTP requests.

This method will be used for initial geo bypass mechanism initialization
during the instance initialization with _GEO_COUNTRIES and
_GEO_IP_BLOCKS.

You may also manually call it from extractor's code if geo bypass
information is not available beforehand (e.g. obtained during
extraction) or due to some other reason. In this case you should pass
this information in geo bypass context passed as first argument. It may
contain following fields:

countries:  List of geo unrestricted countries (similar
            to _GEO_COUNTRIES)
ip_blocks:  List of geo unrestricted IP blocks in CIDR notation
            (similar to _GEO_IP_BLOCKS)


geo_bypassTNr   geo_bypass_ip_blockr   zUsing fake IP z as X-Forwarded-Forgeo_bypass_country (z) as X-Forwarded-For)rf   r   
isinstancelistrz   get_GEO_BYPASSrandomchoicer   random_ipv4write_debug_downloaderupper)r[   geo_bypass_contextip_blockr   countryr   s         r`   r   $InfoExtractor._initialize_geo_bypass  sb   4 ''' >>,55%%'"
 ,tUm<<!3&" ~~&;TBH .22;?	##	%}}Y7H+3+?+?+I(  >$2J2J1KK^!_` nn%94@G .22;?	##	$mmI6G+3+?+?+H(  ,,$T%=%=$>b@QQefh i (rc   c           	          [        S5       H  n U R                  5         U R                  SU R                  S5      (       a  UO[	        USS5      -  5        U R                  U5      nUc    gU R                  (       a  U R                  US'   UR                  S5      =(       d    0 nS	U R                  S
5      ;   a  S H  nUR                  US5        M     Us  $    g! [         a-  nU R                  UR                  5      (       a   SnAGM  e SnAff = f! [         a    e [         a  nUR                  =(       d    U R                  U5      Ul        UR                   =(       d    U R"                  Ul        UR$                  =(       d    [&        R(                  " 5       S   Ul        e SnAf[*         a   n[        SUSU R                  U5      S9eSnAf[,        [.        4 a  n[        SX`R                  U5      S9eSnAff = f)z9Extracts URL information and returns it in list of dicts.r   zExtracting URL: %sverbosed      N__x_forwarded_for_ip	subtitleszno-live-chatcompat_opts)	live_chatcommentsdanmakuzA network error has occurred.T)causeexpectedvideo_idz An extractor error has occurred.r   r   )ranger   	to_screenr   r@   _real_extractrf   r   popr   '_InfoExtractor__maybe_fake_ip_and_retryr   r   r   r   r   ieIE_NAME	tracebacksysexc_infor   KeyErrorStopIteration)r[   ru   _	ie_resultr   langes          r`   extractInfoExtractor.extract  s   	n1XOO%NN#7#~~i88ocSVXZ>[$] ^ $ 2 23 7I (#//<@<T<T	"89 )k : @bI%)FF$HD%MM$5 %I$$  * 55akkBB    	 	<t'7'7'<AJ44'4<<AD++:):AK 	z !@TXcgcscstwcxyy-( 	n !C1WgWghkWlmm	nss   D AC,D .A+CD D 
D) D	D DDD H-A>F++H8GH&G??Hc                    U R                  SS 5      (       d  U R                  (       a  U R                  SS5      (       a  U R                  (       dz  U(       as  [        R                  " U5      n[
        R                  " U5      U l        U R                  (       a1  U R                  SU R                   SUR                  5        S35        gg)Nr   r   Tz:Video is geo restricted. Retrying extraction with fake IP r   z) as X-Forwarded-For.F)	r   r   rf   r   r   r   r   r   r   )r[   r   country_codes      r`   __maybe_fake_ip_and_retry'InfoExtractor.__maybe_fake_ip_and_retry  s    3T::$$NN<6600!==3L'/';';L'ID$''##P//0<3E3E3G2HH]_` rc   c                     Xl         g)z8Sets a YoutubeDL instance as the downloader for this IE.N)r   rj   s     r`   ri   InfoExtractor.set_downloader#  s    %rc   c                 .    U R                   R                  $ rq   )r   cacher[   s    r`   r   InfoExtractor.cache'  s    %%%rc   c                 .    U R                   R                  $ rq   )r   	cookiejarr   s    r`   r   InfoExtractor.cookiejar+  s    )))rc   c                     g)z4Initialization before login. Redefine in subclasses.N r   s    r`   r   #InfoExtractor._initialize_pre_login/      rc   c                     g)z9Login with username and password. Redefine in subclasses.Nr   r   s      r`   r   InfoExtractor._perform_login3  r   rc   c                     g)z4Real initialization process. Redefine in subclasses.Nr   r   s    r`   r   InfoExtractor._real_initialize7  r   rc   c                     [        S5      e)z0Real extraction process. Redefine in subclasses.-This method must be implemented by subclassesNotImplementedErrorr[   ru   s     r`   r   InfoExtractor._real_extract;      !"QRRrc   c                      U R                   SS $ )z>A string for getting the InfoExtractor with get_info_extractorN__name__r   s    r`   ie_keyInfoExtractor.ie_key?  s     ||CR  rc   c                      U R                   S S $ )Nr   r   r   s    r`   r   InfoExtractor.IE_NAMED  s    ||CR  rc   c                     [        U [        5      (       d   eUc  g[        U5      (       a  U" U R                  5      SL $ U R                  [	        U5      ;   $ )NFT)r   r   callablestatusrJ   )errexpected_statuss     r`   __can_accept_status_code&InfoExtractor.__can_accept_status_codeH  sQ    #y))))"o&&"3::.$66::/!:::rc   c                    [        U[        R                  R                  5      (       a'  U R                  R                  S5        [        U5      nO [        U[        5      (       d  [        U5      nUR                  X#XES9  U$ )NzrPassing a urllib.request.Request to _create_request() is deprecated. Use yt_dlp.networking.common.Request instead.)dataheadersquery
extensions)r   urllibrequestr   r   r$   r   update)r[   url_or_requestr	  r
  r  r  s         r`   _create_requestInfoExtractor._create_requestR  sp    nfnn&<&<==00@A /~>NNG44$^4N4]rc   c           	         U R                   R                  (       dL  U R                  S5      =(       d    SnUS:  a+  U R                  SU S35        [        R
                  " U5        OSU R                   l        Uc  U R                  U5        O9USLa4  Uc  U R                  [        U5      5        OU R                  U SU 35        U R                  (       a5  U=(       d    0 R                  5       nUR                  SU R                  5        0 nU R                   R                  U
5      u  pU(       a  XS	'   O[U(       aT  S
nU(       a#  [        U R                   R                  UUSS9SS9eU R                  U R                   R                  UUS9SS9   U R                   R                  U R!                  XXxU5      5      $ ! ["         a  n[%        U[&        5      (       a(  U R)                  UU	5      (       a  UR*                  s SnA$ USL a   SnAgUc  SnU SU 3nU(       a
  [        UUS9eU R                  U5         SnAgSnAff = f)z[
Return the response handle.

See _download_webpage docstring for arguments specification.
sleep_interval_requestsr   z	Sleeping z seconds ...FN: zX-Forwarded-Forimpersonatez)The extractor is attempting impersonationT)noteis_errorr   )r  	only_oncezUnable to download webpager   )r   _first_webpage_requestr   r   timesleepreport_download_webpagestrrf   copy
setdefault_parse_impersonate_targetsr   _unavailable_targets_messager   urlopenr  r   r   r   &_InfoExtractor__can_accept_status_coderesponse)r[   r  r   r  errnotefatalr	  r
  r  r  r  require_impersonationsleep_intervalr  available_targetrequested_targetsmsgr  errmsgs                      r`   _request_webpageInfoExtractor._request_webpage^  s!    66!^^,EFK!N!>*:,GH

>*6;D3<((2s4y)(2dV45 ##}"**,G0$2J2JK
.2.>.>.Y.YZe.f+(8}%=C$$$$AABSZ]hlAm!# #   ==>OVY=Zfj   l	##++D,@,@W^gq,rss! 	#y))00oFF<<'%6y3%(F$V377##F+	s*   +G   
I	
7II	I.II	c                     [        U[        5      (       a  UR                  S5      S   nU R                  XX4XWXU
XS9nUSL a
  U(       a   egU R	                  XX#XEXgS9nUSL a
  U(       a   egX4$ )a  
Return a tuple (page content as string, URL handle).

Arguments:
url_or_request -- plain text URL as a string or
    a yt_dlp.networking.Request object
video_id -- Video/playlist/item identifier (string)

Keyword arguments:
note -- note printed before downloading (string)
errnote -- note printed in case of an error (string)
fatal -- flag denoting whether error should be considered fatal,
    i.e. whether it should cause ExtractionError to be raised,
    otherwise a warning will be reported and extraction continued
encoding -- encoding for a page content decoding, guessed automatically
    when not explicitly specified
data -- POST data (bytes)
headers -- HTTP headers (dict)
query -- URL query (dict)
expected_status -- allows to accept failed HTTP requests (non 2xx
    status code) by explicitly specifying a set of accepted status
    codes. Can be any of the following entities:
        - an integer type specifying an exact failed status code to
          accept
        - a list or a tuple of integer types specifying a list of
          failed status codes to accept
        - a callable accepting an actual failed status code and
          returning True if it should be accepted
    Note that this argument does not affect success status codes (2xx)
    which are always accepted.
impersonate -- the impersonate target. Can be any of the following entities:
        - an instance of yt_dlp.networking.impersonate.ImpersonateTarget
        - a string in the format of CLIENT[:OS]
        - a list or a tuple of CLIENT[:OS] strings or ImpersonateTarget instances
        - a boolean value; True means any impersonate target is sufficient
require_impersonation -- flag to toggle whether the request should raise an error
    if impersonation is not possible (bool, default: False)
#r   )r	  r
  r  r  r  r+  F)encodingr	  )r   r!  	partitionr1  _webpage_read_content)r[   r  r   r  r)  r*  r5  r	  r
  r  r  r  r+  urlhcontents                  r`   _download_webpage_handle&InfoExtractor._download_webpage_handle  s    V nc**+55c:1=N$$^te-4Sb1< % k 5=9,,T8SZ6> - Ke9rc   c                 &   [         R                  " SU 5      nU(       a  UR                  S5      nU$ [         R                  " SUS S 5      nU(       a"  UR                  S5      R	                  S5      nU$ UR                  S5      (       a  SnU$ SnU$ )	Nz2[a-zA-Z0-9_.-]+/[a-zA-Z0-9_.-]+\s*;\s*charset=(.+)   s*   <meta[^>]+charset=[\'"]?([^\'")]+)[ /\'">]i   asciis   zutf-16utf-8)r|   rr   r   searchdecode
startswith)content_typewebpage_bytesmr5  s       r`   _guess_encoding_from_content*InfoExtractor._guess_encoding_from_content  s    HHJLYwwqzH  		H'.0A771:,,W5  ))+66#  #rc   c                 N   US S nSU;   a4  SU;   a.  SnU R                  SUSS S9nU(       a	  USU S	3-  n[        US
S9eSU;   aI  SnU R                  SUSS S9nU(       a$  USR                  UR                  SS5      5      -  n[        US
S9eSU;   a  SU;   a
  [        SS
S9eg g )N   z-<title>Access to this site is blocked</title>WebsensezWAccess to this webpage has been blocked by Websense filtering software in your network.z<iframe src="([^"]+)"zWebsense information URLdefaultz Visit z for more detailsTr  z5<title>The URL you requested has been blocked</title>zzAccess to this webpage has been blocked by Indian censorship. Use a VPN or proxy server (with --proxy) to route around it.z</h1><p>(.*?)</p>zblock messagez (Message: "{}")
 uG   <title>TTK :: Доступ к ресурсу ограничен</title>zblocklist.rkn.gov.ruzAccess to this webpage has been blocked by decision of the Russian government. Visit http://blocklist.rkn.gov.ru/ for a block reason.)_html_search_regexr   formatreplace)r[   r9  first_blockr/  blocked_iframe	block_msgs         r`   __check_blockedInfoExtractor.__check_blocked  s   dsm;wF+-kC!44('*D 5 :N  00ABB t44BkQO  //$$ 0 8I )001B1B41MNN t44UY``*g5 I  6 arc   c                     U(       d"  U R                  UR                  SS5      U5      n UR                  US5      $ ! [         a    UR                  SS5      s $ f = f)NzContent-TyperT   rQ  r?  )rF  r   rA  LookupError)r[   rD  r5  r
  s       r`   __decode_webpageInfoExtractor.__decode_webpage  s^    88^UW9XZghH	< '')<< 	< '';;	<s   = AAc
                 v    UR                  5       n
Ub  Xz-   n
U R                  SS5      (       a^  U R                  SUR                  -   5        [        R                  " U
5      R                  S5      nU R                  R                  U5        U R                  S5      (       a  [        U[        5      (       a  U R                  X)5      R                  n	[!        UR                  X9U R                  S5      S	9nU R                  S
U 35        [#        US5       nUR%                  U
5        S S S 5        U R'                  XUR(                  5      nU R+                  U5        U$ ! [         a<  nU SUR                   3nU(       a	  [        XS9eU R	                  U5         S nAgS nAff = f! , (       d  f       N= f)Nz: Error reading response: r  Fdump_intermediate_pageszDumping request to r>  write_pagestrim_file_nametrim_lengthzSaving request to wb)readr   r/  r   r   r   r   ru   base64	b64encoderA  r   r   r   r  r	  rN   openwrite_InfoExtractor__decode_webpager
  _InfoExtractor__check_blocked)r[   r8  r  r   r  r)  r*  prefixr5  r	  rD  r  r0  dumpfilenameoutfr9  s                    r`   r7  #InfoExtractor._webpage_read_content  sx   	 IIKM "2M>>3U;;NN0488;<##M299'BD&&t,>>-((.'22++NAFF-( NN+;<>H NN/z:;h%

=) & ''NW%5  	 z!;CGG9EF$V77'	( &%s#   E! F*!
F'+2F""F'*
F8c                 r    U(       a  [        U SU 3US9eU(       a  U R                  U SU SU 35        g g )Nr  r  )r   r   )r[   r)  r*  r   r  s        r`   __print_errorInfoExtractor.__print_error/  sD     H:Ry!9EE8*Bwir# ?@ rc   c                     U(       a  U" U5      n [        UR                  5       5      $ ! [        R                  R                  R
                   a"  nU R                  Uc  SOUXBU5         S nAg S nAff = f)NzFailed to parse XML)r   encodexmletreeElementTree
ParseError_InfoExtractor__print_error)r[   
xml_stringr   transform_sourcer*  r)  ves          r`   
_parse_xmlInfoExtractor._parse_xml5  si    )*5J	k*:+<+<+>??yy$$// 	k4WV[gijj	ks   * (A4A//A4c                      [         R                  " U4[        SUS.UD6$ ! [         a"  nU R	                  Uc  SOUXBU5         S nAg S nAff = f)NF)r   strictry  zFailed to parse JSON)jsonloadsr   
ValueErrorrw  )r[   json_stringr   ry  r*  r)  parser_kwargsrz  s           r`   _parse_jsonInfoExtractor._parse_json=  se    	l::w!3ETdwhuw w 	l5gW\hjkk	ls   ! 
AAAc                 t    U R                   " XR                  S5      UR                  S5      S-    /UQ70 UD6$ )N{}r=  )r  findrfind)r[   r	  argskwargss       r`   _parse_socket_response_as_json,InfoExtractor._parse_socket_response_as_jsonD  s8    YYs^DJJsOa4G HZ4ZSYZZrc   c                    ^^^ US.U4S jjmX#S SS S 0 0 S S S4U4S jjmX#S SS S 0 0 S S S4UUU4S jjnS nU" TSU  S	3S
U S35        U" USU  3U 5        TU4$ )N)r)  c                L   > Tc  U$ USL a  X$S'   [        U T5      " U/UQ70 UD6$ )NFr)  )getattr)r   r9  r)  r  r  parsers        r`   parse6InfoExtractor.__create_download_methods.<locals>.parseI  s9    ~%$+y!2v&w@@@@rc   TFc                 X   > U R                  XX4XgXXXS9nUSL a  U$ Uu  nnT" XX%XdS9U4$ )N)
r  r)  r*  r5  r	  r
  r  r  r  r+  Fry  r*  r)  )r:  )r[   r  r   r  r)  ry  r*  r5  r	  r
  r  r  r  r+  resr9  r8  r  s                    r`   download_handle@InfoExtractor.__create_download_methods.<locals>.download_handleQ  sW     //tE%' 0 VC e|
MGT[`rtxxxrc   c                 |  > U R                  S5      (       a  U R                  XX5      n[        UR                  X!R                  U R                  S5      S9nU R                  SU 35         [        US5       nUR                  5       nS S S 5        U R                  WXqR                  5      nT" U UX%XdS9$ UUUUUUU	U
UUUS.nTc  UR                  S	5        [        U TR                  5      " X40 UD6nUS
L a  U$ US   $ ! , (       d  f       N~= f! [         a  nU R                  SU 35         S nANS nAff = f)N
load_pagesr^  r_  zLoading request from rbr  z"Unable to load request from disk: )r  r)  ry  r*  r5  r	  r
  r  r  r  r+  ry  Fr   )r   r  rN   ru   r	  r   re  rb  rg  r
  OSErrorr   r   r  r   )r[   r  r   r  r)  ry  r*  r5  r	  r
  r  r  r  r+  rk  dumpfrD  r9  r   r  r  r  r  r  s                        r`   download_contentAInfoExtractor.__create_download_methods.<locals>.download_content]  sT    ~~l++!%!5!5nG![1"&&2E2E $/? @B !6xjAB{h-(-

 .
 #33M8McMcdG wchzz"$4$"#2*)>F ~

-.$ 8 89.]V\]C,32CF21 .- R''*LQC(PQQRs0   -D 9D
D 
DD 
D;D66D;c                 >    USU 3sU l         U l        SU S3U l        g )NzInfoExtractor.z
                @param transform_source     Apply this transformation before parsing
                @returns                    zg

                See _download_webpage_handle docstring for other arguments specification
            )r   __qualname____doc__)funcnamereturn_values      r`   r  <InfoExtractor.__create_download_methods.<locals>.impersonate  s2    /3~dV5L,DM4, --9N ;DLrc   
_download__handle(z, URL handle)r   )	r  r  r  r)  r  r  r  r  r  s	    `     @@r`   __create_download_methods'InfoExtractor.__create_download_methodsG  s    .5 	A 	A BFim"&D"TVhl(,E
	y CGjn#'$T2UWim)-U"	3 "	3H	 	Oz$w%?1\NR_A`a$
4&&9l^M 000rc   rs  r{  zDownloading XMLzUnable to download XMLz'xml as an xml.etree.ElementTree.Elementr  r  zDownloading JSON metadataz Unable to download JSON metadatazJSON object as a dictsocket_jsonr  zPolling socketzUnable to poll socketwebpagezdata of the page as a stringr=  c                      Sn
  U R                   " XX4SU/UQ70 U	D6$ ! [         a'  nU
S-  n
X:  a  UeU R                  Xr5         SnAOSnAff = fMP  )z
Return the data of the page as a string.

Keyword arguments:
tries -- number of tries
timeout -- sleep interval between tries

See _download_webpage_handle docstring for other arguments specification.
r   Nr=  ) _InfoExtractor__download_webpager   _sleep)r[   r  r   r  r)  r*  triestimeoutr  r  	try_countr   s               r`   _download_webpageInfoExtractor._download_webpage  ss    	 	/..~X\^cufjuntuu! /Q	%GG..	/ s    
AAAr  c                    [        US S5      nSU R                   SU U 3nU(       a2  SU 3U R                  ;   a  g U R                  R                  SU 35        U R                  R
                  " U/UQ70 UD6  g )N%s: [] z	WARNING: )r,   r   rh   addr   r   )r[   r/  r   r  r  r  idstrs          r`   r   InfoExtractor.report_warning  s~    XtV4$,,r%.3% D$:$::""&&3%'89''=d=f=rc   c                 d    U R                   R                  " SU R                   SU 3/UQ70 UD6  g)z2Print msg to screen, prefixing it with '[ie_name]'r  r  N)r   r   r   r[   r/  r  r  s       r`   r   InfoExtractor.to_screen  s1    ""Qt||nBse#<NtNvNrc   c                 d    U R                   R                  " SU R                   SU 3/UQ70 UD6  g )Nr  r  )r   r   r   r  s       r`   r   InfoExtractor.write_debug  s1    $$qb%>PPPrc   c                 |    U R                   (       a*  U R                   R                  R                  " X/UQ70 UD6$ U$ rq   )r   paramsr   )r[   r  rL  r  r  s        r`   r   InfoExtractor.get_param  s7    ##**..tNtNvNNrc   c                 n    U[         La  U R                  R                  S5        U R                  SSUS9  g )Nz?InfoExtractor.report_drm no longer accepts the argument partialzThis video is DRM protectedTr   r   )r   r   r$   raise_no_formats)r[   r   partials      r`   
report_drmInfoExtractor.report_drm  s6    *$001rs;dU]^rc   c                 ,    U R                  U S35        g)zReport information extraction.z: Extracting informationNr   )r[   
id_or_names     r`   report_extractionInfoExtractor.report_extraction  s    *%=>?rc   c                 ,    U R                  U S35        g)zReport webpage download.z: Downloading webpageNr  )r[   r   s     r`   r   %InfoExtractor.report_download_webpage  s    (#89:rc   c                 &    U R                  S5        g)zReport attempt to confirm age.zConfirming ageNr  r   s    r`   report_age_confirmation%InfoExtractor.report_age_confirmation  s    '(rc   c                 &    U R                  S5        g)zReport attempt to log in.z
Logging inNr  r   s    r`   report_loginInfoExtractor.report_login  s    |$rc   z1This video is only available for registered usersc                     U(       a>  U R                  S5      (       d  U R                  S5      (       a  U R                  U5        g U[        U R                  U5      S S5      -  n[	        USS9e)Nignore_no_formats_errorwait_for_videoz. %sTr  )r   r   r,   ra   r   )r[   r/  metadata_availabler\   s       r`   raise_login_required"InfoExtractor.raise_login_required  sb     899T^^L\=]=]$|D,,V4dFCCS400rc   c                     U(       a>  U R                  S5      (       d  U R                  S5      (       a  U R                  U5        g [        XS9e)Nr  r  )r   )r   r   r   )r[   r/  r   r  s       r`   raise_geo_restricted"InfoExtractor.raise_geo_restricted  s?     899T^^L\=]=]$$S>>rc   c                     U(       a>  U R                  S5      (       d  U R                  S5      (       a  U R                  X5        g [        U[        5      (       a  Ue[        XUS9e)Nr  r  r  )r   r   r   r   )r[   r/  r   r   s       r`   r  InfoExtractor.raise_no_formats  sQ    899T^^L\=]=].^,,I (KKrc   )url_transparentc                    Ub*  [        U[        5      (       a  UOUR                  5       US'   Ub  X%S'   Ub  X5S'   0 UEU(       a  SOSU S.E$ )z<Returns a URL that points to a page that should be processedr   r   titler  ru   _typeru   )r   r!  r   )ru   r   r   video_titler  r  s         r`   
url_resultInfoExtractor.url_result  sc     >%/C%8%8rbiikF8#4L")7O

*9&u
 	
rc   c           	      j   ^ ^^ T R                   " U UU4S j[        [        XA5      SS9 5       X#40 UD6$ )Nc              3   ^   >#    U  H"  nTR                   " UT40 T=(       d    0 D6v   M$     g 7frq   )r  )rs   rE  r   r   video_kwargss     r`   rv   6InfoExtractor.playlist_from_matches.<locals>.<genexpr>  s(     pDoqS^^Ar:l&8b:Dos   *-Tlazy)playlist_resultr2   r{   )r   matchesplaylist_idplaylist_titlegetterr   r  r  s   `    `` r`   playlist_from_matches#InfoExtractor.playlist_from_matches  s9     ""pJsSYOcjnDop3+13 	3rc   )multi_videoc                `    U(       a  XS'   U(       a  X%S'   Ub  X5S'   0 UEU(       a  SOSU S.E$ )zReturns a playlistr   r  descriptionr  playlist)r  entriesr   )r  r  r  playlist_descriptionr  r  s         r`   r  InfoExtractor.playlist_result  sG     &4L,7O+$8=!

&1]z
 	
rc   r   c                   ^
 Uc  Sm
Of[        U[        [        R                  45      (       a  [        R                  " XU5      m
O)U H#  n[        R                  " XU5      m
T
(       d  M#    O   U R
                  R                  X0R
                  R                  R                  5      n	T
(       ad  Uc   [        S T
R                  5        5       5      $ [        U[        [        45      (       a  [        U
4S jU 5       5      $ T
R                  U5      $ U[        La  U$ U(       a  [        SU	 35      eU R!                  SU	 3[#        5       -   5        g)z
Perform a regex search on the given string, using a single or a list of
patterns returning the first matching group.
In case of failure return a default value or raise a WARNING or a
RegexNotFoundError, depending on fatal, specifying the field name.
Nc              3   .   #    U  H  oc  M  Uv   M     g 7frq   r   )rs   gs     r`   rv   .InfoExtractor._search_regex.<locals>.<genexpr>8  s     F}!AA}s   	c              3   F   >#    U  H  nTR                  U5      v   M     g 7frq   r   )rs   r  mobjs     r`   rv   r  :  s     :EqTZZ]]Es   !Unable to extract zunable to extract )r   r!  r|   Patternr@  r   _format_errStylesEMPHASISr~   groupsr   rz   r   r   r   r   r!   )r[   patternstringr  rL  r*  flagsr   p_namer  s             @r`   _search_regexInfoExtractor._search_regex"  s    >D#rzz!23399We4DyyE24 
   ,,T3C3C3J3J3S3ST}Ft{{}FFFED%=11:E:::zz%((J&N$'9%%ABB"4UG <?R?T TUrc   rT   z	{(?s:.+)})end_patterncontains_patternr*  rL  c          	         U[         L a  0 SpOSu  pzU R                  SU SU SU S3X#SXz(       a  SO[         S	9nU(       d  U$ U R                  R                  X0R                  R                  R
                  5      n U R                  " X4S
S0U	D6$ ! [         aH  nU(       a  [        SU S3UR                  US9eU
(       d  U R                  SU SU 3US9   SnAU$ SnAff = f)z>Searches string for the JSON object specified by start_patternF)FTz(?:z)\s*(?P<json>z)\s*(?:)r  N)r   r*  rL  ignore_extraTr  z - Failed to parse JSONr   z - Failed to parse JSON: r   )
r   r  r   r	  r
  r  r  r   r   r   )r[   start_patternr  r  r   r  r  r*  rL  r  has_defaultr  r  r   s                 r`   _search_jsonInfoExtractor._search_jsonE  s    j #%u[!,E((=//?.@}TUVe[TV` ) b N  ,,T3C3C3J3J3S3ST	a##KWWPVWW 	a$(/FGqwwaik k ##(/HLW_ $ a	as   >B 
C%=C  C%c           	          U R                  XX4XVU5      n[        U[        5      (       a  [        [        [        U5      5      $ [	        U5      $ )zB
Like _search_regex, but strips HTML tags and unescapes entities.
)r  r   rz   r{   r#   )	r[   r  r  r  rL  r*  r  r   r  s	            r`   rO   InfoExtractor._html_search_regex`  sC       $uUc5!!Z-..#rc   c                 n   U=(       d    U R                   nU R                  S5      nU(       a}  UR                  SU5      nU R                  SU 35        [        R
                  " USS[        R                  S9u  p4nUS:w  a  [        SU 35      e[        U5      R                  U5      nOU R                  SS	5      (       a  [        U R                  S
5      =(       d    S5      n[        R                  R                  U5      (       a   [        R                  R                  US5      n[         R                   " U5      R                  U5      nOgU(       d  U R                  SU 35        gU R#                  SU S35        [$        R&                  S:  a  [)        S US S S2    5       5      $ US   US   4$ )N	netrc_cmd{}zExecuting command: T)textshellstdoutr   zCommand returned error code usenetrcFnetrc_location~z.netrcNNzNo authenticators for zUsing netrc for z authentication)      c              3   4   #    U  H  oS :w  a  UOSv   M     g7f)z""rT   Nr   rs   xs     r`   rv   6InfoExtractor._get_netrc_login_info.<locals>.<genexpr>  s     CA4iR/s   r   )rY   r   rQ  r   r   run
subprocessPIPEr  r1   authenticatorsr   ospathisdirjoinr]   r   r   version_inforz   )r[   netrc_machinecmdr%  r   retinfo
netrc_files           r`   _get_netrc_login_info#InfoExtractor._get_netrc_login_infoi  so   %<)<)<nn[)++dM2CNN067"YYsT*//ZNFsax <SEBCC%f-<<]KD^^J..*4>>:J+K+RsSJww}}Z((WW\\*h?
;;z*99-HD NN3M?CD+M?/JK
 g%CccCCCAwQrc   c                     U R                  U5      nUb  U R                  U5      nXE4$  U R                  U5      u  pEXE4$ ! [        [        R                  4 a  nU R                  SU 35         SnAgSnAff = f)ak  
Get the login info as (username, password)
First look for the manually specified credentials using username_option
and password_option as keys in params dictionary. If no such credentials
are available try the netrc_cmd if it is defined or look in the
netrc file using the netrc_machine or _NETRC_MACHINE value.
If there's no info available, return (None, None)
NzFailed to parse .netrc: r)  )r   r>  r  r]   NetrcParseErrorr   )r[   username_optionpassword_optionr9  r   rV   r  s          r`   r   InfoExtractor._get_login_info  s     >>/2~~o6H !!"%)%?%?%N" !! U223 "##&>se$DE!"s   A   A8A33A8c                 b    U R                  S5      nUb  U$ [        R                  " SU S35      $ )z
Get the two-factor authentication info
TODO - asking the user will be required for sms/phone verify
currently just uses the command line option
If there's no info available, return None
	twofactorzType z and press [Return]: )r   getpass)r[   r  tfas      r`   _get_tfa_infoInfoExtractor._get_tfa_info  s5     nn[)?Jtf,ABCCrc   c                 j    SnSR                  [        R                  " U 5      SS9nSnX2U4-  X1U4-  /$ )NzBcontent=(?:"([^"]+?)"|\'([^\']+?)\'|\s*([^\s"\'=<>`]+?)(?=\s|/?>))zJ(?:name|property)=(?:\'og{sep}{prop}\'|"og{sep}{prop}"|\s*og{sep}{prop}\b)z(?:&#x3A;|[:-]))propsepz<meta[^>]+?%s[^>]+?%s)rP  r|   escape)rL  
content_reproperty_retemplates       r`   _og_regexesInfoExtractor._og_regexes  sP    Z
cjj4&7 k 9+Z00K00
 	
rc   c                 6    S[         R                  " U 5       S3$ )NzY(?isx)<meta
                    (?=[^>]+(?:itemprop|name|property|id|http-equiv)=(["\']?)z?\1)
                    [^>]+?content=(["\'])(?P<content>.*?)\2)r|   rN  )rL  s    r`   _meta_regexInfoExtractor._meta_regex  s'    NNPiiX\oM^ _<? 	?rc   c                     [        U5      nUc  SUS    3n/ nU H#  nUR                  U R                  U5      5        M%     U R                  " XRU4S[        R
                  0UD6nUc  g [        U5      $ )Nz
OpenGraph r   r  )rJ   extendrR  r  r|   DOTALLrC   )r[   rL  htmlr  kargs
og_regexesr  escapeds           r`   _og_search_property!InfoExtractor._og_search_property  s|    ~<Qy)D
Ad..q12 $$ZtV299VPUV?G$$rc   c                 0    U R                   " SUS4SS0UD6$ )Nimagezthumbnail URLr*  Fr^  r[   rZ  r[  s      r`   _og_search_thumbnail"InfoExtractor._og_search_thumbnail  s"    '']e]W\]]rc   c                 .    U R                   " SU4SS0UD6$ )Nr  r*  Frb  rc  s      r`   _og_search_description$InfoExtractor._og_search_description  s    ''tR5RERRrc   r*  c                .    U R                   " SU4SU0UD6$ )Nr  r*  rb  )r[   rZ  r*  r[  s       r`   _og_search_titleInfoExtractor._og_search_title  s    ''LULeLLrc   c                     U R                  S5      U R                  S5      -   nU(       a  U R                  S5      U-   nU R                  " XQU40 UD6$ )Nvideoz	video:urlzvideo:secure_url)rR  rO  )r[   rZ  r  securer[  regexess         r`   _og_search_video_url"InfoExtractor._og_search_video_url  sS    ""7+d.>.>{.KK&&'9:WDG&&wdDeDDrc   c                 *    U R                   " SU40 UD6$ )Nru   rb  rc  s      r`   _og_search_urlInfoExtractor._og_search_url  s    ''t=u==rc   c                .    U R                   " SX4SU0UD6$ )Nz!(?s)<title\b[^>]*>([^<]+)</title>r*  )rO  )r[   rZ  r  r*  r  s        r`   _html_extract_title!InfoExtractor._html_extract_title  s"    &&'KTo_dohnoorc   c                     [        U5      nUc  US   nU R                  " U Vs/ s H  o`R                  U5      PM     snX#4USS.UD6$ s  snf )Nr   r9  )r*  r   )rJ   rO  rU  )r[   r  rZ  display_namer*  r  ns          r`   _html_search_metaInfoExtractor._html_search_meta  sd    ~7L&&*./$Qa $/H&+9H@FH 	H/s   A
c                 (    U R                  SUS5      $ )Nz
dc.creatoruploaderr|  r[   rZ  s     r`   _dc_search_uploader!InfoExtractor._dc_search_uploader  s    %%lD*EErc   c                     [         R                  " SU 5      (       a  g/ SQnS nU HI  n[         R                  " X05      nU(       d  M"  [        U=(       d    S[        [	        USSS95      5      nMK     U$ )NzG(?ix)<meta\s+name="rating"\s+     content="RTA-5042-1996-1400-1577-RTA"   )zYProudly Labeled <a href="http://www\.rtalabel\.org/" title="Restricted to Adults">RTA</a>z6>[^<]*you acknowledge you are at least (\d+) years oldu2   >\s*(?:18\s+U(?:\.S\.C\.|SC)\s+)?(?:§+\s*)?2257\br   r=  rK  )r|   r@  maxintr?   )rZ  AGE_LIMIT_MARKERS	age_limitmarkerr  s        r`   _rta_searchInfoExtractor._rta_search  sv     99 C  
 	'F99V*Dt	QLqRT4U0VW	 ( rc   c                     U R                  SU5      nU(       d  g SSSSSS.nUR                  UR                  5       5      $ )Nratingr               )zsafe for kidsgeneralz14 yearsmature
restrictedr|  r   lower)r[   rZ  r  RATING_TABLEs       r`   _media_rating_search"InfoExtractor._media_rating_search  sK    ''$7 
 //rc   c                     U R                  SUS S9nU(       d  g SSSSS.nUR                  UR                  5       5      $ )NisFamilyFriendlyrK  r   r  )1true0falser  )r[   rZ  family_friendlyr  s       r`   _family_friendly_search%InfoExtractor._family_friendly_search  sW    00d 1 4  	
  5 5 788rc   c                 (    U R                  SUS5      $ )Nztwitter:playerztwitter card playerr  r  s     r`   _twitter_search_player$InfoExtractor._twitter_search_player"  s    %%&6&;= 	=rc   r*  rL  c             #   P  #    U[         La  SnU(       d  [        U[        5      (       d  g[        R                  " [
        U5       H[  nU R                  UR                  S5      X#U[         La  SOSS9n[        U5       H  n[        U[        5      (       d  M  Uv   M      M]     g7f)z%Yield all json ld objects in the htmlFNjson_ldr*  r)  )
r   r   r!  r|   finditerr   r  r   rJ   dict)r[   rZ  r   r*  rL  r  json_ld_itemr  s           r`   _yield_json_ldInfoExtractor._yield_json_ld&  s     *$EZc22KK
D1D++

9%x!(
!: , FL $L1gt,,!M 2	 2s   BB&B&c                    U[         La  SnU R                  [        U R                  XXES95      X$US9nU(       a  U$ U[         La  U$ U(       a  [	        S5      eU R                  S[        5        35        0 $ )z-Search for a video in any json ld in the htmlFr  )r*  expected_typezUnable to extract JSON-LDzunable to extract JSON-LD )r   _json_ldr   r  r   r   r!   )r[   rZ  r   r  r*  rL  r<  s          r`   _search_json_ldInfoExtractor._search_json_ld4  s    *$E}}$$T5$RS  @ K*$N$%@AA"<=P=R<S TUIrc   c           	      
  ^ ^^^^^^	^
^^ [        U[        5      (       a  T R                  XUS9nU(       d  0 $ 0 m
SSSSSSSSS.mS mS mUUU
U4S	 jmU
U 4S
 jmUUU
UU 4S jm	SUU	U
UU4S jjmT" U5        [        T
5      $ )Nri  commentlikedislikeview)CommentActionAgreeActionDisagreeAction
LikeActionDislikeActionListenActionWatchAction
ViewActionc                 X   ^ [        [        U S5      5      m[        U4S jU 5       5      $ )N@typec              3   ,   >#    U  H	  oT;   v   M     g 7frq   r   )rs   r.  type_s     r`   rv   :InfoExtractor._json_ld.<locals>.is_type.<locals>.<genexpr>Y  s     :>aEz>s   )rJ   r?   rU   )r   expected_typesr  s     @r`   is_type'InfoExtractor._json_ld.<locals>.is_typeW  s%    \!W56E:>:::rc   c                     U R                  S5      n[        U[        5      (       a  UR                  S5      n[        U5      $ )NinteractionTyper  )r   r   r  r<   )r   interaction_types     r`   extract_interaction_type8InfoExtractor._json_ld.<locals>.extract_interaction_type[  s=     uu%67*D11#3#7#7#@ /00rc   c                   > U R                  S5      n[        U[        5      (       a  U/n[        U[        5      (       d  g U H  nT
" US5      (       d  M  T" U5      nU(       d  M$  [	        UR                  S5      5      nUc  MC  TR                  UR                  S5      S   5      nU(       d  Mo  U S3nT	R                  U5      b  M  UT	U'   M     g )NinteractionStatisticInteractionCounteruserInteractionCount/_count)r   r   r  r   r=   split)r   interaction_statisticis_er  interaction_count
count_kind	count_keyINTERACTION_TYPE_MAPr  r<  r  s          r`   extract_interaction_statistic=InfoExtractor._json_ld.<locals>.extract_interaction_statistica  s    $%EE*@$A!/66)>(?%3T::-t%9::#;D#A ' %/txx8N/O$P!$,1556F6L6LS6QRT6UV
!)l&1	88I&2"3Y% .rc   c           	      L  > [        U R                  S5      =(       d    / 5       Vs/ s HL  oR                  S5      S:X  d  M  UR                  S5      UR                  S5      UR                  S5      S.PMN     nn[        [        SS	0/UQX"S
S  5      5       H\  u  nu  pEnUS   =(       d    US   US'   US   =(       d    US   US'   S UR	                  5       ;   d  MG  TR                  SU S35          g    U(       a   US   S   =(       d    TS   US   S'   UTS'   g g s  snf )NhasPartr  Clipr  startOffset	endOffset)r  
start_timeend_timer  r   r=  r  zChapter z. contains broken data. Not extracting chaptersr  durationchapters)rJ   r   	enumeratezipvaluesr   )	r   partr  idxlast_c	current_cnext_cr<  r[   s	          r`   extract_chapter_information;InfoExtractor._json_ld.<locals>.extract_chapter_information{  sK   
 #155#3#9r:	[ ;$hhw>OSY>Y	&)"hh}5 HH[1 ;	  [
 5>c !_0x0(QRL?J 5K00f(1*(=(UAU	*%*3L*A*WVJEW	,'9++--''(3%7e(fg5K +3B<
+C+WtJGWZ(#+Z  [s   D!7D!c                 *  >^  T R                  S5      nTR                  [        T R                  S5      5      [        T R                  S5      5      [	        T R                  S5      5      [	        T R                  S5      5      [        T SSS[        1[        1TR                  1[        14045      [        T R                  S	5      5      [        T R                  S
5      5      [        U[        5      (       a  UR                  S5      O[        U[        5      (       a  UOS [        T S[        S9[        [        T R                  S5      5      5      [        T R                  S5      5      [        T R                  S5      5      [        T R                  S5      5      [        T R                  S5      5      [        U 4S j5      S.5        T" T S5      (       a,  TR                  S[        T R                  S5      5      S.5        T" T 5        T" T 5        g )Nauthor
contentUrlencodingFormatr  r  )thumbnailUrlthumbnailURLthumbnail_url)N.ru   r  
uploadDate)byArtistr  r  contentSizebitratewidthheightinteractionCountc                  D   > T R                  S5      R                  S5      $ )Nkeywords,)r   r  )r   s   r`   <lambda>FInfoExtractor._json_ld.<locals>.extract_video_object.<locals>.<lambda>  s    z):)@)@)Erc   )ru   extr  r  
thumbnailsr  	timestampr  artistfilesizetbrr  r  
view_counttagsAudioObjectnone)vcodecabr)r   r  rG   r0   rC   r?   r!  _proto_relative_urlr5   rE   r   r  r-   r+   rA   )r   r  r  r  r<  r  r[   s   ` r`   extract_video_object4InfoExtractor._json_ld.<locals>.extract_video_object  s   UU8_FKK"155#67#AEE*:$;<%aeeFm4+AEE-,@A*1/`bmSEL>D4L4L3MP[}]p /  +155+<=.quu\/BC
 3=VT2J2JFJJv.ZdekmpZqZqPVw{&q*>cR'aeeM6J(KL"155#34$QUU7^4%aeeHo6)!%%0B*CD !EF+ . q-(($&quuY'78  *!,'*rc   c                   > [        U 5       GHw  n[        U[        5      (       d  M  U(       a  SU;  a  M*  U(       a+  [        UR	                  5       5      SS1:X  a  T" US   SS9  M\  Tb  T" UT5      (       d  Mo  [        US[        S9nUb  UT
S'   T" USS	S
5      (       Ga>  [        UR                  S5      5      nT
R                  U[        UR                  S5      5      [        UR                  S5      5      S.5        T
R                  S5      (       d  U(       a  UT
S'   UR                  S5      nT" USSS5      (       aD  T
R                  [        UR                  S5      5      [        UR                  S5      5      S.5        UR                  S5      =(       d    UR                  S5      nT" USSS5      (       a  [        UR                  S5      5      T
S'   GOvT" US5      (       aw  T
R                  [        UR                  S5      5      [        UR                  S5      5      [        UR                  S5      5      [        UR                  S5      5      S.5        OT" US S!5      (       a  T
R                  [        UR                  S"5      5      [        UR                  S#5      5      [        UR                  S$5      =(       d    UR                  S5      5      S%.5        T" [        US&5      S'5      (       a  T	" US(   S)   5        OFT" [        US*5      S'5      (       a  T	" US+   S)   5        OT" US'S,5      (       a  T	" U5        Tc  GMI    g UR                  S(5      nT" US'5      (       a  T	" U5        Tc  GMx    g    g )-Nz@contextz@graphF)at_top_level)aggregateRatingratingValuer  average_rating	TVEpisodeEpisodePodcastEpisoder  episodeNumberr  )episodeepisode_numberr  r  partOfSeasonTVSeasonSeasonCreativeWorkSeasonseasonNumber)seasonseason_numberpartOfSeriespartOfTVSeriesTVSeriesSeriesCreativeWorkSeriesseriesMovier  dateCreated)r  r  r  r  ArticleNewsArticledatePublishedheadlinearticleBody)r  r  r  )rn  r   VideoObjectrn  r   )	subjectOfr   r5  r  )rJ   r   r  rg   keysr?   r+   rC   r   r  r-   r5   rE   r6   )r  r  r   r  episode_namepart_of_seasonpart_of_seriesrn  r  r  r<  r  traverse_json_lds           r`   r:  0InfoExtractor._json_ld.<locals>.traverse_json_ld  s   g&!!T**Ja$7CMj(5K$K$Qx[uE ,WQ5N5N%a)K[hi%-3D)*1k96FGG#/f#>LKK#/*5aeeO6L*M'3AEE-4H'I! 
  88G,,(4W%&UU>%:N~z8EYZZ&2>3E3Ef3M&N-89K9KN9[-\%  &'UU>%:%UaeeDT>UN~z8EYZZ)5n6H6H6P)QXQ((KK!-aeeFm!<'3AEE-4H'I$21553D$E%6quu]7K%L	!  Q	=99KK%21553I%J!-aeeJ.?!@'3AEE-4H4`AEER_L`'a! 
 |A|<mLL,QwZ]; a1A!BMRR,Q{^A->?Q}==(+$, g5-00(/ (y 'rc   T)r   r!  r  r)   )r[   r  r   r*  r  r  r  r  r  r  r<  r  r:  s   `   `@@@@@@@@r`   r  InfoExtractor._json_ldE  s    gs##&&w&FGI '!' &"! 	 
	;	1	4 	44	,"	+ 	+B=	 =	~ 	!4  rc   c                    US:X  a  U R                   R                  S5        0 nU[        La  SnU R                  " SUSU4SX4S.UD6$ )Nr"  z<using `default='{}'` is deprecated, use `default={}` insteadFz,<script[^>]+id=[\'"]__NEXT_DATA__[\'"][^>]*>znext.js dataz	</script>)r  r*  rL  )r   r$   r   r  )r[   r  r   r*  rL  kws         r`   _search_nextjs_data!InfoExtractor._search_nextjs_data  sc    d?001qrG*$E  ;WnS"-USOQS 	Src   c           
      *  ^^ 0 mU(       d  [        U[        5      (       d  T$ UU4S jmSn[        R                  " SU5       He  nU R	                  XRX3(       a  SOSS9n[        U[
        5      (       a  [        U5      S:w  a  U R                  U S3S	S
9  MU  Uu  pxUS:X  d  Ma  XH-  nMg     UR                  5        H  n	U	R                  5       R                  S5      u  pn[        R                  " SU
5      (       d  MC  UR                  S5      (       a/  UR                  S5      (       a  T" U R	                  XSSS95        M  UR                  S5      (       d  M  UR                  S5      (       d  M  U R	                  XSSS9nUc  M  UTU
'   M     T$ )zHParses Next.js app router flight data that was introduced in Next.js v13c                 p  > [        U [        5      (       d  g [        U 5      S:X  a  U S   S:X  av  U u  pp[        U[        5      (       d  g UR	                  SS 5      nU(       a9  [        U[
        5      (       a$  [        R                  " SU5      (       a  UTUSS  '   T" U5        g U  H  nT" U5        M     g )N   r   $childrenz\$L[0-9a-f]+r   )r   r   lenr  r   r!  r|   	fullmatch)flight_datar   r  r	  rF  fflattennextjs_datas         r`   rK  6InfoExtractor._search_nextjs_v13_data.<locals>.flatten   s    k400;1$Q3)>#. !$--88J5JtS11bll?TX6Y6Y,0KQR)! 
 !rc   rT   z9<script\b[^>]*>self\.__next_f\.push\((\[.+?\])\)</script>NFr  r   z4: Unsupported next.js flight data structure detectedTr  r=  :z	[0-9a-f]+r  ]r  r  )r   r!  r|   findallr  r   rG  r   
splitlineslstripr6  rH  rB  endswith)r[   r  r   r*  flight_textflight_segmentsegmentpayload_typechunkrJ  ri  r   bodyr	  rK  rL  s                 @@r`   _search_nextjs_v13_data%InfoExtractor._search_nextjs_v13_data  s   Z55	   !jj)egnoN&&~u^cVZin&oG gt,,G0A  j TUae ! g #*Lq $ p '')Ahhj2237OFt<<f55s##c(:(:((ue(TU%%$--*<*<''eU'S#*.K' * rc   )r	  r   )r*  traversec                   [         R                  " U5      nSnU R                  SU SU S3U SU 34XSU(       a  [        OSS9u  pn
Uc  0 $ [	        [        U	R                  S	5      [        [        R                  U R                  S
U
 S3U[        US9=(       d    S5      5      5      nU R                  X[        R                  " [        US9US9n[        X5      =(       d    0 $ )z_Parses Nuxt.js metadata. This works as long as the function __NUXT__ invokes is a pure functionzY\(function\((?P<arg_keys>.*?)\){.*?\breturn\s+(?P<js>{.*?})\s*;?\s*}\((?P<arg_vals>.*?)\)z<script>\s*window\.=z\s*\)\s*;?\s*</script>z\(.*?)jsarg_keysarg_valsNNN)r   rL  r  r  rO  )ry  r*  r   )vars)r|   rN  r  r   r  r  r  r{   r  dumpsr  r/   	functoolsr  r?   )r[   r  r   context_namer*  r\  rectxFUNCTION_REr_  r`  ra  r  r;  s                r`   _search_nuxt_dataInfoExtractor._search_nuxt_data/  s   		,'r!%!3!3#E7!K=8NOUZT[[`al`mQno)G"'J-? "4 "Ah :ICs+ST=M=MzOX
% >N >Q >WTV.X Y Z ri>O>OPZae>fnstC*0b0rc   c                "   U[         La  Sn[        U[        5      (       a  U(       d7  SnU(       a	  [        XRS9eU[         L a  U R	                  XRS9  U[         L a  0 $ U$ S nS n[
        R                  " UUUUUUUUS.S9n  S	UR                  S
5       3nU(       a	  [        XRS9eU[         L a  U R	                  XRSS9  OU R                  U SU 3SS9   MW  ! [         a*  n	U	R                  =(       d    U[         L a  0 OUs S
n	A	$ S
n	A	ff = f)z&Resolves Nuxt rich JSON payload arraysFz/Unable to resolve Nuxt JSON data: invalid inputr  c                     U $ rq   r   r	  s    r`   indirect_reviver;InfoExtractor._resolve_nuxt_array.<locals>.indirect_reviverO  s    Krc   c                 .    [         R                  " U 5      $ rq   )r  r  rm  s    r`   json_reviver7InfoExtractor._resolve_nuxt_array.<locals>.json_reviverR  s    ::d##rc   )	NuxtErrorEmptyShallowRefEmptyRef
ShallowRefShallowReactiveRefReactive)reviversTzError resolving Nuxt JSON: N)r   r  r  r  )r   r   r   r   r   rO   
parse_itersendr   r   value)
r[   arrayr   r*  rL  	error_msgrn  rq  generrors
             r`   _resolve_nuxt_array!InfoExtractor._resolve_nuxt_array@  s/    *$E%&&eII$YBBJ&##I#A J.2;G;		$   )+$*/#(2
  	Q9#((4.9IJ	(FF
*''	PT'U$$zI;%?4$P  ! Q{{PW
-BrPQs$   =C C 
D$D	D	Dc          
          U[         LnU R                  SUSUSX5(       d  [         OSS9nU(       d  U(       a  U$ 0 $ U R                  XbX4S9$ )z=Parses metadata from Nuxt rich JSON payloads embedded in HTMLz(<script\b[^>]+\bid="__NUXT_DATA__"[^>]*>zNuxt JSON dataz\[(?s:.+)\]N)r  r*  rL  r  )r   r  r  )r[   r  r   r*  rL  passed_defaultr~  s          r`   _search_nuxt_jsonInfoExtractor._search_nuxt_jsonk  s_     
2!!7h>t " M
 ,74"4''u'VVrc   c                 d   [         R                  " SSU 5      n 0 n[         R                  " SU 5       Hz  n[        U5      nU(       d  M  UR	                  S5      S;  a  M.  UR	                  S5      =(       d    UR	                  S5      nUR	                  S5      nU(       d  Mq  Uc  Mv  XQU'   M|     U$ )	Nz<!--(?:(?!<!--).)*-->rT   z(?i)(<input[^>]+>)type)hiddensubmitr  r   r}  )r|   subrP  r(   r   )rZ  hidden_inputsinput_elattrsr  r}  s         r`   _hidden_inputsInfoExtractor._hidden_inputsy  s    vv.D9

#8$?H&x0Eyy (<<99V$7		$DIIg&Et)&+d# @ rc   c                 T    U R                  SU S3X! S3SS9nU R                  U5      $ )Nz(?is)<form[^>]+?id=(["\'])z\1[^>]*>(?P<form>.+?)</form>z formformr  )r  r  )r[   form_idrZ  r  s       r`   _form_hidden_inputs!InfoExtractor._form_hidden_inputs  sC    !!)'2NOIU#6 " 3 ""4((rc   )r   c                 :     " S S[         5      n[        S5        U$ )Nc                   (   ^  \ rS rSrU 4S jrSrU =r$ ),InfoExtractor.FormatSort.<locals>.FormatSorti  c                 B   > [         TU ]  " U R                  /UQ70 UD6  g rq   )superrl   r   )r   r  r  	__class__s      r`   rl   5InfoExtractor.FormatSort.<locals>.FormatSort.__init__  s     A$A&Arc   r   )r   
__module__r  __firstlineno__rl   __static_attributes____classcell__r  s   @r`   
FormatSortr    s    B Brc   r  zuyt_dlp.InfoExtractor.FormatSort is deprecated and may be removed in the future. Use yt_dlp.utils.FormatSorter instead)r   r$   )r   r  s     r`   r  InfoExtractor.FormatSort  s'    	B 	B 	4	5 rc   c                     U(       d  U R                   R                  S5        g U R                   R                  S5        U(       a  X!S   S'   g g )NzJyt_dlp.InfoExtractor._sort_formats is deprecated and is no longer requiredzyt_dlp.InfoExtractor._sort_formats is deprecated and no longer works as expected. Return _format_sort_fields in the info_dict insteadr   __sort_fieldsr   r$   )r[   formatsfield_preferences      r`   _sort_formatsInfoExtractor._sort_formats  sQ    00\^,,B	C *:AJ' rc   c                 @   ^ ^ U(       a  [        U U4S jU5      US S & g g )Nc           	         > TR                  U S   TU R                  S5      (       a"  SR                  U R                  S5      5      S9$ SS9$ )Nru   	format_idz{} video formatrn  )item)_is_valid_urlr   rP  )rJ  r[   r   s    r`   r  .InfoExtractor._check_formats.<locals>.<lambda>  sS    $,,eHhIJ{I[I[*11!%%2DE - jah - jrc   )r   )r[   r  r   s   ` `r`   _check_formatsInfoExtractor._check_formats  s$    j 	GAJ rc   c                   ^ [        5       n[        5       n/ nU  H  mTR                  S5      n[        U5      (       a  UR                  T5        M7  U(       a@  [	        U4S jU 5       5      nXR;  a$  UR                  U5        UR                  T5        M|  M~  TS   U;  d  M  UR                  TS   5        UR                  T5        M     X0S S & g )N	fragmentsc              3   x   >#    U  H/  nUR                  S 5      =(       d    [        TS   US   5      v   M1     g7f)ru   fragment_base_urlr5  N)r   rI   )rs   fragmentrJ  s     r`   rv   :InfoExtractor._remove_duplicate_formats.<locals>.<genexpr>  s<      */$- LL'\715H3I8TZK[+\\$-s   7:ru   )rg   r   r  append	frozensetr  )r  	seen_urlsseen_fragment_urlsunique_formatsr  fragment_urlsrJ  s         @r`   _remove_duplicate_formats'InfoExtractor._remove_duplicate_formats  s    E	 UAk*I	""%%a( ) */$-*/ !/ !:&**=9"))!, ; 5*ah'%%a( " $
rc   rn  c                     U R                  USS9nUR                  S5      (       d  g U R                  XSU S3US9  g! [         a.  nU R	                  U SU S	UR
                  < 35         S nAg
S nAff = f)Nhttp:schemezhttp://zhttps://Tz	Checking z URL)r
  r  z URL is invalid, skipping: F)r  rB  r1  r   r   r   )r[   ru   r   r  r
  r   s         r`   r  InfoExtractor._is_valid_url  s    &&s7&;~~566	!!#9TF$1GQX!Y 	NN*Btf$?{KM	s   ? 
A7	$A22A7c                 8    U R                  SS5      (       a  S$ S$ )z@Either "http:" or "https:", depending on the user's preferences prefer_insecureFr  zhttps:r   r   s    r`   http_schemeInfoExtractor.http_scheme  s*     ~~/77 	 	rc   c                 |    U=(       d    U R                  5       nUR                  S5      (       d   e[        XS S S9$ )NrN  r  r  )r  rS  r:   )r[   ru   r  s      r`   r  !InfoExtractor._proto_relative_url  s;    -4++-s####Cs44rc   c                 j    Uc  SnX2US.-  nU R                  U5        [        R                  " U5        g )Nz-%(video_id)s: Waiting for %(timeout)s seconds)r   r  )r   r  r  )r[   r  r   msg_templater/  s        r`   r  InfoExtractor._sleep  s2    JLwGGs

7rc   c                 4    [        U 5      R                  5       $ rq   r*   stripss    r`   r  InfoExtractor.<lambda>  s    8J18M8S8S8Urc   c                     U R                  S5      (       a  SnU R                  XSSUXyXS9	nUSL a  / $ Uu  pUR                  nU R                  XX#XEXgUS9	$ )Nr  FzDownloading f4m manifestzUnable to download f4m manifest)ry  r*  r	  r
  r  )
preferencequalityf4m_idry  r*  m3u8_id)r   _download_xml_handleru   _parse_f4m_formats)r[   manifest_urlr   r  r  r  ry  r*  r  r	  r
  r  r  manifestr8  s                  r`   _extract_f4m_formats"InfoExtractor._extract_f4m_formats  s     >>344E''$>- .G ( B %<Ixx&&HW-G ' M 	Mrc   c                 4    [        U 5      R                  5       $ rq   r  r  s    r`   r  r    s    6H6K6Q6Q6Src   c
                    [        U[        R                  R                  R                  5      (       d	  U(       d  / $ UR                  S5      n
U
bD  SU
R                  ;   a4  U
R                  R                  S5      S   nUR                  5       S:w  a  / $ / nSnUR                  S5      nU(       d  SnUR                  S5      n[        U5      nU(       d  U$ [        U5      n[        US	S
/SS S9nS n[        USS/SS S9nU(       a  UR                  S5      (       a  Sn[        U5       GH/  u  nn[!        UR"                  R%                  S5      5      n[!        UR"                  R%                  S5      5      n[!        UR"                  R%                  S5      5      n['        UU=(       d    U5      nUGc  S nUS:X  a  UR"                  R%                  S5      nUc  UR"                  R%                  S5      nU(       d  M  UR                  S5      (       a  UO1U=(       d#    SR)                  UR                  S5      S S 5      S-   U-   n[+        U5      nUS:X  a  U R-                  X#XEUXxS9n[/        U5      S:X  a|  US   nUR1                  UR%                  S5      =(       d    UUR%                  S5      =(       d    UUR%                  S5      =(       d    UU(       d  UR%                  S5      OUUS.5        UR3                  U5        GM  US :X  a%  UR3                  U R5                  X#S!UXYUS"95        GM  UR7                  UUUUb  S#OS SUUUUUUS$.5        GM2     U$ )%Nz#{http://ns.adobe.com/f4m/1.0}pv-2.0;r   rT   z1.0z"{http://ns.adobe.com/f4m/1.0}mediaz2.0z"{http://ns.adobe.com/f4m/2.0}mediaz*{http://ns.adobe.com/f4m/1.0}bootstrapInfoz*{http://ns.adobe.com/f4m/2.0}bootstrapInfozbootstrap inforK  z%{http://ns.adobe.com/f4m/1.0}mimeTypez%{http://ns.adobe.com/f4m/2.0}mimeTypezbase URLzaudio/r  r  r  r  hrefru   r  r  r  f4m)r  r  r  ry  r*  r=  r  r  )r  r  r  r  r  m3u8mp4)r  r  r  r*  flv)r  ru   r  r  protocolr  r  r  r  r  r  )r   rs  rt  ru  Elementr  r#  r  r  rP  r	   r   rK   rL   rB  r  r-   attribr   r.   r7  r%   r  rG  r  rX  _extract_m3u8_formatsr  )r[   r  r  r   r  r  r  ry  r*  r  	akamai_pvplayer_verification_challenger  manifest_versionmedia_nodesmanifest_base_urlbootstrap_infor  	mime_typeimedia_elr  r  r  r  	media_urlr  f4m_formatsrJ  s                                r`   r   InfoExtractor._parse_f4m_formats  sR    (CII$9$9$A$ABB5I MM"GH	 SINN%:,5NN,@,@,Ea,H),224:	 &&'KL$"**+OPK -[9N(2&CEqrd, >@gh&	 --h77F$[1KAxhoo11)<=C 3 3G <=E !4!4X!>?F%fchQ7I % 	#u, ( 3 3F ;I$ ( 3 3E :I !*!5!56M!N!NI,V9K9KC9PQTRT9U0VZ]]`ii  $L1%<"&";";$:_e)9 #< #HK ;'1,'N#$55<#63%&UU7^%<u&'eeHo&?CF{);I&,"  NN;/F]NN4#=#=$* ' $> $G H NN&# , . :u!  (" c 2| rc   c           	      D    [        US5      UUSU(       a  US-
  OSUSSS.$ )Nmetar  r   imultiplezQuality selection URL)r  ru   r  r  r  r  
resolutionformat_note)r.   )r[   m3u8_urlr  r  r  r  s         r`   _m3u8_meta_formatInfoExtractor._m3u8_meta_formatb  s4    &w7.8*s*d$2	
 		
rc   c                 >    U R                  [        SU S35      SS9  g )Nz&Ignoring subtitle tracks found in the z. manifest; if any subtitle tracks are missing,Tr  )r   r!   r[   r  s     r`   _report_ignoring_subs#InfoExtractor._report_ignoring_subsn  s3    /4TF ;2 2
  	 	rc   c                 ^    U R                   " U0 UD6u  p4U(       a  U R                  S5        U$ )NHLS)#_extract_m3u8_formats_and_subtitlesr  r[   r  r  fmtssubss        r`   r  #InfoExtractor._extract_m3u8_formatst  s/    ==tNvN
&&u-rc   m3u8_nativec                    U R                  S5      (       a  Sn
U(       dA  U	SLa8  U	=(       d    Sn	U
(       a	  [        XS9eU R                  U	 [        5        35        / 0 4$ Uc  SnU	c  Sn	U R	                  XXXXS9nUSL a  / 0 4$ [
        R                  " U5         UR                  S5      nUR                  S	5      (       d<  S
nU
(       a
  [        UUS9eU R                  U [        5        3US9  / 0 4sS S S 5        $ U R                  XX(U	U
UUS9nS S S 5        WSL a  / 0 4$ U R                  UUR                  X4XVUXXUXUS9$ ! , (       d  f       N9= f)Nr  FzFailed to obtain m3u8 URLr  zDownloading m3u8 informationz#Failed to download m3u8 informationr  r)  r*  r	  r
  r  rI  s   #EXTM3UzResponse data has no m3u header)r  r)  r*  ri  r	  )r  entry_protocolr  r  r  r  r)  r*  liver	  r
  r  r   )r   r   r   r!   r1  
contextlibclosingrb  rB  r7  !_parse_m3u8_formats_and_subtitlesru   )r[   r   r   r  r  r  r  r  r  r)  r*  r  r	  r
  r  r(  ri  r/  r9  s                      r`   r	  1InfoExtractor._extract_m3u8_formats_and_subtitlesz  s    >>344Ee#!@%@(DD##wi0C0E/F$GHr6M<1D?;G((TG ) B ur6M)]]3'F$$Z007(x@@##se,?,A+B$Ch#W2v *) 00HF 1 7G * er6M55X\\s!GeT8	 6 = 	= *)s   AE E
Ec                 r
  ^ ^^^^^^^^^^^'^(^)^*^+^,^- / 0 sm)m-[         R                  " U5      m+U4S jm(T R                  SS5      (       a  S>UUUU U4S jjm'OS m'SU;   aO  T'" US9 Vs/ s H9  n[        TU5      UT=(       d    [	        UR                  5       S5      TTTTT+S	.PM;     snm)T)T-4$ 0 m*0 m,U'UUU(U)U*U+UUUUU-4S
 jnU*U,4S jnUR                  5        H#  nUR                  S5      (       d  M  U" U5        M%     UR                  5        GHS  nUR                  S5      (       a  [        U5      m,M'  UR                  S5      (       d  UR                  5       (       d  MT  [        T,R                  S5      =(       d    T,R                  S5      SS9nT(" UR                  5       5      nT'" U5       GH  nTS U/nU(       d*  U" 5       nU=(       d    SU=(       d    [        T)5      -  US'   [        U6 UUTUT[        T,R                  S5      5      TTTT+S.nT,R                  S5      =n(       a  UR                  S5      S   US'   T,R                  S5      nU(       aX  [        R                  " SU5      nU(       a:  [!        UR#                  S5      5      US'   [!        UR#                  S5      5      US'   [        R                  " SUS    5      nU(       a?  UR%                  5       u  nn[        US5      [        US5      nnUR'                  UUS!.5        [)        T,R                  S"5      5      nUR'                  U5        T,R                  S#5      nU(       aW  U(       aP  UR                  S$5      S%:w  a;  UUS&'   T*R                  U5      n U (       a  U S   R                  S'5      (       a  S%US('   UR                  S)5      (       d  UR                  S$5      S%:X  a  S*OS+US)'   T)R+                  U5        T,R                  S,5      n!U!(       d  GM]  UR-                  5       n"U"S-	 U"R'                  US.   R/                  S/S05      S1U!S2.5        T)R+                  U"5        GM     0 m,GMV     [1        S3 [3        [5        T)S4 5      S5 S69 5       5      n#[        U#5      S:  a  U#S   S7U#S8   S90OS n$[7        U#5      n%T) Hq  n&U&R9                  S&S 5      nU$(       a  U(       a  U&R                  S$5      S%:w  a  M:  U%" U5      U&S:'   [        U&R                  S;5      U$R                  U5      S<S=9U&S;'   Ms     T)T-4$ s  snf )?Nc                    > [         R                  " SU 5      (       a  U $ [        R                  R	                  TU 5      $ )N	https?://)r|   rr   r  r  rI   )ru   r   s    r`   
format_urlCInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>.format_url  s1    ((<553^6<<;O;OPXZ];^^rc   hls_split_discontinuityFc           
         > U(       d%  U (       d  / $ TR                  U TTTTSSS9nUSL a  / $ [        S[        S UR                  5        5       5      -   5      $ )NFz,Failed to download m3u8 playlist information)r*  r	  r
  r  r)  r=  c              3   B   #    U  H  oR                  S 5      v   M     g7f)z#EXT-X-DISCONTINUITYNrB  rs   lines     r`   rv   jInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>._extract_m3u8_playlist_indices.<locals>.<genexpr>  s     $oYnQU__5K%L%LYn   )r  r   sumrQ  )r  m3u8_docr	  r*  r
  r[   r   s     r`   _extract_m3u8_playlist_indicesWInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>._extract_m3u8_playlist_indices  sj    '!	#55$he$PW",Z  6  \H  5(!	Q$oYaYlYlYn$o!oopprc   c                      S /$ rq   r   )r  r  s     r`   r&  r'    s	    vrc   z#EXT-X-TARGETDURATION)r%  zapplication/x-mpegurl)r  format_indexru   r  r  r  r  has_drmc                   >^^^^	^
^ [        U 5      m
T
R                  S5      T
R                  S5      T
R                  S5      snmmU(       a  T(       a  T(       d  g TR                  T/ 5      R                  T
5        US:X  a~  T
R                  S5      (       d  g T" T
S   5      nU[	        U5      S.nUS   S:X  a
  S	US'   S
US'   T
R                  S5      =(       d    SnTR                  U/ 5      R                  U5        US;  a  g T
R                  S5      nU(       aj  T" U5      m	US:H  mT
R                  S5      S:H  =(       d    T
R                  S5      S:H  mTR                  UUUUUUUUU	U
UUU4S jT" T	5       5       5        g g )NTYPEzGROUP-IDNAME	SUBTITLESURIru   r  r  r  vttr  r  LANGUAGEund)VIDEOAUDIOr5  DEFAULTNO
AUTOSELECTc              3      >#    U  HZ  n[        TTTU5      TUT
T	TR                  S 5      TTTTTT(       a  SOST(       a	  T(       a  SOST(       a	  T(       d  TOSS.v   M\     g7f)r2  r  Nr   )r  r  r)  ru   r  languager  r  r  r  r*  r  source_preference_audio_group_id)r.   r   )rs   r  r  r  group_idr*  is_alternateis_audior  r   r  mediar  r  r  s     r`   rv   YInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>.extract_media.<locals>.<genexpr>	  sp      K" Jc! "/w$!L#'$''$, %		* 5 .",&&(0fd/7Ld3;LxVZ! " Js   A"A%)r7   r   r#  r  r%   rX  )x_media_line
media_typeru   sub_infor   r  r=  r>  r?  r  r@  r  r&  r  r  r  r  r  r*  r  r   r  r  r   s         @@@@@@r`   extract_mediaFInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>.extract_media  sz   ),7E).6):EIIj<QSXS\S\]cSd&J$8h+2259[(
 yy'' u.(- E?f, ',HUO+8HZ(yy,5$$T2.55h?!33		%(I))4%0$yy3t;^uyy?VZ^?^ K K K" <LI#K K	 rc   c                     > TR                  S5      n U (       a  U $ TR                  S5      nU(       d  g TR                  U5      nU(       d  U$ US   nUR                  S5      =(       d    U$ )Nr-  r4  r   r   )stream_namestream_group_idstream_group	renditionr  last_stream_infs       r`   build_stream_nameJInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>.build_stream_name	  sj    
 *--f5K"" .11':O"!::o6L&&$QI==(;O;rc   z#EXT-X-MEDIA:z#EXT-X-STREAM-INF:r4  zAVERAGE-BANDWIDTH	BANDWIDTH  scalez%dr=  z
FRAME-RATE)r  r)  ru   r  r  r  fpsr  r  r  r*  zYT-EXT-AUDIO-CONTENT-ID.r   r:  
RESOLUTIONz!(?P<width>\d+)[xX](?P<height>\d+)r  r  z2audio.*?(?:%3D|=)(\d+)(?:-video.*?(?:%3D|=)(\d+))?ru   )vbrr  CODECSr5  r  r  r<  r/  acodecr  m4ar  zPROGRESSIVE-URIr  r  hls-zhttp-http)r  r  ru   c              3   *   #    U  H	  oS    v   M     g7f)r<  Nr   )rs   rJ  s     r`   rv   BInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>.<genexpr>	  s!      -E LDa/@-A LD   c                 B    UR                  S5      S:g  =(       a    US   $ )Nr  r  r<  rH  r   vs     r`   r  AInfoExtractor._parse_m3u8_formats_and_subtitles.<locals>.<lambda>	  s    quuX&/H/aQO`Ma/arc   c                 j    U R                  S5      =(       d    SU R                  S5      =(       d    S4$ )Nr  r   r  rH  r.  s    r`   r  rc  	  s#    155<,1aeeGn.ABrc   keylowr  highr;  r  z, )delimr)  )r
   _has_drmr   r.   r'   rr  rQ  rB  r7   r  r+   r   rG  r  r|   r@  r  r   r  r  r4   r  r"  rQ  r2   sortedr?   r9   r   ).r[   r%  r   r  r  r  r  r  r  r  r)  r*  r	  r
  r  r   r  rE  rN  r!  r  r  r  rI  rJ  yt_audio_content_idr  r  r  rW  codecsaudio_group_idaudio_groupprogressive_urihttp_faudio_groups_by_qualityaudio_quality_mapaudio_preferencefmtr&  r  r  r  r*  rM  r   s.   ` ``````   ``` `                       @@@@@@@r`   r  /InfoExtractor._parse_m3u8_formats_and_subtitles  s!   
  ..*	_ >>3U;;	q 	q& #h. 8J	L K# +7C8 #^?8??3DF]#^*(""	 K	LG I%%4	K 4	K 4	Kl	<, '')D//d# * '')D344"7"=%%TZZ\\##''(;< 8&**;7tE  *$**,79,GC!($ 4I  &7&9'2'Rdc>QS\6R	!%2I%>(++(0"",_-@-@-NO$2&0#*#*A />.A.AB[.\\*\(;(A(A#(Fq(I*!0!4!4\!BJ!!yy)MzZ),TZZ-@)AAgJ*-djj.B*CAhK99MqQVxYD#';;=S#0d#;]3PT=US#&#&"  */*=*=h*GHFHHV$%4%8%8%AN &&QUU8_5N/=+,&,jj&@&;q>+=+=e+D+D +1AhK55<<,-EE(Ov,E55%NN1% '6&9&9:K&LO&!"">2)*;)?)?)P(.#2' 
  v.Y H\ #%s *~ #- -E6"abBLD -E #E ()A- $A&#B'
 48 	 %%<=C WW%6=N$Ncggh>OSY>Y'7'GC#$!.&(9(=(=n(MUY"[C  	!!a	Ls   )A T4c                 t    U R                  XUc  SOUUc  SOUSXVUS9nU R                  U=(       d    SU5      $ )NzDownloading m3u8 VOD manifestFailed to download VOD manifestFr  rT   )r  _parse_m3u8_vod_duration)	r[   m3u8_vod_urlr   r  r)  r	  r
  r  m3u8_vods	            r`   _extract_m3u8_vod_duration(InfoExtractor._extract_m3u8_vod_duration	  sQ     ))48L0d9@5gd5	 * B ,,X^XFFrc   c                 t    SU;  a  g [        [        S UR                  5        5       5      5      =(       d    S $ )Nz#EXT-X-ENDLISTc              3      #    U  HE  oR                  S 5      (       d  M  [        U[        S 5      S R                  S5      S   5      v   MG     g7f)z#EXTINF:Nr  r   )rB  floatrG  r  r   s     r`   rv   9InfoExtractor._parse_m3u8_vod_duration.<locals>.<genexpr>	  sG      N-1L 8E$s:'(..s3A677-s
   A0A)r  r$  rQ  )r[   r|  r   s      r`   rz  &InfoExtractor._parse_m3u8_vod_duration	  sE    8+3 N ++-N N O WRV	Wrc   c                     U R                  XUc  SOUUc  SOUSXVUS9n[        U[        R                  R                  R
                  5      (       d  g [        [        UR                  S5      5      5      $ )NzDownloading MPD VOD manifestry  Fr  mediaPresentationDuration)	_download_xmlr   rs  rt  ru  r  r-   r5   r   )	r[   mpd_urlr   r  r)  r	  r
  r  mpd_docs	            r`   _extract_mpd_vod_duration'InfoExtractor._extract_mpd_vod_duration	  st     $$37</T9@5gd5	 % B
 '399#8#8#@#@AA>'++6Q*RSTTrc   c                     U(       d  U $ / nU R                  S5       H:  nU(       a  US:X  a  UR                  U5        M#  UR                  SU SU 35        M<     SR                  U5      $ )Nr  rU  r  r  )r  r  r7  )r5  	namespaceoutcs       r`   	_xpath_nsInfoExtractor._xpath_ns	  s^    KCAS

1

R	{"QC01	 !
 xx}rc   c           	          U R                  S5      (       a  SnU R                  XX5S9nUSL a  U(       a   e/ 0 4$ Uu  pxU R                  XxR                  X$U R	                  U5      S9$ )Nr  Fr*  ry  )
f4m_paramsr  )r   _download_smil!_parse_smil_formats_and_subtitlesru   _parse_smil_namespace)	r[   smil_urlr   r*  r  ry  r  smilr8  s	            r`   #_extract_smil_formats_and_subtitles1InfoExtractor._extract_smil_formats_and_subtitles	  s|    >>344E!!(E!e%<9r6M
55dHHh@D@Z@Z[_@` 6 b 	brc   c                 ^    U R                   " U0 UD6u  p4U(       a  U R                  S5        U$ NSMIL)r  r  r
  s        r`   _extract_smil_formats#InfoExtractor._extract_smil_formats	  s/    ==tNvN
&&v.rc   c                 p    U R                  XUS9nUSL a  0 $ Uu  pgUR                  nU R                  XaX$S9$ )Nri  F)r  )r  ru   _parse_smil)r[   r  r   r*  r  r  r  r8  s           r`   _extract_smil_info InfoExtractor._extract_smil_info	  sI    !!(E!B%<I
88PPrc   c           	      &    U R                  XSSX4S9$ )NzDownloading SMIL filezUnable to download SMIL filer  )r  )r[   r  r   r*  ry  s        r`   r  InfoExtractor._download_smil	  s'    (( 7*% ) \ 	\rc   c                 j   U R                  U5      nU R                  XX5US9u  pg[        R                  R	                  [        U5      5      S   nS nS n	S n
UR                  U R                  SU5      5       H  nUR                  R                  S5      nUR                  R                  S5      nU(       a  U(       d  MI  U(       d
  US:X  a  UnMZ  U	(       d
  US;   a  Un	Mk  U
(       a  Mt  US:X  d  M|  [        U5      n
M     UR                  U R                  S	U5      5       Vs/ s Ho  oR                  S
5      (       d  M  UR                  S5      UR                  S
5      [        UR                  S5      5      [        UR                  S5      5      S.PMq     nnUU=(       d    UU	U
UUUS.$ s  snf )N)r  r  r   ./head/metar  r9  r  )r  abstractdatez.//imagesrcr  r  r  )r   ru   r  r  )r   r  r  upload_dater  r  r   )r  r  r4  r5  splitextrF   rP  r  r  r   rD   r-   )r[   r  r  r   r  r  r  r   r  r  r  r  r  r9  ra  r  s                   r`   r  InfoExtractor._parse_smil	  s   ..t4	!CCHj D R 77##L$:;A>LLy!IJD;;??6*Dkkooi0GwTW_ T-H%H% [TV^-g6 K" ||DNN:y$IJ`
 KeiiX]N^
))F#99U# 7!34!%))H"56	

 K 	 ` &h&&$"
 	
`s   %F0AF0c                 :    U R                  SUR                  SS S9$ )Nz(?i)^{([^}]+)?}smil$r  rK  )r  tag)r[   r  s     r`   r  #InfoExtractor._parse_smil_namespace
  s)    !!#TXX{D " J 	Jrc   c                 ^    U R                   " U0 UD6u  p4U(       a  U R                  S5        U$ r  )r  r  r
  s        r`   _parse_smil_formats!InfoExtractor._parse_smil_formats
  s/    ;;TLVL
&&v.rc   c                    ^ ^^ UnTR                  T R                  ST5      5       H7  nUR                  S5      =(       d    UR                  S5      n	U	(       d  M5  U	n  O   / 0 pSnSnSnSn[        5       n[        R
                  R                  UU U4S jS 5       5      nU GH  nUR                  S5      nU(       a  UU;   a  M$  UR                  U5        [        UR                  S5      =(       d    UR                  S	5      S
5      n[        UR                  S5      =(       d    UR                  S5      5      n[        UR                  S5      5      n[        UR                  S5      5      nUR                  S5      nUR                  S5      n[        US S9=(       d-    U=(       d$    [        T R                  [        U5      USSS95      nUR                  S5      =(       d    UnUS:X  d  UR                  S5      (       aT  US-  nU
R                  UUSSUc  UOU-  UUUUS.5        U(       a#  U" UU5      u  nnU
S   R!                  UUS.5        GM  UR                  S5      (       a  UO"["        R$                  R'                  U S3U5      nUR)                  5       nUS:X  d  US:X  ax  T R+                  UUU=(       d    S S!SS"9u  nnT R-                  UUS#9  [/        U5      S:X  a&  US-  nUS   R!                  S$Uc  UOU-  UUUS%.5        U
R1                  U5        GM  US&:X  aa  UnU(       d  S'S(S).nUS*U;   a  S+OS*-  nU["        R$                  R3                  U5      -  nU
R1                  T R5                  UUS,SS-95        GM  US.:X  a9  T R7                  UUS/SS09u  n n!U
R1                  U 5        T R-                  U!US#9  GM-  [8        R:                  " S1U5      (       a9  T R=                  UUS2SS39u  n"n#U
R1                  U"5        T R-                  U#US#9  GM  UR                  S5      (       d  GM  T R?                  UU5      (       d  GM  US-  nU
R                  UU=(       d    U=(       d    SS4U=(       d    U-  UUUUS5.5        GM     TR                  T R                  S6T5      5       H  nUR                  S5      nU(       a  UU;   a  M#  UR                  U5        US-  nU
R                  S7U 3U[A        UR                  S85      5      S9S9[        UR                  S5      5      [        UR                  S5      5      S:S;.5        M     T RC                  TTS<9n$T R-                  U$US#9  X4$ )=Nr  basehttpBaser   c              3   f   >#    U  H&  nTR                  TR                  UT5      5      v   M(     g 7frq   )rP  r  )rs   argr  r[   r  s     r`   rv   BInfoExtractor._parse_smil_formats_and_subtitles.<locals>.<genexpr>5
  s/      .=; LLY788;s   .1)z.//videoz.//audioz.//mediar  zsystem-bitratesystemBitraterQ  sizefileSizer  r  protor  default_extzRequesting extension infoF)r  r*  streamerrtmpr=  r  zrtmp-%d)ru   	play_pathr  r  r  r
  r  r  r  ru   r  r\  r  r  r  hlsr  r*  targetzhls-%d)r  r  r  r  r  z3.2.0zflowplayer-3.2.0.1)hdcoreplugin?&hdsr  r*  mpddashmpd_idr*  z\.ism/[Mm]anifestmss)ism_idr*  zhttp-%d)ru   r  r  r  r
  r  r  z.//imagestreamzimagestream-r  r  zSMIL storyboards)r  ru   r  rY  r  r  r  r  )r  )"rP  r  r   rg   	itertoolschainfrom_iterabler  r+   r-   r%   rH   r1  r   rB  r  r  r  r  rI   r  r	  _merge_subtitlesrG  rX  	urlencoder  "_extract_mpd_formats_and_subtitlesr|   r@  "_extract_ism_formats_and_subtitlesr  r0   _parse_smil_subtitles)%r[   r  r  r   r  r  transform_rtmp_urlr  r  br  r   
rtmp_count
http_count
m3u8_count
imgs_countsrcsr@  mediumr  r  r
  r  r  r  r  src_extr  src_urlm3u8_formats	m3u8_subsf4m_urlmpd_formatsmpd_subsism_formatsism_subs	smil_subss%   ``  `                                r`   r  /InfoExtractor._parse_smil_formats_and_subtitles%
  s\   LLy!IJD 8DHHZ$8Aq	 K  



u-- .=;.= = F**U#C#+HHSM#FJJ/?$@$_FJJD_aefG"6::f#5#OJ9OPH

7 34E H!56FJJw'E**U#C#CT: rc rEY%%k#&6Gbjo%pFrGzz*-5H("5"5f"="=a
#!$ !*GOjQX!Y" ("$	  	 &$6x$EMHcBK&&'%((   ^^F33c9M9MQUPVVWjZ]9^GmmoG'V"3*.*R*RXs|eU% +S +Q'i%%i	%B|$)!OJ O**%-wT[%\&!&"(	,  |,E!!!")"6"J #.3c96<<11*==t88(SX`e8fgE!(,(O(OXfE )P )C%X{+%%hy%A/99(,(O(OXe5 )P )B%X{+%%hy%A##F++0B0B30Q0Qa
"2'2U!*g.C!D" ("$  U h ll4>>2BI#NOF**U#C#+HHSM!OJNN+J<8#FJJv$67  $VZZ%89%fjj&:;1	 	 P$ ..ty.I	i	:!!rc   c                 "   / n0 nUR                  U R                  SU5      5       H  nUR                  S5      nU(       a  Xt;   a  M"  UR                  U5        UR                  S5      =(       d,    [	        UR                  S5      5      =(       d    [        U5      nUR                  S5      =(       d2    UR                  S5      =(       d    UR                  S5      =(       d    Un	UR                  U	/ 5      R                  UUS.5        M     U$ )	Nz.//textstreamr  r  r  systemLanguagesystemLanguageNamer   r0  )rP  r  r   r  r0   r%   r#  )
r[   r  r  subtitles_langurlsr   
textstreamr  r  r   s
             r`   r  #InfoExtractor._parse_smil_subtitles
  s    	,,t~~oy'QRJ..'C#+KK..'e<
v8N+OeS`adSeC>>"23  Hz~~FZ7[  H_i_m_mnt_u  H  zHD  r*113  S rc   c                     U R                  XSSUS9nUSL a  / $ Uu  pVUR                  nU R                  XRU[        U5      S9$ )NzDownloading xpsf playlistz Unable to download xspf manifestri  F)xspf_urlxspf_base_url)r  ru   _parse_xspfr    )r[   r  r  r*  r  xspfr8  s          r`   _extract_xspf_playlist$InfoExtractor._extract_xspf_playlist
  se    ''#>.e ( = %<I
88"8,   . 	.rc   c                    SSS.n/ nUR                  [        SU5      5       GH7  n[        U[        SU5      SUS9n[        U[        SU5      S	5      n	[        U[        S
U5      S5      n
[        [        U[        SU5      S5      S5      n/ nUR                  [        SU5      5       H  n[	        XMR
                  5      nU(       d  M!  UR                  UUUR                  [        SU5      5      [        UR                  [        SU5      5      5      [        UR                  [        SU5      5      5      S.5        M     UR                  UUU	U
UUS.5        GM:     U$ )Nzhttp://xspf.org/ns/0/z&http://static.streamone.nl/player/ns/0)r  s1z./xspf:trackList/xspf:trackz./xspf:titler  rK  z./xspf:annotationr  z./xspf:image	thumbnailz./xspf:durationr  rQ  z./xspf:locationzs1:labelzs1:widthz	s1:height)ru   r  r  r  r  )r   r  r  r  r  r  )	rP  rM   rL   r+   rI   r#  r  r   r-   )r[   xspf_docr  r  r  NS_MAPr  trackr  r  r  r  r  locationr  s                  r`   r  InfoExtractor._parse_xspf
  sd   +:

 %%m4QSY&Z[E}^V<g{\E$}%8&A=RK"}^V<kKI$5-0A6"JJWY]_H G!MM-8I6*RS$]MMB
!%$,!)mJ.O!P(mJPV6W)XY)(,,}[RX7Y*Z[  	 T NN!*&$" / \> rc   c                 ^    U R                   " U0 UD6u  p4U(       a  U R                  S5        U$ NDASH)r  r  r
  s        r`   _extract_mpd_formats"InfoExtractor._extract_mpd_formats
  s/    <<dMfM
&&v.rc   c                 H    U R                   " U0 UD6nU R                  U5      $ rq   )_extract_mpd_periods_merge_mpd_periodsr[   r  r  periodss       r`   r  0InfoExtractor._extract_mpd_formats_and_subtitles
  s(    ++T<V<&&w//rc   c
                     U R                  S5      (       a  SnU R                  XUc  SOUUc  SOUXgXS9n
U
SL a  / $ U
u  pUc  / $ UR                  n[        U5      nU R	                  XX5      $ )Nr  FzDownloading MPD manifestzFailed to download MPD manifestr  )r   r  ru   r    _parse_mpd_periods)r[   r  r   r  r  r)  r*  r	  r
  r  r  r  r8  mpd_base_urls                 r`   r  "InfoExtractor._extract_mpd_periods
  s     >>344E''/3|+9@5gG	 ( B
 %<I?I (((&&wNNrc   c                 ^    U R                   " U0 UD6u  p4U(       a  U R                  S5        U$ r  ) _parse_mpd_formats_and_subtitlesr  r
  s        r`   _parse_mpd_formats InfoExtractor._parse_mpd_formats  s/    ::DKFK
&&v.rc   c                 H    U R                   " U0 UD6nU R                  U5      $ rq   )r  r  r  s       r`   r  .InfoExtractor._parse_mpd_formats_and_subtitles  s(    ))4:6:&&w//rc   c                    0 0 p2U H  nUS    Hn  nSU;  d   S5       eSUS'   [        S UR                  5        5       5      nXb;  a  XRU'   M@  SU;   d  MH  X&   R                  S/ 5      R                  US   5        Mp     U(       a#  US   (       a  U R	                  [        S5      SS	9  US   R                  5        H&  u  pxUR                  U/ 5      R                  U5        M(     M     [        UR                  5       5      U4$ )
zy
Combine all formats and subtitles from an MPD manifest into a single list,
by concatenate streams with similar formats.
r  is_dash_periodszformat already processedTc              3   :   #    U  H  u  pUS ;  d  M  Uv   M     g7f))r  r  manifest_stream_numberNr   )rs   krb  s      r`   rv   3InfoExtractor._merge_mpd_periods.<locals>.<genexpr>  s"      #KaH?J11s   	r  r   z_Found subtitles in multiple periods in the DASH manifest; if part of the subtitles are missing,r  )rz   itemsr#  rX  r   r!   r   r  )	r[   r  r  r   periodrJ  
format_keysub_langrD  s	            r`   r   InfoExtractor._merge_mpd_periods  s   
  FI&(1M3MM1'+#$" #K #K K
,*+J' A%'22;CJJ1[>Z ' VK0##$7<% " $ #
 '-[&9&?&?&A"$$Xr299(C 'B# ( GNN$%y00rc   c              #   j  ^ ^!^-^.^/^0^1^2^3^4^5^6#    T R                  SS5      (       d  UR                  S5      S:X  a  / 0 4$ T R                  SUR                  SSS9m2U2U 4S	 jm-U-4S
 jnU-4S jn[	        UR                  S5      5      n[
        R                  " [        5      n[        UR                  T-" S5      5      5       GHf  u  pU
R                  SSU	 35      / [
        R                  " [        5      S.n[	        U
R                  S5      5      =(       d    UnU" U
SSS.5      nU
R                  T-" S5      5       GH  nU" X5      nUR                  T-" S5      5       GH  nUR                  R                  5       nUR                  UR                  5        US   nUR                  SUR                  S5      S   5      nUR                  SS5      nUS:X  a  SU0nO[        U5      nUS;  a~  US;   a  UnOuUR                  S S!5      S!:w  a  S"nO\UR                  S#S!5      S!:w  a  S$nOCUR                  SS!5      S!:w  a  S%nO*[!        U5      S&;   a  S%nOT R#                  S'U S(35        GM  SnUXU4 HY  nUR%                  T-" S)5      5      m/['        U/4S* j5      c  M,  T/R(                  U-   n[*        R,                  " S+U5      (       d  MY    O   U(       a8  UR.                  " S5      (       a!  [0        R2                  R5                  UU5      nOCU(       a<  [*        R,                  " S+U5      (       d   UR7                  S5      (       d  US-  nUU-   nUR                  S5      m3UR                  S,5      nUR%                  T-" S)5      5      n[9        Ub  UR                  R                  S-5      OS5      n[9        UR                  S.5      5      m.T3b  T3nOUnU(       a  US/-   U-   nUS0;   a  UU[!        U5      [9        UR                  S15      5      [9        UR                  S25      5      [;        T.S35      [9        UR                  S45      5      [9        UR                  S55      5      US6;  a  UOSS7U 3U[!        U5      S8-   S9.UEnO2US%:X  a  [!        U5      UUS:.nOUS;   a  US;US<[!        U5       S=3S!S!S>.nU" U5      (       d  U" U5      (       a  SWS?'   U" UU5      m4U3U44S@ jnSAT4;   a  U" SASB5      nUSCT.0-  T4SD'   SE nSFT4;  Ga(  SGT4;   Ga!  U" SGSH5      m1U" T15      m0SIT1;   a  SJT4;  az  Sn SKT4;  a:  SLT4;   a4  [;        T4SL   T4SM   5      n [<        R>                  " [;        UU SS95      T4SK'   [A        T4SN   T4SK   T4SN   -   5       V!s/ s H  n!T0T1U!T.SO.-  SU 0PM     sn!T4SP'   GOg/ T4SP'   Sm6Sm5T4SN   m!U.U0U1U4U5U!U64SQ jn"T4SJ    Hf  n#U#R                  SR5      =(       d    T6m6U#SS   m5U"" 5         T!S-  m![A        U#R                  STS5      5       H  n$T6T5-  m6U"" 5         T!S-  m!M     T6T5-  m6Mh     OSFT4;   a}  SJT4;   aw  / n%Sn&T4SM   n'T4SJ    H_  n#[;        U#SS   U'5      n([A        U#R                  STS5      S-   5       H+  n$T4SF   U&   n)U%RC                  U" U)5      U)SU(05        U&S-  n&M-     Ma     U%T4SP'   OZSFT4;   aT  / n%SLT4;   a  [;        T4SL   T4SM   5      OSn T4SF    H*  n*U" U*5      U*0n+U (       a  U U+S'   U%RC                  U+5        M,     U%T4SP'   SPT4;   a  WR                  U=(       d    UU/ US;   a  S;OSUSV.5        SDT4;   a<  T4SD   n,UR                  SW5      (       d  U,USW'   USP   RC                  U" U,5      U,05        USP   RE                  T4SP   5        U(       d  [G        T4SX [H        5      nOUWSW'   USY;   a2  UUSW      USZ'   UUSW   ==   S-  ss'   US[   RC                  U5        GM  US%:X  d  GM  US\   U=(       d    S]   RC                  U5        GM     GM     Uv   GMi     gs  sn!f 7f)^a  
Parse formats from MPD manifest.
References:
 1. MPEG-DASH Standard, ISO/IEC 23009-1:2014(E),
    http://standards.iso.org/ittf/PubliclyAvailableStandards/c065274_ISO_IEC_23009-1_2014.zip
 2. https://en.wikipedia.org/wiki/Dynamic_Adaptive_Streaming_over_HTTP
dynamic_mpdTr  dynamicz(?i)^{([^}]+)?}MPD$r  NrK  c                 (   > TR                  U T5      $ rq   )r  )r5  r  r[   s    r`   _add_ns1InfoExtractor._parse_mpd_periods.<locals>._add_ns?  s    >>$	22rc   c                 6   > U R                  T" S5      5      S L$ )NContentProtection)r  )elementr)  s    r`   is_drm_protected:InfoExtractor._parse_mpd_periods.<locals>.is_drm_protectedB  s    <<(; <=TIIrc   c                   >^
 UR                  5       m
UU
4S jnUU
4S jnU R                  T" S5      5      nUbR  U" U5        U" U5        UR                  T" S5      5      nU(       a"  U Vs/ s H  ofR                  S   PM     snT
S'   T
$ U R                  T" S5      5      nUbL  U" U5        UR	                  S5      nU(       a  UT
S'   UR	                  S5      n	U	(       a  U	T
S'   T
$ U" U5        T
$ s  snf )	Nc           	      f  > U R                  T" S5      5      nUb  UR                  T" S5      5      nU(       a  ST	S'   / T	S'   U Hu  n[        UR                  SS5      5      nT	S==   SU-   -  ss'   T	S   R	                  [        UR                  SS5      5      [        UR
                  S	   5      US
.5        Mw     U R                  S5      nU(       a  [        U5      T	S'   U R                  S5      nU(       a  [        U5      T	S'   U R                  S5      nU(       a  [        U5      T	S'   g g )NSegmentTimelineSr   total_numberr  rr=  td)r6  r7  r5  startNumberstart_number	timescaler  segment_duration)r  rP  r  r   r  r  r  )
sourcesegment_timelines_er  r5  r9  r:  r;  r)  ms_infos
           r`   extract_common[InfoExtractor._parse_mpd_periods.<locals>.extract_multisegment_info.<locals>.extract_commonK  s   #);;w7H/I#J #/*2273<@C23/')!$A #AEE#qM 2A#N3q1u<3#CL//%(sA%7%(#%7%&	1  "%  &zz-8.1,.?GN+"JJ{3	+.y>GK(#)::j#9 #278H2IG./ $rc   c                 `   > U R                  T" S5      5      nUb  UR                  S   TS'   g g )NInitialization	sourceURLinitialization_url)r  r  )r<  initializationr)  r?  s     r`   extract_InitializationcInfoExtractor._parse_mpd_periods.<locals>.extract_multisegment_info.<locals>.extract_Initializatione  s8    !'W5E-F!G!-4B4I4I+4VG01 .rc   SegmentList
SegmentURLr@  segment_urlsSegmentTemplaterF  )r"  r  rP  r  r   )r-  ms_parent_infor@  rG  segment_listsegment_urls_erV  segment_templater@  rF  r?  r)  s             @r`   extract_multisegment_infoCInfoExtractor._parse_mpd_periods.<locals>.extract_multisegment_infoE  s   $))+G
J4W
 #<<(>?L'|,&|4!-!5!5gl6K!L!Vd.eVd7~~g/FVd.eGN+ N $+<<8I0J#K #/"#34,009E+0(%5%9%9:J%KN%4B 01 N //?@N /fs   -C5r  Periodr   zperiod-)r   r  r   r  r=  )r9  r:  AdaptationSetRepresentationmimeTypecontentTyper  r   rn  rT   zapplication/x-rawccscodecrn  audior#  )
image/avif
image/jpegr  r  rn  rY  rZ  r#  )ttdfxpttmlrs  r  zUnknown MIME type z in DASH manifestBaseURLc                     > T R                   $ rq   )r#  )
base_url_es   r`   r  2InfoExtractor._parse_mpd_periods.<locals>.<lambda>  s	    JOOrc   r  r   z/{http://youtube.com/yt/2012/10/10}contentLength	bandwidth-rn  rZ  r  r  rQ  audioSamplingRate	frameRate)mulr3  zxxmiszDASH _dash)r  r  r  r  r  r  asrrT  r:  r  r
  	container)r  r  r
  mhtmlzDASH storyboards (r  )r  r  r  r  rY  r  r*  c                   > TU    nTb  UR                  ST5      nSnSnU H+  nX5-  nUS:X  a	  U(       + nM  US:X  d  M  U(       a  M'  X5-  nM-     [        R                  " SR                  SR	                  U5      5      SU5      n[        R                  " S	R                  SR	                  U5      5      S
U5      nUR                  SS5        U$ )Nz$RepresentationID$rT   FrE  %z\$({})\$|z%(\1)dz\$({})%([^$]+)\$z%(\1)\2z$$)rQ  r|   r  rP  r7  )template_nameidentifierstmplr6  in_templater  representation_idrepresentation_ms_infos         r`   prepare_template:InfoExtractor._parse_mpd_periods.<locals>.prepare_template  s    5mD,8#'<<0DFW#XD
 &+!%AFA Cx2=o!"c++ ! "& FF;#5#5chh{6K#LiYZ[FF#6#=#=chh{>S#TV`bcd		$, rc   rF  )	Bandwidthr{  rE  c                 B    [         R                  " SU 5      (       a  S$ S$ )Nr  ru   r5  )r|   rr   )r  s    r`   location_key6InfoExtractor._parse_mpd_periods.<locals>.location_key  s    (*x(H(HuTfTrc   rK  r@  )Numberr{  Timez%(Numberr  r4  r;  r:  r9  )r  r{  r  c            
      b   > TTTTS.-  n TS   R                  TU S[        TTS   5      05        g )N)r  r{  r  r  r  r:  )r  r+   )segment_urlrd  media_location_keymedia_templaterx  	segment_dsegment_numbersegment_times    r`   add_segment_url9InfoExtractor._parse_mpd_periods.<locals>.add_segment_url,  sO    .<,81:.<@" /"
 !7{ C J J$6$.iI_`kIl0mL" !#rc   r6  r7  r5  http_dash_segments)ru   r  r  r  ru   c                 ,    [        S U S    5       5      $ )Nc              3   *   #    U  H	  oS    v   M     g7f)r  Nr   )rs   frags     r`   rv   EInfoExtractor._parse_mpd_periods.<locals>.<lambda>.<locals>.<genexpr>w  s     -Z>4:.>>r_  r  )r$  )r5  s    r`   r  rc  w  s    #-Z1[>-Z*Zrc   )rn  rZ  r[  r\  r  r  r   r3  )%r   r   r  r  r5   collectionsdefaultdictr  r  rP  r   r  r"  r  r  r4   r0   r   r  rA   r#  r|   rr   rB  r  r  rI   rS  r-   r+   mathceilr   r  rX  rB   r  )7r[   r  r  r  r  r.  rQ  mpd_durationstream_numbers
period_idxr!  period_entryperiod_durationperiod_ms_infoadaptation_setadaption_set_ms_inforepresentationrepresentation_attribr  rC  	codec_strrn  r    r-  r   url_elr
  r  rJ  ry  initialization_templater}  r;  r  r  r  r   r  segment_indexr:  r  segment_urir  r  rE  r)  rd  rb  r  r  r  rw  rx  r  r  s7   `                                `           @@@@@@@@@@r`   r   InfoExtractor._parse_mpd_periods1  ss	     ~~mT22{{6"i/2v&&'=w{{Kae&f		3	J8	t &gkk2M&NO$005"+GOOGH<M,N"OJjj'=>(44T:L
 -VZZ
-CDTO6v !@ N #)..1I"J'@'`$&4&<&<WEU=V&WN,:,A,A,F,F,H))001F1FG 5j AI#8#<#<]IOO\_L`abLc#dL 5 9 9(B GI $99"*I!6!-i!8#+EE$(DD+4L#ZZ&9VC+2L#ZZ&9VC+2L#ZZ&9VC+1L))48]]+1L //2DYKO`0ab$!H$2NG#T%,\\')2D%E
#$;<H'1'AH!xxh?? % $U $(;(;C(@(@#)<<#7#7h#O%bhh|X.N.N+44S99(C/L#/(#:(=(A(A$(G%044V<D+001CDF*sy  tF6==+<+<=n+o  LP   QH +,A,E,Ek,R SI(4$5	$0	$*SL9$<	#'99)2,3#/	#:%01F1J1J71S%T&12G2K2KH2U&V#0D#A#./D/H/HI\/]#^#./D/H/H/U#V04<X0X^b-2<.+A(0)5i)@7)J % &/#/	#:,3(0
 &)EE *3#*,3-?Y@W?XXY+Z&,&, (77;KN;[;['+)-F~Wk-l*!4 (+AA2B, ,3-/ H_'b H./CDU &-CCSiHi)9'Cb)c-9.-I* &7CG]<]/3,-5KKPbf|P|3@AWXjAk  nD  EP  nQ  4R 0IMS`ap  sC  MN  TO  JP 6~ F 5: 6~ F 6~ FI_`nIo o5qCr5q. !3N.<1:F" 5" !+,<D5qCr2;? CE2;?+,L(,I-CN-SN	# 	# &<C%@/0uuSz/I\,-cF	 / 1 .! 3).quuS!})=A$0I$=L$3$5$2a$7N *> !-	 9 &A (+AAcMcFc %'	()$:;$G	!7!<A'4QsVY'GH%*155a=1+<%=.D^.TUb.c ) 0 0$0$={$.2" !# !. 2 &> "= ?H.{;'+AA %'	 EWZpDp ,923EF2;?,Avz ) ,B.+QK ,[ 9;(H  07G 4%,,X6 ,R ?H.{;
 #&<<#*#6h19)+3<@\3\bv"  03II1GH\1].#$55<<+=%kN11<@R3SUg2hi+--.D[.QR..5 6 Z\a/cO
 $,%#'UU6DQuX6N23&qx0A50$Y/66q9%/$[1$-%@GGJe 'X #Kj A #PtCrs&   J`3#)`3J?`3`.
%I`3:9`3c                 ^    U R                   " U0 UD6u  p4U(       a  U R                  S5        U$ )NISM)r  r  r
  s        r`   _extract_ism_formats"InfoExtractor._extract_ism_formats  s/    <<dMfM
&&u-rc   c
                     U R                  S5      (       a  SnU R                  XUc  SOUUc  SOUXgXS9n
U
SL a  / 0 4$ U
u  pUc  / 0 4$ U R                  XR                  U5      $ )Nr  FzDownloading ISM manifestzFailed to download ISM manifestr  )r   r   _parse_ism_formats_and_subtitlesru   )r[   ism_urlr   r  r  r)  r*  r	  r
  r  r  ism_docr8  s                r`   r  0InfoExtractor._extract_ism_formats_and_subtitles  s    >>344E''/3|+9@5gG	 ( B
 %<r6M?r6M44WhhOOrc   c                 	   UR                  S5      S:X  a  / 0 4$ [        UR                  S   5      n[        UR                  S5      5      =(       d    Sn/ n0 nUR	                  S5       GHz  nUR                  S5      n	U	S;  a  M  UR                  S	   n
[        UR                  S5      5      =(       d    UnUR                  S
5      nUR                  S5      =(       d    Sn[        U5      S:w  a  [        R                  " U5      =(       d    SnUR	                  S5       GH  nSSS.nUR                  S5      =(       d     UR                  UR                  S5      5      nUS;  a  U R                  U S35        M]  [        UR                  S   5      S-  n[        UR                  S5      =(       d    UR                  S5      5      n[        UR                  S5      =(       d    UR                  S5      5      n[        UR                  S5      5      n[        R                  " SUR                  S   U
5      n[        R                  R                  UU5      n/ nSS0nUR	                  S 5      n[        U5       GH  u  nn[        UR                  S!5      5      =(       d    US   US'   [        UR                  S"5      5      =(       d    S#n[        UR                  S$5      5      US%'   US%   (       d-   [        UUS#-      R                  S!   5      nUUS   -
  U-  US%'   [!        U5       HO  nUR#                  [        R                  " S&[%        US   5      U5      US%   U-  S'.5        US==   US%   -  ss'   MQ     GM     U	S(:X  aA  UR'                  U/ 5      R#                  S)S*UUUU	UUUUUR                  S+5      S,.S-.5        GM  U	S.;   d  GM  UR#                  0 S/[)        X<U5      _S0U_S1U_S2U	S3:X  a  S4OS5_S6U_S7U_S8U_S9U_S:U	S;:X  a  S<OU_S=U	S3:X  a  S<OU_S>S*_S?U_S@UR+                  SA5      SBL_SCU_SD[        UR                  SE5      5      _SFU	UUU=(       d    SU=(       d    SUUUR                  S+5      U[        UR                  SESG5      5      [        UR                  SHSI5      5      [        UR                  SJSK5      5      SL._5        GM     GM}     Xg4$ ! [         a    Un GNf = f)Mz
Parse formats from ISM manifest.
References:
 1. [MS-SSTR]: Smooth Streaming Protocol,
    https://msdn.microsoft.com/en-us/library/ff469518.aspx
IsLiveTRUEDuration	TimeScalei StreamIndexTyperY  UrlNameLanguager3  r*  QualityLevelAACLEC-3)25565534FourCCAudioTag)H264AVC1r  TTMLr  z is not a supported codecBitraterQ  MaxWidthWidth	MaxHeightHeightSamplingRatez{[Bb]itrate}r  r   r  r6  r5  r=  r7  r  z{start[ _]time})ru   r  r#  ismtismCodecPrivateData)stream_typer  r:  fourccr:  codec_private_data)r  r  ru   r  r  _download_paramsrf  r  ru   r  r  rn  ismvismar  r  r  rm  r  rZ  r  rY  r  r  r*  
ProtectionNr:  audio_channelsChannelsr  r   BitsPerSample   NALUnitLengthFieldrD  )r  r  r:  r  r  r  r:  r  sampling_ratechannelsbits_per_samplenal_unit_length_field)r   r  r  r-   rP  rG  r   
short2longr   r|   r  r  r  rI   r  r   r   r  r!  r#  r.   r  )r[   r  r  r  r  r:  r  r   streamr  url_patternstream_timescalerI  stream_languager  
KNOWN_TAGSr  r  r  r  r  track_url_patternr  fragment_ctxstream_fragmentsstream_fragment_indexstream_fragmentfragment_repeatnext_fragment_timer   s                                 r`   r  .InfoExtractor._parse_ism_formats_and_subtitles  s:    ;;x F*r6Mw~~j12K 89EX		oom4F **V,K"<< --.K*6::k+BCPy **V,K %jj4=O?#q("-"8"8"I"RU7%+f=
8,U
uyy?T0U!II''6(2K(LM%,,y12d: $EIIj$9$OUYYw=OP$UYY{%;%Ruyy?RS +EIIn,E F$&FF?ELL<SU`$a!$*LL$8$8BS$T!	A  $*>>##6 >GHX>Y:)?+67J7J37O+P+hT`agThL(&1/2E2Ec2J&K&PqO/:?;N;Ns;S/TL,'
3:14_EZ]^E^5_5f5fgj5k1l. 5GV\I]4]ap3pZ0"?3!((#%66*<c,vBV>WYj#k(4Z(@CS(S*  %V,Z0HH, 4 ?Z" &((("=DD%$)&(/%.+6(0)9&,(727))<N2O-F  !$66NN $#]6%L$w$ '$ )?vV	$
  $ !&$ s$ }$ !K7,B&$ !K7,B&$ #E$ $Y$ "7<<#=T#I$ #O$ )+eii
6K*L$  ++6(0)9%*Za&,k&,(727))<N2O-:(3EIIj!4L(M/:599_VX;Y/Z5@K_abAc5d-!$ s 8 5H !!u  * :19.:s   ;S,,S<	;S<	c
           
        ^ ^^^^^^^^	^& U4S jm&S n
S#U	U&UUUUUU U4	S jjn/ nSn[         R                  " SU S3U5       VVVs/ s H  u  pnXUS4PM     nnnnUR                  [         R                  " SU S	3U5      5        U GH  u  nnnn/ 0 S
.n[        U5      n[	        [        US5      5      nU(       a8  U
" UR                  S5      5      nU" UUU5      u  nnUS   R                  U5        T&" UR                  S5      5      US'   U(       Ga  [         R                  " SU5       GH  n[        U5      n[	        [        US5      5      nU(       d  M-  U
" UR                  S5      5      nU" UUU5      u  nnU(       Ga}  S Vs/ s H5  n[        UR                  U5      5      (       d  M$  UR                  U5      PM7     nn[        UR                  S5      5      n[        UR                  S5      5      =(       d    [        UR                  S5      5      nU(       a  U(       dQ  U HK  n[        U5      n U (       d  M  U=(       d    U R                  S5      nU=(       d    U R                  S5      nMM     U H  n[        U5      n!U!(       d  M    O   S n!UR                  UUU!UR                  S5      =(       d    UR                  S5      S.5        UR                  US   5        US   R                  U5        GM  US   R                  U5        GM     [         R                  " SU5       H  n"[        U"5      n#U#R                  S5      n$U$(       a  U$S;   d  M.  [	        U#R                  S5      5      nU(       d  MQ  U#R                  S5      =(       d)    U#R                  S5      =(       d    U#R                  S5      n%US   R                  U%/ 5      R                  S T&" U5      05        M     US    H5  nTUR                  S!0 5      S"'   T	(       d  M!  US!   R                  T	5        M7     US   (       d  US   (       d  GM  UR                  U5        GM     U$ s  snnnf s  snf )$Nc                    > [        TU 5      $ rq   )rI   )item_urlr    s    r`   absolute_url>InfoExtractor._parse_html5_media_entries.<locals>.absolute_url  s    8X..rc   c                     U (       d  0 $ [         R                  " SU 5      nU(       a-  UR                  5       u  p#[        U5      n[	        U5      US'   U$ 0 $ )Nz<(?P<mimetype>[^/]+/[^;]+)(?:;\s*codecs="?(?P<codecs>[^"]+))?r  )r|   r@  r  r4   r0   )rC  ctrmimetypern  rJ  s        r`   parse_content_typeDInfoExtractor._parse_html5_media_entries.<locals>.parse_content_type  sO    	))[]ijC#&::<  ('1%Irc   c                   >	 U=(       d    0 nT" U 5      nUR                  S5      =(       d    [        U5      nUS:X  a  SnTR                  UTST	T
TTSTS9	nXV4$ US:X  a  SnTR                  UTTSTS9nXV4$ SnUUS	:X  a  S
OS US./nXV4$ )Nr  r  Fr  )r  r  r  r  r  r*  r
  r  )r  r*  r
  TrZ  r  ru   r  r  )r   r%   r  r  )r  cur_media_type	type_infofull_urlr  is_plain_urlr  _headersr  m3u8_entry_protocolr  r  r  r  r[   r   s          r`   _media_formats@InfoExtractor._parse_html5_media_entries.<locals>._media_formats  s    !RI#C(H--&A-*ACf}$44hE#6)7%QY 5 [  (( $33hvUH 4 V  ((  $#(6'(Aft 
  ((rc   z((?:(?:amp|dl8(?:-live)?)-)?(video|audio)z(?s)(<(z	)[^>]*/>)rT   z(?s)(<(?P<tag>z )(?:\s+[^>]*)?>)(.*?)</(?P=tag)>)r  r   )r  zdata-video-srczdata-srczdata-sourcer  r  posterr  z<source[^>]+>)labelr  r  r  r  r  r  )r  r  r  r  r   z<track[^>]+>kind)r   captionsr  srclangr   r   ru   http_headersRefererrq   )r|   rP  rX  r(   r>   r&   r   r<   r-   r8   r3   r  r  r#  )'r[   r    r  r   r  r  r  r  r  r  r  r  r  _MEDIA_TAG_NAME_RE	media_tagmedia_tag_namerC  
media_tagsr   media_content
media_infomedia_attributesr  rJ  r  
source_tags_attrr  lbllabelsr  r  r  r  	track_tagtrack_attributesr  r   r  s'   `` ```````                            @r`   _parse_html5_media_entries(InfoExtractor._parse_html5_media_entries  s.   	/			) 	). 
 I w/A.B)$LgVXV @)Z !*bAV 	 X 	"**
 011QRT[] 	^ 8B3Iq*mJ  2)<)9;o pqC&'7';';F'CD+CQ?
79%,,W5&23C3G3G3Q&RJ{#"$**-=}"MJ/
;F (9m(noC *6::f+=>A,:3
A,N)L'#
 (:"'9*6::c?; ,FJJsO'9  "
 !,FJJw,? @"-fjj.B"C #D%0E1B%C $F'--=c-B
'1$,(-(H1H)/)K:>>(3K (. $*C"/"4C"s % $*
 #'C%*&,#&)/G)<)S

7@S	"  ,"9-44Q7"9-44W=U #NV "$O]!KI'9)'D$+//7D4+D#D+,<,@,@,GH"$/33I>BRBVBVW]B^brbvbvw~b";/::4DKK!<#4M  "L  	*>F^R0;8n%,,X6 + )$
;(?(?z*Q 8BR eXD"s   Q$#Q+3Q+c                 ^    U R                   " U0 UD6u  p4U(       a  U R                  S5        U$ )Nakamai)%_extract_akamai_formats_and_subtitlesr  r
  s        r`   _extract_akamai_formats%InfoExtractor._extract_akamai_formats  s/    ??PP
&&x0rc   c                 *   SU;   nU(       d'  [         R                  " SSU5      R                  S5      n/ n0 nSn[         R                  " SSU5      R                  SS	5      nUR	                  S
5      n	U	(       a  [         R                  " SSU	-   U5      nSU;  a  USU;   a  SOSU-   -  nU R                  XS
SS9n
U
 H  nUR                  SU05        M     UR                  U
5        [         R                  " SSU5      R                  S	S5      nUR	                  S5      nU(       a  [         R                  " SSU-   U5      nU R                  XSSSSS9u  pUR                  U5        U R                  Xo5      nUR	                  S5      nU(       a  U(       a  U(       d  Sn[         R                  " UU5      R                  S5      R                  S5      n[        U5      n[        U5      UUS-   4;   a  SnU H  nUS   S:w  d  M  S  Hz  nUR                  5       nUS!	 [         R                  " UUS"U S#UU    S$3-   US%   5      nUR                  US&   R                  S'US(-   5      UUS).5        UR                  U5        M|     US-  nM     XV4$ )*Nzhdnea=z2(?:b=[\d,-]+|(?:__a__|attributes)=off|__b__=\d+)&?rT   r  zhdcore=3.7.0z(https?://[^/]+)/i/z\1/z/z/master.m3u8z/manifest.f4mr  z(https?://)[^/]+z\1zhdcore=r  Fr  extra_param_to_segment_urlz(https?://[^/]+)/z/z\1/i/r  r  r  r  r\  z2https?://[^/]+/i/([^,]+),([^/]+),([^/]+)\.csmil/.+r   r  r=  r   r  r  )r\  httpsr  z://z/\g<1>z\3ru   r  r[  re  )r  ru   r  )r|   r  r  rQ  r   r  r  rX  r	  r  rr   r   r  rG  r"  r  )r[   r  r   hostssignedr  r   hdcore_signr  hds_hostr  entryr   hls_hostr  m3u8_subtitles	http_host
REPL_REGEXr9   qualities_lengthr  rJ  r  rr  http_urls                            r`   r  3InfoExtractor._extract_akamai_formats_and_subtitles  s   \)66EL""'%*  	$&&/<HPPQ_apq99U#ff0%(2BGLGG#sg~3+EEG//e5 0 : ELL6DE !{#660(LIQQRacqr99U#vv1583CXNH'+'O'O} (P (($ 	|$)))D	IIf%	fNJX6<<Q?EEcJI"9~< %57G!7K$LL%A{f,(9H%&VVXF &~ 6')vv *H#i[yYZ|n\^7_,_abchai(kH"MM-3K-@-H-HQY\_Q_-`'/,4+ 
 $NN62 ): Q & !!rc   c                 .  ^^ [         R                  R                  U5      R                  m[        R
                  " SSU5      n[        R                  " SU5      nUR                  S5      nSR                  SUR                  S5      =(       d    SU5      m/ nUU4S jnS	U;  a)  UR                  U R                  U" S
5      USUSSS95        SU;  a'  UR                  U R                  U" S5      USSS95        SU;  a'  UR                  U R                  U" S5      USSS95        [        R                  " SU5      (       a  SU;  a  U R                  U" S5      USS9n	U	 H  n
U
R                  5       nSR                  U
S   U
S   5      US'   US	 US	 UR                  US   R!                  SS5      U
S   R!                  S S!5      S!S".5        UR                  X/5        M     U$ S# H$  nX;  d  M
  UR#                  U S$U 3UUS".5        M&     U$ )%Nz6/(?:manifest|playlist|jwplayer)\.(?:m3u8|f4m|mpd|smil)rT   z1(?:(?:http|rtmp|rtsp)(?P<s>s)?:)?(?P<url>//[^?]+)ru   z{}{}:{}r\  r  c                 4   > T SU  3nT(       a  UST 3-  nU$ )Nr  r  r   )r  m_urlhttp_base_urlr  s     r`   r  :InfoExtractor._extract_wowza_formats.<locals>.manifest_url  s+    $oQxj1E1UG$Lrc   r  zplaylist.m3u8r  r  Fr  r  zmanifest.f4mr  r  r  zmanifest.mpdr  z(?:/smil:|\.smil)r  zjwplayer.smilri  z{}/{}r  r  zrtmp://zrtsp://r  r  rtsp)ru   r  r  )r  r*  rN  )r  r  urlparser  r|   r  r@  r   rP  rX  r  r  r  r  r"  r  rQ  r  )r[   ru   r   r  skip_protocolsr  url_baser  r  rtmp_formatsrtmp_formatrtsp_formatr  r(  r  s                @@r`   _extract_wowza_formats$InfoExtractor._extract_wowza_formats  sH   %%c*00ffNPRTWXyy@#G::e$!((C1FBQ	 'NN455_-x#U% 6 A B &NN444^,e 5 5 6 'NN444^,u 5 6 7 99)844^+#99 1E  :  + $0K"-"2"2"4K)0E8JKXcLd)eK&#K0#E*&&*5199)YO%0%=%E%Eff%U$*( 
 NNK#=> $0&  -1NN"*1XJ7%-$,$  - rc   c                 .    U R                  SUSUSSUS S9$ )Nzy(?<!-)\bjwplayer\s*\(\s*(?P<q>'|")(?!(?P=q)).+(?P=q)\s*\)(?:(?!</script>).)*?\.\s*(?:setup\s*\(|(?P<load>load)\s*\(\s*\[)zJWPlayer dataz)\{(?s:.*)}(?(load)(?:\s*,\s*\{(?s:.*)})*)z(?(load)\]|\)))r  r  ry  rL  )r  )r[   r  r   ry  s       r`   _find_jwplayer_data!InfoExtractor._find_jwplayer_data  s2       M_hIWh-t ! = 	=rc   ry  c                N    U R                  XUS9nU R                  " Xb/UQ70 UD6$ )Nr6  )r4  _parse_jwplayer_data)r[   r  r   ry  r  r  jwplayer_datas          r`   _extract_jwplayer_data$InfoExtractor._extract_jwplayer_data  sD    000@ 1 B((6&*6.46 	6rc   c                    / n[        U[        5      (       d  U$ UR                  S5      n	[        U	[        5      (       d  U	=(       d    U4n	U	 GH  n
[        U
[        5      (       d  M  SU
;  a  U
/U
S'   U=(       d    U
S   nU R	                  U
S   XXVUS9n0 n[        U
SS 45       Hp  n[        X~R                  S5      5      nU(       d  M&  UR                  UR                  S5      =(       d    S	/ 5      R                  S
U R                  U5      05        Mr     U[        U(       a  U
S   OU
R                  S5      5      [        U
R                  S5      5      [        XpR                  U
R                  S5      5      5      [        U
R                  S5      5      [        UR                  S5      =(       d    U
R                  S5      5      U[        U
R                  S5      5      [        U
R                  S5      5      [        [        U
S5      5      [        U
R                  S5      5      [        U
R                  S5      5      [        U
R                  S5      5      [        U
R                  S5      5      S.n[        U5      S:X  a=  [         R"                  " SUS   S
   5      (       a  UR%                  SUS   S
   S.5        OUUS'   UR                  U5        GM     [        U5      S:X  a  US   $ U R'                  U5      $ )Nr  sourcesmediaid)r   r  r  rtmp_paramsr    tracksc                 .    US   R                  5       S;   $ )Nr  )r  r   )r  ra  s     r`   r  4InfoExtractor._parse_jwplayer_data.<locals>.<lambda>/  s    1V9??+<@Y+Yrc   filer  enru   r  r  ra  pubdater  subtitlegenre)categorychannelr%  r  releasedateage_restriction)r   r  r  r  r  r  r   	alt_titlerG  rI  r&  r  release_yearr  r=  z+^(?:http|//).*(?:youtube\.com|youtu\.be)/.+r   r  r  r  )r   r  r   r   _parse_jwplayer_formatsr?   rI   r#  r  r  rC   r#   r-   r+   r&   rG  r|   r@  r  r  )r[   r9  r   require_titler  r  r?  r    r  playlist_items
video_datathis_video_idr  r   r  	track_urlr  s                    r`   r8  "InfoExtractor._parse_jwplayer_data  s   -..N&**:6 .$//,=@N(Jj$// 
*)3
9%$=
9(=M229% 3 KG I%jY3[ \#Hii.?@	 $$UYYw%7%?4DKK433I>M \ $%]j&9PZP^P^_fPgh)*..*GH$X/G/G
W^H_/`a(	)BC)-*;*;J*G*e:>>ZdKef&'
z(BC#JNN7$;<%hz;R&ST!,Z^^H-E!F"-jnnY.G"H +JNN=,I J(8I)JKE" 7|q RYY/]_fgh_ijo_p%q%q."1:e, 
 $+i NN5!a )b w<11:''00rc   c                 6   [        5       n/ nU GH  n	[        U	[        5      (       d  M  [        X`R	                  U	R                  S5      5      5      n
U
(       a  X;   a  MR  UR                  U
5        U	R                  S5      =(       d    Sn[        U
[        U5      S9nUS:X  d  US:X  d  SU
;   a$  UR                  U R                  XSS	US
S95        M  US:X  d  US:X  d  SU
;   a"  UR                  U R                  XUS
S95        M  US:X  a"  UR                  U R                  XS
S95        GM"  UR                  S5      (       d  US;   a  UR                  U
SUS.5        GMV  [        U	R                  S5      5      n[!        U	R                  S5      5      nUc!  U(       a  [#        U5      R                  S5      nU
[!        U	R                  S5      5      U[!        U	R                  S5      SS9[!        U	R                  S5      5      UUS.nU
R                  S5      (       a_  SUS '   [$        R&                  " S!U
S"S#9n[)        U5      S$:X  a  Uu  nnnUR+                  UUU-   S%.5        U(       a  UR+                  U5        UR                  U5        GM     U$ )&NrC  r  rT   r  r  r  zformat=m3u8-aaplr  r  F)r  r  r*  r  r  zformat=mpd-time-csfr  r  ri  rZ  )ogaaacmp3mpegvorbisr  r  r  r  r  r  rQ  rR  r
  )ru   r  r  r  r
  r  r  r  r  r  z((?:mp4|mp3|flv):)r=  )maxsplitr*  r  )rg   r   r  rI   r  r   r  r%   r0   rX  r  r  r  rB  r  r<   r-   r8   r|   r  rG  r  )r[   jwplayer_sources_datar   r  r  r?  r    r  r  r<  
source_urlsource_typer  r  r  a_formatrtmp_url_partsrtmp_urlri  r  s                       r`   rN  %InfoExtractor._parse_jwplayer_formatsU  s   u+Ffd++ 226::f3EFHJ!3HHZ  **V,2K
[8QRCe#sf}8Jj8Xt99%#5  :  2 3 &#,:OS]:]t88u  9  F Gt99  :  7 8 ''00C <; 5;%$   (

7(;<	$VZZ%9:>i .i8<<XFF%(G)<=$&vzz)'<DI +FJJz,B C!* ((00&+HUO &(XX-zA&GN>*a/6D3&) #+)/));)  # 4x(u ,v rc   c                 <    U R                   R                  S5        U$ )NzLyt_dlp.InfoExtractor._live_title is deprecated and does not work as expectedr  r  s     r`   _live_titleInfoExtractor._live_title  s    ,,-{|rc   c                 |    [        U40 UD6nUc,  SU SU< 3nU(       a  [        U5      eU R                  U5        U$ NzFailed to extract z: Could not parse value )r-   r   r   r[   rb  r  r*  r  r  r/  s          r`   _intInfoExtractor._int  sJ    !&v&;&tf,DQEJC$S))##C(
rc   c                 |    [        U40 UD6nUc,  SU SU< 3nU(       a  [        U5      eU R                  U5        U$ rg  )r+   r   r   rh  s          r`   _floatInfoExtractor._float  sJ    A((;&tf,DQEJC$S))##C(
rc   r  c
                     [         R                  R                  SX#XUS LUSUR                  S5      USXtUS S U	5      nU R                  R	                  U5        g )Nr   TrU  )r\  r   CookierB  
set_cookie)r[   domainr  r}  expire_timeportr5  ro  discardrestr  cookies               r`   _set_cookieInfoExtractor._set_cookie  sW    &&tDd"2FDc"D$T4' 	!!&)rc   c                 ^    [        U R                  R                  R                  U5      5      $ )z@Return a http.cookies.SimpleCookie with the cookies for the url )r   r   r   get_cookie_headerr   s     r`   _get_cookiesInfoExtractor._get_cookies  s%    "4#3#3#=#=#O#OPS#TUUrc   c                 D   UR                   R                  5        H  u  p4UR                  5       S:w  a  M  UR                  S5      R	                  S5      n[
        R                  " U S3U5      nU(       d  M^  UR                  5       u  pgU R                  XrU5          g   g)a  
Apply first Set-Cookie header instead of the last. Experimental.

Some sites (e.g. [1-3]) may serve two cookies under the same name
in Set-Cookie header and expect the first (old) one to be set rather
than second (new). However, as of RFC6265 the newer one cookie
should be set into cookie store what actually happens.
We will workaround this issue by resetting the cookie to
the first one manually.
1. https://new.vk.com/
2. https://github.com/ytdl-org/youtube-dl/issues/9841#issuecomment-227871201
3. https://learning.oreilly.com/
z
set-cookiez
iso-8859-1r?  z%=(.+?);.*?\b[Dd]omain=(.+?)(?:[,;]|$)N)	r
  r   r  rr  rA  r|   r@  r  rw  )r[   
url_handlerv  headerrW   cookie_valuer}  rq  s           r`   _apply_first_set_cookie_header,InfoExtractor._apply_first_set_cookie_header  s      *11779OF||~-nn\299'BG998@A7LL| , 3 3 5  7  :rc   c              #     #    [        U 5      R                  S5      nU(       a-  [        U S5      (       a   U R                  5        S35       eU/nO[        U 5      R                  S/ 5      nU H:  nU(       d  UR                  SS5      (       a  M#  U R                  5       US'   Uv   M<     [	        U SS 5      (       a$  U R
                  R                  U5       S h  vN   g g  N7f)N_TEST_TESTSzIE has _TEST and _TESTSonly_matchingFr  __wrapped__)rc  r   hasattrr   r  r  get_testcases)r   include_onlymatchingr6  testss       r`   r  InfoExtractor.get_testcases  s      IMM'"sH--W#**,?V/WW-CEIMM(B/EA'AEE/5,I,I

AfIG	 
 3t,,445IJJJ -Js   CC%C#C%c              #      #    [        U 5      R                  S/ 5      nU H  nU R                  5       US'   Uv   M     [        U SS 5      (       a#  U R                  R                  5        S h  vN   g g  N7f)N_WEBPAGE_TESTSr  r  )rc  r   r   r  r  get_webpage_testcases)r   r  r6  s      r`   r  #InfoExtractor.get_webpage_testcases  sg     S	.3A

AfIG  3t,,<<>>> ->s   A+A6-A4.A6c           	          [        [        / U R                  SS9QU R                  5       Q7S5      =(       d    S/5      $ )z Get age limit from the testcasesFr  ).))r  r   N	info_dictr  r   )r  r?   r  r  r   s    r`   r  InfoExtractor.age_limit  sM     <ZcU;Zc>W>W>YZDF MJKN 	Nrc   c                     [        U R                  SS95      nU(       d  g[        S U 5       5      (       d  g[        S U 5       5      (       a  gg)	zIWhat the extractor returns: "video", "playlist", "any", or None (Unknown)Fr  Nc              3   T   #    U  H  o  H  o"R                  S 5      v   M     M      g7fr  Nr  )rs   testr  s      r`   rv   -InfoExtractor._RETURN_TYPE.<locals>.<genexpr>  s#     N%$A\\*---%s   &(rn  c              3   F   #    U  H  n[        S  U 5       5      v   M     g7f)c              3   B   #    U  H  oR                  S 5      v   M     g7fr  r  )rs   r  s     r`   rv   7InfoExtractor._RETURN_TYPE.<locals>.<genexpr>.<genexpr>  s     <t!\\*--tr#  N)rU   )rs   r  s     r`   rv   r    s     O<t<<<s   !r  rU   )rz   r  rU   all)r   r  s     r`   _RETURN_TYPEInfoExtractor._RETURN_TYPE  sM     c''U'CDN%NNNOOOOrc   c                 l    U R                  U5      (       a  SSS.R                  U R                  5      $ g)z=Returns whether the URL is of a single video, None if unknownTF)rn  r  N)r   r   r  r   s     r`   is_single_videoInfoExtractor.is_single_video   s4     <<!u599#:J:JKK rc   c                 8    [        U R                  U5      (       + $ )zHTest whether the extractor is generally suitable for the given age limit)r   r  )r   r  s     r`   is_suitableInfoExtractor.is_suitable  s     "#--;;;rc   )markdownsearch_examplesc                   SnU R                   (       a.  U(       a  USU R                    S3-  nOUSU R                    S3-  nU R                  SL a  US-  nO#U R                  (       a  USU R                   3-  nU R                  (       ap  X0R                  (       a  S	OS S
U R                   S3-  nU(       aB  SnUSU R                   [        R                  " U5       S[        R                  " U5       S3-  nU R                  5       (       d  X1(       a  SOS-  nU(       a1  SR                  [        R                  " SSU R                  5      5      OU R                  nU(       a  U SU 3$ U$ )zDescription of the extractorrT   z [*z*](## "netrc machine")z [rO  Fz	 [HIDDEN]rN  r  z "z	:" prefix)rT   510r  z (e.g. "rN  z")z (**Currently broken**)z (Currently broken)z	 - **{}**z:(\w+:)u	   :​\g<1>)
rY   r   
SEARCH_KEYr   r   r   rP  r|   r  r   )r   r  r  desc_COUNTSr  s         r`   r  InfoExtractor.description  sI    #c0011GHH"S//022;;%KD[[a}%%D>>kksr2"S^^4DINND0(3>>"26==3I2J!FMMZiLjKkkmnn{{}}-?TTD Zb""266*os{{#STgjgrgr#'$q1T1rc   c                     U R                  SS5      (       d  U R                  S5      (       a  U R                  " U0 UD6$ 0 $ )NwritesubtitlesFlistsubtitles)r   _get_subtitlesr[   r  r  s      r`   extract_subtitlesInfoExtractor.extract_subtitles$  s>    NN+U33>>/22&&777	rc   c                     [        S5      eNr   r   r  s      r`   r  InfoExtractor._get_subtitles*      !"QRRrc   c                       \ rS rSrSrSrg)InfoExtractor.CommentsDisabledi-  z=Raise in _get_comments if comments are disabled for the videor   N)r   r  r  r  r  r  r   rc   r`   CommentsDisabledr  -  s    Krc   r  c                 j   ^ ^ T R                  S5      (       d  g T R                  " U0 UD6mUU 4S jnU$ )Ngetcommentsc                    > / n Sn  U R                  [        T5      5        M  ! [         a    Sn Ox[         a    TR	                  S5         O\TR
                   a    S S S.s $ [         a:  nTR                  S5      SLa  e TR                  R                  U5         S nAOS nAff = f[        U 5      nTR	                  SU S35        U U(       a  S S.$ US.$ )NTFzInterrupted by user)r   comment_countignoreerrorsz
Extracted z	 comments)r  r~   r   KeyboardInterruptr   r  	Exceptionr   r   report_errorrG  )r   interruptedr   r  	generatorr[   s       r`   	extractor1InfoExtractor.extract_comments.<locals>.extractor5  s    HK1OODO4   $#$ 645(( A$(4@@ 1>>.1=  --a001  MMNNZi@A$)4 :G s&   $ B'B'B'$	B'-0B""B')r   _get_comments)r[   r  r  r  r  s   `   @r`   extract_commentsInfoExtractor.extract_comments0  s7    ~~m,,&&77		, rc   c                     [        S5      er  r   r  s      r`   r  InfoExtractor._get_commentsM  r  rc   c                    ^ U  Vs1 s H$  o"R                  S5      UR                  S5      4iM&     snm[        U 5      nUR                  U4S jU 5       5        U$ s  snf )zXMerge subtitle items for one language. Items with duplicated URLs/data
will be dropped. ru   r	  c              3   v   >#    U  H.  oR                  S 5      UR                  S5      4T;  d  M*  Uv   M0     g7f)ru   r	  NrH  )rs   r  
list1_datas     r`   rv   6InfoExtractor._merge_subtitle_items.<locals>.<genexpr>V  s0     lNDxxQWHX6Yak6k44Ns   )9	9)r   r   rX  )subtitle_list1subtitle_list2r  r;  r  s       @r`   _merge_subtitle_items#InfoExtractor._merge_subtitle_itemsP  sV     GUUndxx(89nU
>"

lNll
 Vs   +Ar  c                    Uc  0 n[        SU5       H@  nUR                  5        H)  u  pEU R                  UR                  U/ 5      U5      X'   M+     MB     U$ )z3Merge subtitle dictionaries, language by language. N)r   r   r  r   )r   r  dictsr7  r   r  s         r`   r  InfoExtractor._merge_subtitlesY  sW     >Fe$Aggi
"88D"9MtT ( % rc   c                     U R                  SS5      (       d  U R                  S5      (       a  U R                  " U0 UD6$ 0 $ )NwriteautomaticsubFr  )r   _get_automatic_captionsr  s      r`   extract_automatic_captions(InfoExtractor.extract_automatic_captionsc  s>    NN.66>>/22//@@@	rc   c                     [        S5      er  r   r  s      r`   r  %InfoExtractor._get_automatic_captionsi  r  rc   c                 \    U R                  S5      SL=(       d    U R                  S5      SL$ )z-Whether cookies have been passed to YoutubeDL
cookiefileNcookiesfrombrowserr  r   s    r`   _cookies_passedInfoExtractor._cookies_passedl  s-     ~~l+47k4>>J^;_gk;kkrc   c                     U R                  SS5      (       d  g U R                  5       (       a  U R                  5       S   c  U R                  (       a  U R                  " U0 UD6  g g )Nmark_watchedFr   )r   rZ   r   r  _mark_watchedr  s      r`   r  InfoExtractor.mark_watchedq  s[    ~~ne44!!d&:&:&<Q&?&KPTPdPd// Qerc   c                     [        S5      er  r   r  s      r`   r  InfoExtractor._mark_watchedw  r  rc   c                 B    0 nU R                  S5      nU(       a  X!S'   U$ )Ngeo_verification_proxyzYtdl-request-proxyr  )r[   r
  r  s      r`   geo_verification_headers&InfoExtractor.geo_verification_headersz  s(    !%0H!I!,B()rc   c                     [         R                  R                  [        R                  R                  U R                  S5      R                  S5      S   5      S   5      $ )Nr  r  r   )r  r  unquoter4  r5  r  rstripr  )ru   s    r`   _generic_idInfoExtractor._generic_id  sE    ||##BGG$4$4SZZ_5J5J35OPR5S$TUV$WXXrc   rK  c                    U R                  US S9=(       dh    U R                  US S9=(       dQ    [        R                  R	                  [
        R                  R                  [        U5      5      S   5      =(       d    U$ )NrK  r   )	rk  rw  r  r  r  r4  r5  r  rF   )r[   ru   r  rL  s       r`   _generic_titleInfoExtractor._generic_title  sl    %%gt%< ++GT+B<<''(8(8c9J(KA(NO 	rc   c                    U(       d  g U=(       d    /  Vs/ s H  nU" U5      U" U5      S.PM     nnU(       a  U R                   nOU R                  nUR                  S S9  SS0/n[        U5       H  u  pUS   c  U" SU	 35        M  US   S   US   s=::  a  U::  a  O  OUR	                  U5        MD  Xh;  d  MK  US   U:  a
  US    SU 3OUS    S	US   S    3n
U" S
U
 SUS    S35        M     USS  $ s  snf )N)r  r  c                     U S   =(       d    S$ )Nr  r   r   )r  s    r`   r  8InfoExtractor._extract_chapters_helper.<locals>.<lambda>  s    AlO,@q,@rc   rf  r  r   zIncomplete chapter r  z > z < zInvalid start time (z) for chapter "r  "r=  )r   r   sortr  r  )r[   chapter_liststart_functiontitle_functionr  r~  chapterwarnr  r  issues              r`   _extract_chapters_helper&InfoExtractor._extract_chapters_helper  sQ    &++- ,g )1#G,
 , 	 - &&D##D"@A!1%&%l3LC|$,*3%01"l+w|/DPP((DKLDY\dDdGL12#hZ@!(!6 7s8B<;U:VW +E7/''BRASSTUV 4 |)-s   C<c                     SnSnU R                  [        R                  " XCS4-  U=(       d    S5      S S USS9=(       d8    U R                  [        R                  " USU4-  U=(       d    S5      S	 S
 USS9$ )Nz(?:\d+:)?\d{1,2}:\d{2}z(?m)^\s*(%s)\b\W*\s(%s)\s*$z.+?rT   c                     [        U S   5      $ Nr   r5   re  s    r`   r  BInfoExtractor._extract_chapters_from_description.<locals>.<lambda>      ^AaD%9rc   c                     U S   $ Nr=  r   re  s    r`   r  r        TUVWTXrc   F)r  r  r  r~  c                     [        U S   5      $ r  r  re  s    r`   r  r    r	  rc   c                     U S   $ r  r   re  s    r`   r  r    r  rc   )r  r|   rP  )r[   r  r  duration_resep_res        r`   "_extract_chapters_from_description0InfoExtractor._extract_chapters_from_description  s    //,,JJvf 55{7HbI9.e - - - 150M0MJJv 55{7HbI9.e 1N 1-	-rc   c                     [        S XX#U4 5       5      nU (       a  S$ U(       a  S$ U(       a  S$ U(       a  S$ U(       a  S$ U(       a  S$ S $ )Nc              3   (   #    U  H  oS Lv   M
     g 7frq   r   r-  s     r`   rv   .InfoExtractor._availability.<locals>.<genexpr>  s      VT  TMTs   privatepremium_onlysubscriber_only
needs_authunlistedpublic)r  )
is_privateneeds_premiumneeds_subscriptionr  is_unlisted	all_knowns         r`   _availabilityInfoExtractor._availability  su     V(:TV V	 $I	#0	 '9"	 ",		
  +	 '	 	rc   )r   	casesensec                R   [        U[        5      (       a  UOU=(       d    U R                  5       n[        U R                  R
                  SUR                  5       U45      nUc  U[        L a  / $ U$ U(       a  [        U5      $ U Vs/ s H  ofR                  5       PM     sn$ s  snf )a,  
@returns            A list of values for the extractor argument given by "key"
                    or "default" if no such key is present
@param default      The default value to return when the key is not present (default: [])
@param casesense    When false, the values are converted to lower case
extractor_args)	r   r!  r   r?   r   r  r  r   r   )r[   rg  rL  r   r#  valr.  s          r`   _configuration_arg InfoExtractor._configuration_arg  s     &fc2248O8O8Q4++225Ev||~WZ4[\; J.2;G;%tCyCs+Cs!GGIs+CC+Cs   B$r  )playlist_labelvideo_labelc                8   U(       a  U(       d  U(       + $ U=(       d    0 R                  S5      nUb  U(       + $ USL a  SOSU 3nUSL a  SOSU 3nU R                  S5      (       a  U R                  SU U S35        gU R                  S	U U S
U U 35        g)Nforce_noplaylistTrT   rN  
noplaylistzDownloading just the z because of --no-playlistFzDownloading z* - add --no-playlist to download just the )r   r   r   )r[   r  r   smuggled_datar)  r*  no_playlists          r`   _yes_playlistInfoExtractor._yes_playlist  s    (<$*//0BC""?"!T)28*~'4/bq5F>>,''NN2;-zIbcdn%5k]Blmxly  {C  zD  E  	Frc   c                    [         R                  " X=(       d    [        U5      UU R                  U R                  U(       a  S OU R                  U R                  S0 5      R                  S5      S9  g )Nretry_sleep_functionsr  )r<  r   r  
sleep_func)r   report_retryr  r   r   r   r   )r[   r  r  _retriesr*  s        r`   _error_or_warningInfoExtractor._error_or_warning  sU    !!%3u:xd&9&9TXTgTg~~&=rBFF{S	Urc   c                 P    [        U R                  SS5      U R                  40 UD6$ )Nextractor_retriesr*  )r   r   r7  )r[   r  s     r`   r   InfoExtractor.RetryManager  s'    DNN+>BDDZDZe^deerc   zExtracting generic embeds)r  r  c                    [        USS5      nU R                  [        US S5       U 35        U R                  R	                  S5      R
                  " [        USU R                  5       /05      /UQ70 UD6$ )N
display_idr   r  Generic	block_ies)r?   r   r,   r   get_info_extractor_extract_embedsr;   r   )r[   ru   r  r  r  r  r=  s          r`   _extract_generic_embeds%InfoExtractor._extract_generic_embeds  s~    !)\4@
,z4@A$HI229=MMkDKKM?;<O?COGMO 	Orc   c              #     #    [        U R                  [        R                  5      (       a  U OUR	                  U R                  5       5      nUR                  X#5      =(       d    /  H  nUR                  XTS 5        Uv   M     g 7frq   )r   _extract_from_webpagetypes
MethodTyper@  r   add_default_extra_info)r   ydlru   r  r   r<  s         r`   extract_from_webpage"InfoExtractor.extract_from_webpage  sl      9 95;K;KLLc))#**,7 	,,S:@b@D&&t6J As   BBc              #      #    [        U R                  X5      =(       d    / SS9 H'  nU R                  X0R                  SL a  S OU 5      v   M)     g 7f)NTr  F)r2   _extract_embed_urlsr  rx   )r   ru   r  	embed_urls       r`   rE  #InfoExtractor._extract_from_webpage  sH     #''5;$HI..NNe4KDQTUUHs   AAc           
   #     #    SU R                   ;  a  [        U R                  [        [        45      (       d   e[        U R                  5       H3  u  p4UR                  S5      S:X  a  M   U R                   SU SU 35       e   [	        [        [        R                  U R                  5      5      U l        U R                   H~  nUR                  U5       Hf  n[        R                  R                  U[!        UR#                  S5      5      5      nU R$                  SL d  U R'                  U5      (       d  Mb  Uv   Mh     M     g7f)	z*@returns all the embed urls on the webpage_EMBED_URL_REz(?P<url>r=  z._EMBED_REGEX[z!] must have exactly 1 url group
	ru   FN)ry   r   _EMBED_REGEXr   rz   r  countr   r{   r|   r}   rQ  r  r  r  rI   rC   r   rx   r   )r   ru   r  r  rt   r  rN  s          r`   rM  !InfoExtractor._extract_embed_urls  s     #,,.c..u>>>>'(8(89
{{:.!3 c||nN3%7Z[`Zabc3 : !&c"**c6F6F&G HC&&Ew/"LL00l4::eCT6UV	>>U*cll9.E.E#O 0 's   A%E+CE:Ec                       \ rS rSrSrg)InfoExtractor.StopExtractioni  r   N)r   r  r  r  r  r   rc   r`   StopExtractionrV    s    rc   rW  c                 ^    [        [        U R                  SU5      =(       d    / 5      S5      $ )z1Only for compatibility with some older extractorsN)r~   iterrM  )r   r  s     r`   _extract_urlInfoExtractor._extract_url  s(     D00w?E2FMMrc   )plugin_namec                \  >^ T(       Ga  [         R                  " U 5      nX3R                  U 5      S-      =pE[        USS 5      (       a   UR                  n[        USS 5      (       a  M   [        U4S j[        R                  U    5       5      (       d  X@l        TUR                  sU l	        U l        UR                   ST 3U l
        [        [        R                  UR                     UR                  U 5        [        R                  U   R!                  U 5        ["        TU ]H  " S0 UD6$ )Nr=  r  c              3   @   >#    U  H  oR                   T:H  v   M     g 7frq   )PLUGIN_NAME)rs   overrider\  s     r`   rv   2InfoExtractor.__init_subclass__.<locals>.<genexpr>  s     sKrx++{:Krs   +r   )inspectgetmroindexr  r  rU   r   r}  r   r_  r   setattrr   modulesr  r   r  r  __init_subclass__)r   r\  r  mronext_mro_classsuper_classr  s    `    r`   rh  InfoExtractor.__init_subclass__  s    ..%C+.yy~/A+BBN+}d;;)55 +}d;; sK_KeKefqKrsss"0.9>;P;P+!/!7!7 8+GK$:$:;[=Q=QSVW$**;7>>sCw(2622rc   )r   rh   re   rf   rq   )NNNN)	NNTNNNNNF)NNTNNN)NTN)zEThis video is not available from your location due to geo restrictionNF)FNrb  )r   rV   N)ztwo-factor verification code)z	video urlT)r  )NF)TNr<  )__NUXT__)TNN)NrD  r)  )NrT   N)Nr  NNNN)NTNNNN)NNNNN)F)rT   rT   r  )r   r  r  r  r  re   r   rf   r   r   r   r   _ENABLEDrY   r   r  rx   rR  r   ra   rl   classmethodr   r   r   r   r   rZ   r   r   r   r   ri   propertyr   r   r   r   r   r   r   r"   r   staticmethodr'  r  r1  r:  rF  rh  rg  r7  rw  r{  r  r  '_InfoExtractor__create_download_methodsr  r  _download_json_handle_download_json_download_socket_json_handle_download_socket_jsonr  r  r   r   r   r   r  r  r   r  r  r  r  r  r  r   r  r  r  r  rO  r>  r   rI  rR  rU  r^  rd  rg  rk  rq  rt  rw  r|  r  r  r  r  r  r  r  r  r@  rZ  ri  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r	  r  r}  rz  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r1  r/   r4  r:  r8  rN  rd  ri  rl  rw  r{  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  r  re  cached_propertyr  r  r  r  r  r  r  r  r!  r'  r0  r7  r   rB  rJ  rE  rM  rW  rZ  rh  r  r  r  s   @r`   rQ   rQ   k   s1	   Wr FKKNNHHNGJJL!+4 	a( [ [ 5 5 5 5     ( ($Qhf nD& & & * *S ! ! ! ! ; ;
 dhqv?B GKTX`d*.T2Rae-19v   8< dh?C@Akl[E1N +D|.0HJs+u'-,E:<^`w-y)>:S79IKbd{;}7 "729dD$Pnopqr 26ta/@>% >OQ
 ,6 _
@;)%
 J$Z1 ^/4?L 
UZ 
 
 8<T%-$T3 3 
rw 
 
 <FTYZbf !F RT&2$
6 AKRV^_gk   D"*D 
 
 ? ?

%^S /4 ME>pu pHF  *0 9 = 7;J "4Yc "h!T ?CJ 	S3j1UYdo 1" =A* )QV =A* W  )   79 	; $ $. 18 5
 GKTXae.U#'D"TVM. OS\`im,S!%tdL

 +/}T4d5tR	-=` &*tMT4e$42	|"~ 04TVX`b	GW +/4QS[]
U 	 	bQ\
%
NJ ae|"| .&P0
 -1tTT2RO0018Pd
 LPVZdhpt{  JL  TV P"s"j~@ SU 8"t IVfh 3j 59: = Q[ 6 PTSWA1F GKVZ?B <@dUE*V2 K K  ? ? N N 	 	 L L
 < < %)4 2 20SL9 L:S   -1  S l l0S Y YD 2	-   /9 DDTY DYcqx  Ut Uf =?E` O   V V
 $ $  N N .2 3 3rc   rQ   c                   ^    \ rS rSrSr\" S5      rSr\S 5       r	S r
S rS r\S	 5       rS
rg)SearchInfoExtractori#  z
Base class for paged search queries extractors.
They accept URLs in the format _SEARCH_KEY(|all|[0-9]):{query}
Instances should define _SEARCH_KEY and optionally _MAX_RESULTS
infr  c                      U R                    S3$ )Nz/(?P<prefix>|[1-9][0-9]*|all):(?P<query>[\s\S]+)_SEARCH_KEYr   s    r`   rx   SearchInfoExtractor._VALID_URL-  s    ??##RSSrc   c                    U R                  U5      R                  SS5      u  p!US:X  a  U R                  US5      $ US:X  a  U R                  XR                  5      $ [	        U5      nUS::  a  [        SU SU S	35      eX0R                  :  a7  U R                  S
U R                  U R                  U4-  5        U R                  nU R                  X5      $ )Nri  r  rT   r=  r  r   zinvalid download number z for query "r  z,%s returns max %i results (you requested %i))r   r   _get_n_results_MAX_RESULTSr  r   r   r}  )r[   r  ri  r{  s       r`   r   !SearchInfoExtractor._real_extract1  s    --e4::8WMR<&&ua00u_&&u.?.?@@FAAv$'?s,ugUV%WXX&&&##$RVZVfVfhlhyhy{|U}$}~%%&&u00rc   c           
          U R                  [        R                  " U R                  U5      SU[	        S5      :X  a  SOU5      X5      $ )zxGet a specified number of results for a query.
Either this function or _search_results must be overridden by subclasses r   rz  N)r  r  islice_search_resultsr  )r[   r  r{  s      r`   r  "SearchInfoExtractor._get_n_results@  sF     ##T11%8!Q%PU,EVT\]^ 	rc   c                     [        S5      e)z%Returns an iterator of search resultsr   r   )r[   r  s     r`   r  #SearchInfoExtractor._search_resultsG  r   rc   c                     U R                   $ rq   r|  r   s    r`   r  SearchInfoExtractor.SEARCH_KEYK  s    rc   r   N)r   r  r  r  r  r  r  r  r"   rx   r   r  r  r  r  r   rc   r`   ry  ry  #  sO     <LLT T1S  rc   ry  c                   &    \ rS rSrSrSrSrS rSrg)UnsupportedURLIEiP  z.*Fc                     [        U5      erq   )r   r   s     r`   r   UnsupportedURLIE._real_extractU  s    s##rc   r   N)	r   r  r  r  rx   rn  r   r   r  r   rc   r`   r  r  P  s    JHG$rc   r  )src  r  r  re  rG  http.clientr\  http.cookiejarhttp.cookiesrc  r  r  r  r]   r4  r   r|   r1  r   r  rF  urllib.parser  urllib.requestxml.etree.ElementTreers  compatr   r   r   rW   r   downloader.f4mr   r	   downloader.hlsr
   globalsr   
networkingr   r   networking.exceptionsr   r   r   r   utilsr   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/   r0   r1   r2   r3   r4   r5   r6   r7   r8   r9   r:   r;   r<   r=   r>   r?   r@   rA   rB   rC   rD   rE   rF   rG   rH   rI   rJ   rK   rL   rM   utils._utilsrN   utils.jslibrO   rQ   ry  r  r   rc   r`   <module>r     s                 	  	  
      
 * A " * - = = = = = = = = = = = = = = = =| 2 !u>3 u>3p}*- *Z$} $rc   