
    ĞiK                         d dl Z d dlZd dlZd dlZddlmZ ddlmZm	Z	m
Z
mZmZmZmZ ddlmZ  G d de          Z G d	 d
e          ZdS )    N   )InfoExtractor   )ExtractorErrordetermine_extfilter_dictint_or_noneparse_iso8601
update_urlurl_or_none)traverse_objc                      e Zd ZdZdZde dgZddddd	d
ddddddddddddddddddddddddd d!d"d#	dd$d%dd&d'd(d)d*d+d,d-d.id/gd0d1d2d3dd4d5d6d7d8dd9d:id/gd;d<d=d>dd?d@dAdBdCddDdEid/gd;gZdFdGdHddIdJdKdLdMdNdOdPgZdQdRg dSiiZ e	j
        dT           e	j
        dU           e	j
        dV           e	j
        dW          dXZdYZdad\Zd] Zd^ Zd_ Zd` ZdZS )bLoomIEloomz@https?://(?:www\.)?loom\.com/(?:share|embed)/(?P<id>[\da-f]{32})z<iframe[^>]+\bsrc=["\'](?P<url>)z;https://www.loom.com/share/43d05f362f734614a2e81b4694a3a523 bfc2d7e9c2e0eb4813212230794b6f42 43d05f362f734614a2e81b4694a3a523mp4z#A Ruler for Windows - 28 March 2022zwILLIAM PIP20220328i^jAb   )idexttitleuploaderupload_date	timestampduration)urlmd5	info_dictz;https://www.loom.com/share/c43a642f815f4378b6f80a889bb73d8d 70f529317be8cf880fcc2c649a531900 c43a642f815f4378b6f80a889bb73d8dwebmzLilah Nielsen Intro VideozLilah Nielsen20200826iLF_   z;https://www.loom.com/share/9458bcbf79784162aa62ffb8dd66201b 7b6bfdef8181c4ffc376e18919a4dcc2 9458bcbf79784162aa62ffb8dd66201bzSharing screen with gpt-4zUSharing screen with GPT 4 vision model and asking questions to guide through blender.zSuneel Mathamzcount:320231109iLe]   )	r   r   r   descriptionr   chaptersr   r   r   z;https://www.loom.com/share/24351eb8b317420289b158e4b7e96ff2 24351eb8b317420289b158e4b7e96ff2z
OMFG clownz$md5:285c5ee9d62aa087b7e3271b08796815zBrailey Bragg20210924iENa   )r   r   r   r*   r   r   r   r   skip_downloaddashzFailed to parse JSON)r   r    paramsexpected_warningsz;https://www.loom.com/share/50e26e8aeb7940189dff5630f95ce1f4 5cc7655e7d55d281d203f8ffd14771f7 50e26e8aeb7940189dff5630f95ce1f4ziOS Mobile UploadzSimon Curran20200520iy^#   videopasswordseniorinfants2)r   r   r    r1   r2   z;https://www.loom.com/embed/ddcf1c1ad21f451ea7468b1e33917e4e f983a0f02f24331738b2f43aecb05256 ddcf1c1ad21f451ea7468b1e33917e4ezCF Reset User's PasswordzAimee Heintz20220707ib   format	bestvideozBhttps://www.loom.com/community/e1229802a8694a09909e8ba0fbb6d073-pg ec838cd01b576cf0386f32e1ae424609 e1229802a8694a09909e8ba0fbb6d073z.Rexie Jane Cimafranca - Founder's PresentationzRexie Cimafranca20230213   inc)r   r   r   r   r   r   r   z404 Not Found)r   r   r    skipGetVideoSourceacceptableMimes)DASHM3U8MP4WEBMa              query GetVideoSSR($videoId: ID!, $password: String) {
              getVideo(id: $videoId, password: $password) {
                __typename
                ... on PrivateVideo {
                  id
                  status
                  message
                  __typename
                }
                ... on VideoPasswordMissingOrIncorrect {
                  id
                  message
                  __typename
                }
                ... on RegularUserVideo {
                  id
                  __typename
                  createdAt
                  description
                  download_enabled
                  folder_id
                  is_protected
                  needs_password
                  owner {
                    display_name
                    __typename
                  }
                  privacy
                  s3_id
                  name
                  video_properties {
                    avgBitRate
                    client
                    camera_enabled
                    client_version
                    duration
                    durationMs
                    format
                    height
                    microphone_enabled
                    os
                    os_version
                    recordingClient
                    recording_type
                    recording_version
                    screen_type
                    tab_audio
                    trim_duration
                    width
                    __typename
                  }
                  playable_duration
                  source_duration
                  visibility
                }
              }
            }
a              query GetVideoSource($videoId: ID!, $password: String, $acceptableMimes: [CloudfrontVideoAcceptableMime]) {
              getVideo(id: $videoId, password: $password) {
                ... on RegularUserVideo {
                  id
                  nullableRawCdnUrl(acceptableMimes: $acceptableMimes, password: $password) {
                    url
                    credentials {
                      Policy
                      Signature
                      KeyPairId
                      __typename
                    }
                    __typename
                  }
                  __typename
                }
                __typename
              }
            }
a              query FetchVideoTranscript($videoId: ID!, $password: String) {
              fetchVideoTranscript(videoId: $videoId, password: $password) {
                ... on VideoTranscriptDetails {
                  id
                  video_id
                  source_url
                  captions_source_url
                  __typename
                }
                ... on GenericError {
                  message
                  __typename
                }
                __typename
              }
            }
a              query FetchChapters($videoId: ID!, $password: String) {
              fetchVideoChapters(videoId: $videoId, password: $password) {
                ... on VideoChapters {
                  video_id
                  content
                  __typename
                }
                ... on EmptyChaptersPayload {
                  content
                  __typename
                }
                ... on InvalidRequestWarning {
                  message
                  __typename
                }
                ... on Error {
                  message
                  __typename
                }
                __typename
              }
            }
)GetVideoSSRrD   FetchVideoTranscriptFetchChapters45a5bd4NTc                 <   |                      d          }|                     d||pd|pdddd| j         d| j        |dd	t          j        |||d
| j                            |i           | j        |         dd                                          |          S )Nr7   zhttps://www.loom.com/graphqlzDownloading GraphQL JSONzFailed to download GraphQL JSONapplication/json	loom_web_webzhttps://www.loom.com)AcceptContent-Typezx-loom-request-sourcezapollographql-client-namezapollographql-client-versionzgraphql-operation-nameOrigin)videoIdpassword)operationName	variablesquery,:
separators)headersdatafatal)		get_param_download_json_APOLLO_GRAPHQL_VERSIONjsondumps_GRAPHQL_VARIABLESget_GRAPHQL_QUERIESencode)selfoperation_namevideo_idnoteerrnotera   rV   s          ZC:\Users\betacode\Desktop\descargarYoutube\venv\Lib\site-packages\yt_dlp/extractor/loom.py_call_graphql_apizLoomIE._call_graphql_api   s    >>/22""*Hd6X>X88, 2)ST5Q)S)S-2040L*80C C J!/' (  -11."EE
 .~>    %& & & '-fhhe% # = = 	=    c                 D   |                      d| d| |d| dd| dddddt          j        t          t	          j                              d d|                     d	          d
d                                                    }t          |dt          hf          S )Nz,https://www.loom.com/api/campaigns/sessions//zDownloading z JSONzFailed to download FrO   )rR   rS   r7   )anonIDdeviceIDforce_originalrV   rZ   r]   )ra   r_   r`   r   )
rc   re   rf   struuiduuid4rb   rj   r   r   )rk   endpointrm   responses       rp   _call_url_apizLoomIE._call_url_api  s    &&P8PPhPPRZ*8***,Q(,Q,Q,QY^1CUVVdjll++ "' NN?;;	 
 %& & &
 '-fhh ' 	0 	0 Hu{m&<===rr   c                    
 g }t          |ddt          hfdt          hfdd hfdf          
 
fd}                     d          }|                     ||d	d
                                          d          }|                     ||dd                     t          |ddddt          hf          }d ||fD             }	|r4t          |d           |	vr!|                     ||dd                     |S )Nvideo_propertieswidthheightmicrophone_enabledc                     | du rdnd S )NFnone )xs    rp   <lambda>z)LoomIE._extract_formats.<locals>.<lambda>$  s    !u**RV rr   )r   r   acodecc              3   $  K   | sd S t          |           }t          j                            |           j        }|dk    r|                     dd          } 	                    | 
