
    yf                     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	 ddl
mZ  G d de      Zy)	    N   )InfoExtractor   )ExtractorErrorparse_iso8601update_url_queryurl_or_none)traverse_objc            
       X    e Zd ZdZdddddddd	d
dddiddddddddddddidgZd Zy)BoxIEzShttps?://(?:[^.]+\.)?app\.box\.com/s/(?P<shared_name>[^/?#]+)(?:/file/(?P<id>\d+))?zRhttps://mlssoccer.app.box.com/s/0evd2o3e08l60lr4ygukepvnkord1o1x/file/510727257538 1f81b2fd3960f38a40a3b8823e5fcd43510727257538mp4z7Garber   St. Louis will be 28th MLS team  +scarving.mp4 i&\]20190820	235196876)idexttitleuploader	timestampupload_dateuploader_idskip_downloadzdash fragment too small)urlmd5	info_dictparamsz=https://utexas.app.box.com/s/2x6vanv85fdl8j2eqlcxmv0gp1wvps6e787379022466z%Webinar recording: Take the Leap!.mp4zPatricia MoseleiO`20210315	239068974)r   r   r   c           
      @   | j                  |      j                         \  }}| j                  ||xs |      }|sZ| j                  d|d|      }t	        |dt
        hf      xs i }|j                  d      dk7  rt        dd      t        |d	         }| j                  d
|d|      d   }| j                  d|dt        j                  d|gi      j                         d|d|z   d      |   d   }d|z   }	| j                  d|z   |dd|z   d|	z   ddddi      }
|
d   }||	d }g }t	        |
d!d"d# d$d%t        hf      D ]t  }t        |j                  d&d'      |      }| j!                  ||      }|D ].  }t"        j$                  j'                  |      j(                  |d(<   0 |j+                  |       v |
j                  d)      xs i }||||
j                  d*      xs d |j                  d      t-        |
j                  d+            |j                  d,      d-S ).NzBox\.postStreamData\s*=zBox post-stream dataz/app-api/enduserapp/shared-itemitemTypefilez$The requested resource is not a fileT)expecteditemIDzBox\.config\s*=z
Box configrequestTokenz6https://app.box.com/app-api/enduserapp/elements/tokenszDownloading token JSON metadatafileIDszapplication/jsonzsharedName=)zContent-TypezX-Request-TokenzX-Box-EndUser-API)dataheadersreadzhttps://app.box.com/s/zhttps://api.box.com/2.0/files/zDownloading file JSON metadatazBearer zshared_link=z[dash])AuthorizationBoxApizX-Rep-Hintsfieldszvauthenticated_download_url,created_at,created_by,description,extension,is_download_available,name,representations,size)r*   queryname)access_tokenshared_linkrepresentationsentriesc                     |d   dk(  S )Nrepresentationdash )_vs     6/usr/lib/python3/dist-packages/yt_dlp/extractor/box.py<lambda>z%BoxIE._real_extract.<locals>.<lambda>W   s    q9I7Jf7T     contenturl_templatez{+asset_path}zmanifest.mpdextra_param_to_segment_url
created_bydescription
created_atr   )r   r   formatsrB   r   r   r   )_match_valid_urlgroups_download_webpage_search_jsonr
   dictgetr   str_download_jsonjsondumpsencoder	   r   replace_extract_mpd_formatsurllibparseurlparser/   extendr   )selfr   shared_namefile_idwebpagepost_stream_datashared_itemrequest_tokenr1   r2   fr   r/   rD   url_tmplmanifest_urlfmtsfmtcreators                      r;   _real_extractzBoxIE._real_extract+   s   #44S9@@BW((g.DE#00*G5K[ Z& #Dtf"MO URT z*f4$%KVZ[[+h/0G))w@@NP**Dg-Y	23::< 2#0%2[%@G +     /<,w6,!*\!9(;6'7
   S    &	 )&

 $Qy*T~})
  	!H ,H,<,<_n,]_deL,,\7CD ^4:LL4I4I,4W4]4]01^NN4 	! %%%+ 55/74F+&quu\':;";;t,
 	
r=   N)__name__
__module____qualname__
_VALID_URL_TESTSrc   r8   r=   r;   r   r      ss    gJc1 N#%&
 #$=> O <)#%&
 #$=>F6?
r=   r   )rM   urllib.parserR   commonr   utilsr   r   r   r	   utils.traversalr
   r   r8   r=   r;   <module>rm      s+      !  +\
M \
r=   