dd| d|          }dt          |d	          v }|D ]B}|r|                    d
          dk    rd|d<   i |t          |d         |          |dV  Cd S |dk    r.	
                    | 
d| d          }|D ]}i |||dV  d S | |d| |dV  d S )Nm3u8z-split.m3u8z.m3u8r   zhls-F)m3u8_idra   qualityr   ).vcodecr   r   r   rY   )r   extra_param_to_segment_urlmpdzdash-)mpd_idra   )r   r   zhttp-)r   r   	format_idr   )r   urllibparseurlparserY   replace_extract_m3u8_formatsr   rh   r   _extract_mpd_formats)
format_urlr   r   r   rY   m3u8_formatsis_not_premergedfmtdash_formatsrk   rm   r   s            rp   get_formatsz,LoomIE._extract_formats.<locals>.get_formats'  s      
++CL))*55;Ef}}'//wGG
#99%9K	9K9KSXbi  :  k  k $*\,-X-X#X '  C' /CGGH,=,=,G,G(.H)#e*EBBB6;        #881D1D1DE  9  S  S'  C6;#*        &!4!4!4&	 
 '     rr   zraw-urlrawr   )r   ztranscoded-url
transcodedr`   getVideonullableRawCdnUrlr   c                 4    g | ]}|t          |d           S )Nr   )r   ).0r   s     rp   
<listcomp>z+LoomIE._extract_formats.<locals>.<listcomp>X  s+    ^^^cZ]^jD111^^^rr   r   cdnr   )r   r	   r}   extendr   r   )rk   rm   metadata
video_dataformatsr   raw_urltranscoded_urlcdn_url
valid_urlsr   s   ``        @rp   _extract_formatszLoomIE._extract_formats  sj   '3E}-+/+.V.V-WXH
 H
 3  '	 '	 '	 '	 '	 '	 '	R $$Y99{{7E1===>>>++,<hGG{{><LLLMMMzFJ@SUZ]h\i+jkk^^g~=V^^^
 	Cz'666jHHNN;;wqAAABBBrr   c                     |                      d|dd          }t          dt          |dddd	t          hif          pd i          S )
NrK   z"Downloading GraphQL subtitles JSONFra   enr`   fetchVideoTranscript)
source_urlcaptions_source_urlr   )rq   r   r   r   )rk   rm   	subs_datas      rp   _get_subtitleszLoomIE._get_subtitles^  su    **"H.RZ_ + a a	,y.5K=8+    
   	rr   c                    |                      |          }t          |                     d|dd          ddt          hf          pi }|                    d          dk    r7|                     d	          st          d
d          t          dd          |                     d|d          }|                     d|dd          }t          |ddt          hf          }|||                     t          |dddt          hf          |          pd | 
                    |||          |                     |          dt          |dt          hfdt          hfddt          hfdt          hfd          S )NrJ   z!Downloading GraphQL metadata JSONFr   r`   r   
__typenameVideoPasswordMissingOrIncorrectr7   zAThis video is password-protected, use the --video-password optionT)expectedzInvalid video passwordrD   zDownloading GraphQL video JSONrL   z!Downloading GraphQL chapters JSONr   r   fetchVideoChapterscontent)r   r   r+   r   	subtitlesnamer*   ownerdisplay_name	createdAt)r   r*   r   r   )	_match_idr   rq   dictrh   rb   r   r	   "_extract_chapters_from_descriptionrx   r   extract_subtitlesr
   )rk   r   rm   r   r   chapter_datar   s          rp   _real_extractzLoomIE._real_extracti  s   >>#&&""=(<_gl"mmZ$(* * 0-/ 	 <<%%)JJJ>>/22 h$Wbfh h h h !9DIIII++h(HJ J
--X'JRW . Y Y+=zK=*YZZ  ??\F4H)VYUZ+[\\^fh h pko,,XxLL//99
 
 8 3% -u5$nse<)M?;	& &  
 	
rr   )NNT)__name__
__module____qualname__IE_NAME
_VALID_URL_EMBED_REGEX_TESTS_WEBPAGE_TESTSrg   textwrapdedentri   rd   rq   r}   r   r   r   r   rr   rp   r   r      s       GTJDzDDDEL M14:%%#
 
	  M140'%#
 
	  M140r'!%#

 

	 " M4!A'%#	
 	
 #F+45 " M14(&%#
 
 #$4545 " M140&%#
 
 [)45 OVFp T14F*%#
 
    N  	>>>
 'x 9( 9 9t *(/ +  ( !0 1 ! !" ) *  Aw wp (= = = =,> > >= = =~	 	 	
 
 
 
 
rr   r   c                       e Zd ZdZdZdZdddddd	d
ddddd	dddddd	dddddd	dddddddddddd	ddd d!dd	d"d#d$gZd% Zd)d'Zd( Z	d&S )*LoomFolderIEFzloom:folderz=https?://(?:www\.)?loom\.com/share/folder/(?P<id>[\da-f]{32})zBhttps://www.loom.com/share/folder/997db4db046f43e5912f10dc5f817b5c    997db4db046f43e5912f10dc5f817b5czBlending Lessons)r   r   )r   playlist_mincountr    zBhttps://www.loom.com/share/folder/9a8a87f6b6f546d9a400c8e7575ff7f2    9a8a87f6b6f546d9a400c8e7575ff7f2zList A- a, i, ozBhttps://www.loom.com/share/folder/886e534218c24fd292e97e9563078cc4    886e534218c24fd292e97e9563078cc4zMedicare Agent Training videoszBhttps://www.loom.com/share/folder/b72c4ecdf04745da9403926d80a40c38 b72c4ecdf04745da9403926d80a40c38zQuick Altos Q & A TutorialszBhttps://www.loom.com/share/folder/8b458a94e0e4449b8df9ea7a68fafc4e    8b458a94e0e4449b8df9ea7a68fafc4ezSezer Texting Guide)r   playlist_countr    zBhttps://www.loom.com/share/folder/e056a91d290d47ca9b00c9d1df56c463=    e056a91d290d47ca9b00c9d1df56c463zUser VideoszBhttps://www.loom.com/share/folder/c2dde8cc67454f0e99031677279d8954K    c2dde8cc67454f0e99031677279d8954zHonors 1zKhttps://www.loom.com/share/folder/bae17109a68146c7803454f2893c8cf8/EdpuzzleT)r   only_matchingc                 >    |                      d| |dddi          S )Nz https://www.loom.com/v1/folders/zDownloading folder info JSONlimit10000r   )rc   )rk   	folder_ids     rp   _extract_folder_dataz!LoomFolderIE._extract_folder_data  s9    "":y::I*7G2D # F F 	Frr   Nc           	   #   V  K   |p|                                }t          |dd f          D ]?}|d         }|                     d| t          ||                    d                    V  @t          |dfddt
          hf          D ]}|                     |          E d {V  d S )Nvideosc                     |d         S Nr   r   )_vs     rp   r   z6LoomFolderIE._extract_folder_entries.<locals>.<lambda>  s
    qw rr   r   zhttps://www.loom.com/share/r   foldersc                     |d         k    S r   r   )r   r   r   s     rp   r   z6LoomFolderIE._extract_folder_entries.<locals>.<lambda>  s    $9(< rr   )r   r   
url_resultr   rh   rx   _extract_folder_entries)rk   r   initial_folder_datafolder_datavideorm   subfolder_ids    `     rp   r   z$LoomFolderIE._extract_folder_entries  s     )QT-F-Fy-Q-Q!+:N:N/OPP 	_ 	_ET{H//8h88&(EIIV\L]L]_ _ _ _ _ _ )<<<<dSE7K L L 	B 	BL33LAAAAAAAAAA	B 	Brr   c           
          |                      |          }|                     |          }|                     |                     ||          |t	          |ddt
          j        hf                    S )Nfolderr   )r   r   playlist_resultr   r   rx   strip)rk   r   playlist_idplaylist_datas       rp   r   zLoomFolderIE._real_extract  sn    nnS))11+>>##((mDDk6CI;(GHHJ J 	Jrr   )N)
r   r   r   _WORKINGr   r   r   r   r   r   r   rr   rp   r   r     sr       HGQJ T4'
 
	  T4&
 
	  T45
 
	  T42
 
	  T4*
 
	  T4"
 
	  T4
 
	  ] q;FzF F F
B B B BJ J J J Jrr   r   )re   r   urllib.parser   ry   commonr   utilsr   r   r   r	   r
   r   r   utils.traversalr   r   r   r   rr   rp   <module>r     s'          ! ! ! ! ! !                  + * * * * *u
 u
 u
 u
 u
] u
 u
 u
pYJ YJ YJ YJ YJ= YJ YJ YJ YJ YJrr   