
    VGh                        d dl Z d dlZd dlZd dlZddlmZmZ ddlmZ ddl	m
Z
 ddlmZmZmZmZmZmZmZmZmZmZmZmZ ddlmZ  G d	 d
e      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z G d de      Z  G d de      Z! G d de      Z" G d de      Z# G d de      Z$ G d d ee      Z%y)!    N   )InfoExtractorSearchInfoExtractor   )HEADRequest)	HTTPError)ExtractorErrorfloat_or_noneint_or_nonejoin_nonemptymimetype2extparse_qsstr_or_nonetry_callunified_timestampupdate_url_queryurl_or_noneurlhandle_detect_ext)traverse_objc                   &    e Zd ZdZdgZdddZd Zy)SoundcloudEmbedIEzDhttps?://(?:w|player|p)\.soundcloud\.com/player/?.*?\burl=(?P<id>.+)zQ<iframe[^>]+src=(["\'])(?P<url>(?:https?://)?(?:w\.)?soundcloud\.com/player.+?)\1zhttps://w.soundcloud.com/player/?visual=true&url=https%3A%2F%2Fapi.soundcloud.com%2Fplaylists%2F922213810&show_artwork=true&maxwidth=640&maxheight=960&dnt=1&secret_token=s-ziYeyTurlonly_matchingc                     t        |      }|d   d   }|j                  d      }|rt        |d|d   i      }| j                  |      S )Nr   r   secret_token)r   getr   
url_result)selfr   queryapi_urlr   s        d/var/www/it7/html/youtubeDownloader/venv/lib/python3.12/site-packages/yt_dlp/extractor/soundcloud.py_real_extractzSoundcloudEmbedIE._real_extract#   sM    ,q/yy0&wa0QRGw''    N)__name__
__module____qualname__
_VALID_URL_EMBED_REGEX_TESTr#    r$   r"   r   r      s$    XJhiL CE(r$   r   c                       e Zd ZdZdZdZdZdZdZdZ	i Z
dZ ej                  d	      Zd
dddddddddd
Zg dZej$                  d        Zd Zd Zd Zd Zd Zd Zd Zd Zd"d Zed!        Zy)#SoundcloudBaseIE
soundcloudzhttps://api-v2.soundcloud.com/https://soundcloud.com/sMozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/84.0.4147.105 Safari/537.36z?client_id=%sz;https://api-auth.soundcloud.com/web-auth/sign-in/password%sz1https://api-auth.soundcloud.com/connect/session%sz-[0-9a-z]+\.(?P<ext>jpg|png)z"([^"]+)"|([^ ]+)          /   C   d   i,  i  i  r   )
minitinysmallbadget67x67larget300x300cropt500x500original)http_aachls_aac	http_opushls_opushttp_mp3hls_mp3c                      t        j                  dj                  t         fd j	                  ddgt
              D                          j                  S )N|c              3      K   | ]a  }|d k7  r%t        j                  |      j                  dd      n2dj                  t	        t         j                  j
                               c yw)defaultz\*z.*rH   N)reescapereplacejoinmap_DEFAULT_FORMATS).0patternr   s     r"   	<genexpr>z1SoundcloudBaseIE._is_requested.<locals>.<genexpr>K   s\      (
  9@98LBIIg&&ue4#bii)>)>?@A(
s   A'A*formatsrJ   )ie_key)rK   compilerN   set_configuration_argSoundcloudIE	fullmatchr   s   `r"   _is_requestedzSoundcloudBaseIE._is_requestedI   sQ    zz$))C (
  229ykR^2_(
 %
   I		r$   c                 >    | j                   j                  dd|       y )Nr.   	client_id)cachestore)r   r^   s     r"   _store_client_idz!SoundcloudBaseIE._store_client_idQ   s    

{I>r$   c                    | j                  dd       }t        t        j                  d|            D ]J  }| j                  |d d      }|s| j	                  d|dd       }|s2|| _        | j                  |        y  t        d      )	Nr/   z<script[^>]+src="([^"]+)"Ffatalz#client_id\s*:\s*"([0-9a-zA-Z]{32})"z	client idrJ   zUnable to extract client id)_download_webpagereversedrK   findall_search_regex
_CLIENT_IDra   r	   )r   webpagesrcscriptr^   s        r"   _update_client_idz"SoundcloudBaseIE._update_client_idT   s    (()BDIBJJ'CWMN 		C++CU+CF ..:K / 7	 &/DO)))4		 :;;r$   c                    |j                  d      du }|r|d= |j                  di       j                         }t        d      D ]*  }| j                  |d<   ||d<   	  | j                  |i |c S  y # t
        $ r}t        |j                  t              r>|j                  j                  dv r&| j                  d        | j                          Y d }~|r | j                  t        |             Y d }~ y d }~ww xY w)Nrd   Fr    r   r^   )    )r   copyrangerj   _download_jsonr	   
isinstancecauser   statusra   rn   report_warningstr)r   argskwargs	non_fatalr    _es          r"   	_call_apizSoundcloudBaseIE._call_apib   s    JJw'50	w

7B',,.q 	A!%E+#F7O
*t**D;F;;		
 " aggy1aggnn
6R))$/**,''A/ s%   A22	C;;AC6C65C66C;c                 N    | j                   j                  dd      xs d| _        y )Nr.   r^    a3e059563d7fd3372b49b37f00a00bcf)r_   loadrj   r[   s    r"   _initialize_pre_loginz&SoundcloudBaseIE._initialize_pre_loginv   s    **//,DjHjr$   c                 *   | j                  | j                  | j                  | j                  z  z  d ddt	        j
                  dd|ii      j                               r#d| | j                  d<   | j                          y | j                  d       y )	NzVerifying login token...Fsessionaccess_token)noterd   datazOAuth Authorizationz<Provided authorization token is invalid. Continuing as guest)
_request_webpage_API_VERIFY_AUTH_TOKEN_API_AUTH_QUERY_TEMPLATErj   jsondumpsencode_HEADERSreport_loginrx   r   tokens     r"   _verify_oauth_tokenz$SoundcloudBaseIE._verify_oauth_tokeny   s      ++t/L/Lt/^_5UZZ^U,C DELLN ! P 06eW-=DMM/* ^_r$   c                 d      j                   ry t         fd      x}r j                  |       y y )Nc                  T     j                   j                        d   j                  S )Noauth_token)_get_cookies	_BASE_URLvaluer[   s   r"   <lambda>z3SoundcloudBaseIE._real_initialize.<locals>.<lambda>   s!    T%6%6t~~%F}%U%[%[ r$   )r   r   r   r   s   ` r"   _real_initializez!SoundcloudBaseIE._real_initialize   s2    ==[\\5\$$U+ ]r$   c                     |dk7  r t        d| j                  d       d      | j                  ry | j                  |       y )NoauthzLogin using username and password is not currently supported. Use "--username oauth --password <oauth_token>" to login using an oauth token, or else cookies)methodTexpected)r	   _login_hintr   r   )r   usernamepasswords      r"   _perform_loginzSoundcloudBaseIE._perform_login   sZ    w ++9+=>@JNP P ==  *	r$   c           
      l   d}d}d}d}d}d}	d}
d}d}d	}d
}d}|}|}dj                  ||||||	|
|fD cg c]  }t        |       c}      }||z   |z   |z   |z   |z   |z   |z   }d}t        t        |            D ]&  }|dz	  d|z  dz  z   }|t	        ||         z  }|dz  }( | d| d|dd| S c c}w )N!   r   i; u   i@w i  %       0763ed7314c69015fd4a0dc16bbf4b908r0   -i>z    i :x)rN   ry   rs   lenord)r   userpwclidaiswulbkcnyrr~   tmIntdhmfs                          r"   signzSoundcloudBaseIE.sign   s   . BHHQ1aAq!,DEDc$iEFEAIMA!A%)s1v 	AaQUrM*AQqTNAMA	 AaS!Aas## Fs   B1Nc                 D  $ t        d         }t               $g }d}d| j                  i}|r||d<   |sj                  d      rۉj                  d      r	 | j	                  | j
                   d| d|d	|| j                  
      }	t!        |	dt"        hf      x}r| j%                  t'        |      |ddd      }|rc|j(                  }$j+                  |       |j-                  dt/        |d      t1        |j2                  j                  d            |dddd       $fd}t!        ddd f      D ]7  }|r n2|d   }|d    }|j5                  d!      d"   }t!        |d#d$t         hf      xs d%}|j7                  d&      rd'}S|d(k(  rd%}|d)k7  rd*|v rd)}|d+k(  sd,|v rd-}| d!| }|d.k(  r| j                  d/| d0       | j9                  |      s| j                  d1| d2       t!        | j;                  ||d3| d4|| j                  
      dt"        hf      } ||      r$j+                  |       t!        |d#d5t         hf      }| j=                  d6|d7d       }d8d9d:j                  |r|d d; nd       xs t?        |d       }|r|d<k(  r|}|j                  d=      d>k(  }t1        | j=                  d?|d.d       xs! | j=                  d@|d.d       xs
 |rdA|v rdBnd       }|j                  dC      xs dD|v xs tA        jB                  dE|      }|j-                  tE        |||xr dFd!G      |||d||dHv rdInd%|d8k(  rdJnd |rdKn
|r|dLk\  rd"ndM|rdNnd |rdOnd dP       : |s9|r| jG                  |       j                  dQ      dRk(  r| jI                  d'S       j                  dT      xs i }g }j                  dU      }|xs |j                  dV      }t#        |      rtA        jB                  | jJ                  |      x}r| jL                  jO                         D ]  \  } }!| dWk(  r|jQ                  dX      ndY}| tA        jR                  | jJ                  dZ|  d[| |      d\}"| d]k(  r|sd^}!n
| dWk(  rd|"d_<   |!r|"jU                  |!|!d`       |j-                  |"        nd|ig}fda}#i d|db|j                  dc      ddtW        |j                  d            xs |j                  de      df|j                  dg      dhtY        j                  di            djj                  dj      dkj                  dj      dlj                  dl      dm|dnt[        j                  dn      do      dpj                  dg      dqj                  dq      dr |#ds      dt |#du      xs  |#dv      dw |#dx      dy |#dz      d{t!        d|t         ht\        t^        t\        f      t!        d}| j`                  jb                  hd~d~t\        f      t!        ddt         ht\        t^        t\        f      |s|dS d dS # t        $ r}
t        |
j                  t              r<|
j                  j                  dk(  r#| j                  d| j                                 n`t        |
j                  t              r+|
j                  j                  dk(  r| j                  d       n| j                  |
j                         d }	Y d }
~
d }
~
ww xY w)NidFr^   r   downloadablehas_downloads_lefttracks/z	/downloadz.Downloading original download format info JSONr    headersrp   zAOriginal download format is only available for registered users. rq   z9Original download format is not available for this clientredirectUriz.Checking original download format availabilityz)Original download format is not availablerc   downloadmp3re   zContent-Length
   Originalnone)	format_idextfilesizer   qualityformat_notevcodecc                     |  xs | v S Nr+   )r   format_urlss    r"   invalid_urlz8SoundcloudBaseIE._extract_info_dict.<locals>.invalid_url   s    70c[00r$   mediatranscodingsc                 ,    t        |d         xr |d   S )Nr   preset)r   )r}   vs     r"   r   z5SoundcloudBaseIE._extract_info_dict.<locals>.<lambda>  s    ;WXY^W_K`Kpefgoep r$   r   r   r}   r   formatprotocolhttp)zctr-zcbc-Tprogressivehlsz/hlszencrypted-hlsz/encrypted-hlshls-aesabrzSkipping broken "z" format"z%" is not a requested format, skippingzDownloading z format info JSON	mime_typezcodecs="([^"]+)"codecm4aopus)mp4ar      m3u8r   hqz(\d+)k$z\.(\d+)\.(?:opus|mp3)[/?]aac   snippedz	/preview/z/(?:preview|playlist)/0/30/preview)delim)r   r   m3u8_nativem4a_dashr      Premiumi)r   r   r   acodecr   r   r   	containerr   r   
preferencepolicyBLOCK)metadata_availabler   artwork_url
avatar_urlr@   r   jpgr   .r   r   r8      r  )widthheightc                 >    t        j                  |  d            S )N_count)r   r   )keyinfos    r"   extract_countz:SoundcloudBaseIE._extract_info_dict.<locals>.extract_counte  s    txx3%v788r$   uploaderr   uploader_id	permalinkuploader_urlpermalink_url	timestamp
created_attitletrackdescription
thumbnailsdurationi  webpage_urllicense
view_countplayback
like_countfavoritingslikescomment_countcommentrepost_countrepostsgenresgenretag_list.publisher_metadataartist)tagsartistsrT   )2ry   rW   rj   r   rt   _API_V2_BASEr   r	   ru   rv   r   rw   rx   r   write_debugmsgr   r   r   r   r   addappendr   r   r   	partition
startswithr\   r   ri   r   rK   searchr   
report_drmraise_geo_restricted_IMAGE_REPL_RE_ARTWORK_MAPitemsgroupsubupdater   r   r
   filterall_TAGS_RErh   )%r   r  
full_titler   extract_flattrack_idrT   has_drmr    download_datar~   redirect_urlurlh
format_urlr   r   r   preset_baser   short_identifier
stream_urlr   r   r   
is_premiumr   
is_previewr   r  r  	thumbnailmobjimage_idsizer   r  r   s%    `                                  @r"   _extract_info_dictz#SoundcloudBaseIE._extract_info_dict   s	   tDz?edoo.$0E.! 8TXXFZ=[% $ 3 3(()
)DhDE[_[h[h !4 !j  ,MMK=;YZZ|Z,,-x9i?u - N !%JOOJ/NN%/3D%H$/0@0@AQ0R$S)#%'1"($ 	1 dWn>p$qr A	A5Jx[F **3/2K#A*se'DEOH""#34=(!5 Vz%9 ?*.>*.L$"*1[M:e#  #45E4Fh!OP%%&67  1%5$66[!\] &dnnH5E4FFW&XT]] '5 '46;k]5KMJ :&OOJ'$Q;(FGI&&':IwX\&]E cu%)$/Y 4@	SW3X  #-!y)T1J"":vud"K G%%&BJPU_c%dG&5F?CHC
 %%	* S(J6SYY'EzR  NN*8VZ=UI]`a! -59K-KMQW+.%<ZT *1ccSjr,6yD%/cT kA	F )xx!W,))T)Bxx%2
hh}-9488L#9	y!yy!4!4i@@t@&*&7&7&=&=&? )NHd/7:/E$**U+5C&!vvd&9&9Qxj#;OQZ[A  6)+!!Z/*,,%)&*"  %%a(!)$  %i01
	9
(
,
 ;txx~6O$((;:O
 DHH_5	

 *488L+AB
 TXXg&
 TXXg&
 488M2
 *
 dhhz&:DA
 488O4
 txx	*
 -
3
 -6P-:P
 ]95
  M)4!
" l4'C5&#v)NO#
$ !
T]]5J5J4KSRUW]'^_#D+?C5RXZ]_e*fg&2w)
 	
( 9=)
 	
O " 	%aggy1aggnn6K''1151A1A1C0DFG  3#8M$$%`a''. $	%s   0Y 	\B8\\c                 &    | j                   dz   |z   S )Nzresolve?url=)r1  )clsr   s     r"   _resolv_urlzSoundcloudBaseIE._resolv_url  s    .0366r$   )NNF)r%   r&   r'   _NETRC_MACHINEr1  r   _USER_AGENTr   _API_AUTH_URL_PWr   r   r;  rK   rV   rC  r<  rP   	functoolscached_propertyr\   ra   rn   r   r   r   r   r   r   rU  classmethodrX  r+   r$   r"   r-   r-   ,   s    !N3L)I HK.TPH4Nrzz./H L _ ?<(k`,(V$:l
\ 7 7r$   r-   c                      e Zd ZdZdZdZddi dddd	d
ddddddddddddddddddededededd d!d"d#d$id%d&i dd'dd	d
d(dd(dd)dd*dd+dd,dd-dd.dddedededed!d/dd0d1gd*gg d2d3d4d5i dd6dd7d
d8dd8dd9dd:dd;dd<dd=dd>dddedededed!d?dd@dAgg dBd%dCd5i dd6dd7d
d8dd8dd9dd:dd;dd<dd=dd>dddedededed!d?dd@dAgg dBd%dDdEi ddFdd	d
dGddGddHddIddJd!dKddLddMddNddOdddededededPgdIgg dQd2dRgdSdTdUi ddVdd	d
dWddWddXddYddZdd[dd\dd]dddededededd^d!d_d`gdagg dbd2dRgdSdcddi ddedd7d
dfddfddgddhddiddjddkddlddmdddedededed!dndogg dpdqdridsdtdui ddvdd	d
dwddwddxddyddzdd{dd|dd}ddmdddedededed~dgdddd%di ddddd
dddHddddd!ddededededdd#g ddgddddddddddddddddddddddddddddddddddddddg
dddddddrdddrdgZd Zy)rY   a]  Information extractor for soundcloud.com
       To access the media, the uid of the song and a stream token
       must be extracted from the page source and the script must make
       a request to media.soundcloud.com/crossdomain.xml. Then
       the media can be grabbed by requesting from an url composed
       of the stream token and uid
     a  (?x)^(?:https?://)?
                    (?:(?:(?:www\.|m\.)?soundcloud\.com/
                            (?!stations/track)
                            (?P<uploader>[\w\d-]+)/
                            (?!(?:tracks|albums|sets(?:/.+?)?|reposts|likes|spotlight|comments)/?(?:$|[?#]))
                            (?P<title>[\w\d-]+)
                            (?:/(?P<token>(?!(?:albums|sets|recommended))[^?]+?))?
                            (?:[?].*)?$)
                       |(?:api(?:-v2)?\.soundcloud\.com/tracks/(?P<track_id>\d+)
                          (?:/?\?secret_token=(?P<secret_token>[^&]+))?)
                    )
                    r.   z9http://soundcloud.com/ethmusic/lostin-powers-she-so-heavy de9bac153e7427a7333b4b0c1b6a18d2r   62986583r   r   r  zELostin Powers - She so Heavy (SneakPreview) Adrian Ackers Blueprint 1r  r  zNo Downloads untill we record the finished version this weekend, i was too pumped n i had to post it , earl is prolly gonna b hella p.o'dr  zE.T. ExTerrestrial Musicr  1571244r  iV'vPupload_date20121011r  gxa@r   zall-rights-reservedr!  r#  r&  r(  rQ  z?https://i1.sndcdn.com/artworks-000031955188-rwb18x-original.jpgr  zhttps://soundcloud.com/ethmusicr/  zcount:14)r   md5	info_dictzihttps://soundcloud.com/the-concept-band/goldrushed-mastered?in=the-concept-band/sets/the-royal-concept-ep47127627
GoldrushedzNFrom Stockholm Sweden
Povel / Magnus / Filip / David
www.theroyalconcept.comThe Royal Concept9615865iO20120521gKcl@z'https://soundcloud.com/the-concept-bandz:https://i1.sndcdn.com/artworks-v8bFHhXm7Au6-0-original.jpgAlternative)r*  r0  r/  )r   rf  zDhttps://soundcloud.com/jaimemf/youtube-dl-test-video-a-y-baw/s-8Pjrp aa0dd32bfea9b0c5ef4f02aacd080604	123998367r   u!   Youtube - Dl Test Video '' Ä↭u   test chars:  "'/\ä↭jaimeMF69767071ixR20131209gv#@zhttps://soundcloud.com/jaimemfz5https://a1.sndcdn.com/images/default_avatar_large.png	youtubedl)r*  r/  z@https://api.soundcloud.com/tracks/123998367?secret_token=s-8Pjrpz+https://soundcloud.com/the80m/the-following ecb87d7705d5f53e6c02a63760573c75	343609555zThe Following 80M	312384765zhttps://soundcloud.com/the80m20170922iYgSx@z?https://i1.sndcdn.com/artworks-000243916348-ktoo7d-original.jpgzDance & EDM)rv  EDMDanceMusicz?Original download format is only available for registered users)r   re  rf  expected_warningszBhttps://soundcloud.com/oriuplift/uponly-238-no-talking-wav/s-AyZUd 2e1530d0e9986a833a67cb34fc90ece0	340344461zOUplifting Only 238 [No Talking] (incl. Alex Feed Guestmix) (Aug 31, 2017) [wav]z$md5:fa20ee0fca76a3d6df8c7e57f3715366zOri Uplift Music12563093i]Y20170831gjt@z?https://i1.sndcdn.com/artworks-000240712245-kedn4p-original.jpgz https://soundcloud.com/oriupliftTrance
Ori Uplift)
Orchestral	EmotionalzUplifting Trancer  r  UpOnlyz5https://soundcloud.com/garyvee/sideways-prod-mad-real 59c7872bc44e5d99b7211891664760c2	309699954zSideways (Prod. Mad Real)z$md5:d41d8cd98f00b204e9800998ecf8427egaryvee2366352iYgX20170226gMbi@zre:https?://.*\.jpgzhttps://soundcloud.com/garyveeMadReal)r0  r/  skip_downloadT)r   re  rf  paramsz2https://soundcloud.com/giovannisarani/mezzo-valzer 8227c3473a4264df6b02ad7e5b7527ac	583011102zMezzo Valzerz$md5:f4d5f39d52e0ccc2b4f665326428901azGiovanni Sarani3352531i{ex\20190228g/$f@r*  Pianoz%https://soundcloud.com/giovannisaranizcount:10)r  r/  z*https://soundcloud.com/skorxh/audio-dealer
2011421339r   zaudio dealerz$KORCH	150292288zhttps://soundcloud.com/skorxhg^Ij@r0  z$KORXHig20250117zChttps://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-original.pngr7   z?https://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-mini.jpgr
  r8   z?https://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-tiny.jpgr9   z@https://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-small.jpgr:   z@https://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-badge.jpgr;   zAhttps://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-t67x67.jpgr<   z@https://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-large.jpgr=   zChttps://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-t300x300.jpgr>   z?https://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-crop.jpgr?   zChttps://i1.sndcdn.com/artworks-a1wKGMYNreDLTMrT-fGjRiw-t500x500.jpgr@   )r   rQ  r  r   hls_aac_160k)r  r   )r   rf  r  zQhttps://soundcloud.com/wandw/the-chainsmokers-ft-daya-dont-let-me-down-ww-remix-1r   zChttps://soundcloud.com/taylorswiftofficial/look-what-you-made-me-doc                    | j                  |      }|j                  d      }i }|r-| j                  dz   |z   }|}|j                  d      }|r`||d<   nZ dj                  |j                  dd       x}}|j                  d      }|r|d| z  }| j	                  | j
                  |z         }| j                  ||d	|| j                  
      }	| j                         D ]  }
	 | j                  |	||      c S  y # t        $ rb}t        |j                  t              r|j                  j                  dk7  r | j                  dd       |j                  |
_        Y d }~d }~ww xY w)NrF  r   r   z{}/{}r  r  r   /zDownloading info JSONr   i  zYou have reached the API rate limit, which is ~600 requests per 10 minutes. Use the --extractor-retries and --retry-sleep options to configure an appropriate retry count and wait timeT)	only_once)_match_valid_urlr>  r1  r   rX  r   r   r   RetryManagerrU  r	   ru   rv   r   rw   rx   error)r   r   rR  rF  r    info_json_urlrD  r   resolve_titler  retryr~   s               r"   r#   zSoundcloudIE._real_extract  sq   $$S)::j) --	9HDM!JJJ~.E(-n%)7JPW9X)YYJJJw'E1UG, ,,T^^m-KLM~~:'>eUYUbUb  d &&( 
	&E	&..tZGG
	& " &!!''9539N##LW[ $ ]  gg&s   "C99	E$AEE$N)	r%   r&   r'   __doc__r(   IE_NAMEint_TESTSr#   r+   r$   r"   rY   rY     s<	   	J G O5jv ` `	
    l 6 y Z z G 0 c c     ^!"  A#$ 
%	
4 jv  	
 s / y Z z G 0 c c      I!" Y#$ )//0)	
6 Z5ku > >	
 9 I z Z z E 0 c c      @!" T#$ '-'	
6 V5ku > >	
 9 I z Z z E 0 c c      @!" T#$ '-'	
6 A5kv  	
 r E {  ? z Z G ^ 0 c    !" c#$ )/!78), #d!d3	
< X5kv j j	
 E . z Z z H 0 c c     ^!"  B#$ $*(>i), #d!d3	
: K5ku 4 4	
 E I y Z z G 3 0 c c    !"  @#$ &;',  1	
: H5kv  	
 E - y Z z G 3 0 c c    !" 7)#$ !H"'	
6 @ l u    r	 
 H  {   ?     c  c    G    H:     Z! " z# $ 1b!*kl!*kl"+mn"+mn#,op"+mn%.st!*kl%.st%.st) B )/.IG$	
N g!	
 Y!	
CFFP &r$   rY   c                       e Zd ZddZy)SoundcloudPlaylistBaseIENc                 @   t        |d         }|j                  d      xs g }t        d |D              s\|rZ| j                  | j                  dz   |ddj                  |D cg c]  }t        |d          c}      ||d| j                        }t        |dt         hfd	d
t         hfdt         hd hfd      }g }|D ]  }t        |j                  d            }	|j                  d      }
|
s|	s3| j                  dz   |	z   }
|r|
d|z   z  }
|j                   | j                  |
t        j                         |	fddi|         | j                  |||j                  d      |j                  d      fi |t        |d	d
t         hfd	dt        hfd      S c c}w )Nr   tracksc              3   >   K   | ]  }|j                  d         yw)r  N)r   )rQ   r   s     r"   rS   z8SoundcloudPlaylistBaseIE._extract_set.<locals>.<genexpr>  s     :a155):s   zDownloading tracks,)ids
playlistIdplaylistSecretTokenr   r  r   r   set_typec                     | xs dS )Nplaylistr+   )r   s    r"   r   z7SoundcloudPlaylistBaseIE._extract_set.<locals>.<lambda>  s
    j r$   )albumalbum_artist
album_typer  r   z?secret_token=url_transparentTr  )r  r  )ry   r   rB  r   r1  rN   r   r   r   r5  r   rY   rU   playlist_result)r   r  r   playlist_idr  r   
album_infoentriesr  rF  r   s              r"   _extract_setz%SoundcloudPlaylistBaseIE._extract_set  s   (4.)h'-2:6::u^^!!H,k$886$BaS4\$BC"-+0-  == $ *F "(u%#Z#7%u/H.IJ-
 

  
	[E"599T?3H))O,C'')3h>+e33CNN?4??\((*HZFJZNXZ [
	[ $t##[LL!LL'	
 		

 8#Z#7 &{m<& 	
 		
+ %Cs   "Fr   )r%   r&   r'   r  r+   r$   r"   r  r    s    %
r$   r  c            
       \    e Zd ZdZdZddddddddgd	d
ddddddddddddddgZd Zy)SoundcloudSetIEzuhttps?://(?:(?:www|m)\.)?soundcloud\.com/(?P<uploader>[\w\d-]+)/sets/(?P<slug_title>[:\w\d-]+)(?:/(?P<token>[^?/]+))?zsoundcloud:setzAhttps://soundcloud.com/the-concept-band/sets/the-royal-concept-ep2284613zThe Royal Concept EPz$md5:71d07087c7a449e8941a70a29e34671eri  rj  ep)r   r  r  r  r  r  album_artistsr  r   r   rf  playlist_mincountzGhttps://soundcloud.com/the-concept-band/sets/the-royal-concept-ep/tokenTr   z6https://soundcloud.com/discover/sets/weekly::flacmaticz<https://soundcloud.com/discover/sets/charts-top:all-music:dez<https://soundcloud.com/discover/sets/charts-top:hiphoprap:krc                    | j                  |      } dj                  |j                  dd       }|j                  d      }|r|d|z   z  }| j                  | j	                  | j
                  |z         || j                        }d|v r5d |d   D        }t        d	j                  d
j                  |                  | j                  ||      S )Nz
{}/sets/{}r  
slug_titler   r  r   errorsc              3   8   K   | ]  }t        |d            ywerror_messageNry   rQ   errs     r"   rS   z0SoundcloudSetIE._real_extract.<locals>.<genexpr>  s     H#CO,-H   z$unable to download video webpage: {}r  )
r  r   r>  r   rX  r   r   r	   rN   r  )r   r   rR  rD  r   r  msgss          r"   r#   zSoundcloudSetIE._real_extract  s    $$S)(\(($**Z*NO


7##+%J~~d..NNZ')*4dmm  M tHhHD !G!N!NsxxX\~!^__  u--r$   Nr%   r&   r'   r(   r  r  r#   r+   r$   r"   r  r    s     JJGR+A+$+12	
  Y H N N-F6.r$   r  c                       e Zd Zd Zd Zy)SoundcloudPagedPlaylistBaseIEc                 0    d||| j                  ||      dS )Nr  )_typer   r  r  )_entries)r   base_urlr  playlist_titles       r"   _extract_playlistz/SoundcloudPagedPlaylistBaseIE._extract_playlist  s#    #}}X{;	
 	
r$   c              #   0   K   dddd}t        j                         D ]  } j                         D ]*  }	  j                  ||| j                  d|dz          } n  fd	}d
   xs g D ],  } |||j                  d      |j                  d             . |j                  d      }|s y |j                  dd         y # t
        $ rE}t        |j                  t              r|j                  j                  dk7  r ||_
        Y d }~d }~ww xY ww)N   1r   limitlinked_partitioningoffsetzDownloading track page r   )r    r   r   i  c            
      :   | D ]  }t        |t              st        |j                  d            }|s1j	                  |t
        j                  |      rt
        j                         nd t        |j                  d            |j                  d            c S  y )Nr  r   r  )	ru   dictr   r   r   rY   suitablerU   r   )
candidatescandr  r   s      r"   resolve_entryz=SoundcloudPagedPlaylistBaseIE._entries.<locals>.resolve_entry?  s    & LD%dD1 $/0I$JM$#)5A5J5J=5YL//1_c'7'9J L LLr$   
collectionr  r  	next_hrefr  )	itertoolscountr  r   r   r	   ru   rv   r   rw   r  r   pop)	r   r   r  r    r   r  responser~   r  s	   `        r"   r  z&SoundcloudPagedPlaylistBaseIE._entries'  s'     #&
 "  	&A**, #~~[t}}6q1ug>  .  @H 	L l+1r J#AquuW~quuZ7HIIJ ,,{+CIIh%A 	& &  &aggy9QWW^^s=R"#EKs/   1D&CA*D	D;D	DDDN)r%   r&   r'   r  r  r+   r$   r"   r  r    s    
)&r$   r  c                       e 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dddgZd d!d"d#d$d%d&d'd(Zd) Zy*)+SoundcloudUserIEam  (?x)
                        https?://
                            (?:(?:www|m)\.)?soundcloud\.com/
                            (?P<user>[^/]+)
                            (?:/
                                (?P<rsrc>tracks|albums|sets|reposts|likes|spotlight|comments)
                            )?
                            /?(?:[?#].*)?$
                    zsoundcloud:userz)https://soundcloud.com/soft-cell-official	207965082zSoft Cell (All)r   r     r  z0https://soundcloud.com/soft-cell-official/trackszSoft Cell (Tracks)   z0https://soundcloud.com/soft-cell-official/albumszSoft Cell (Albums)r   z"https://soundcloud.com/jcv246/sets12982173zJordi / cv (Sets)r   z%https://soundcloud.com/jcv246/repostszJordi / cv (Reposts)   z%https://soundcloud.com/clalberg/likes11817582zclalberg (Likes)r   z*https://soundcloud.com/grynpyret/spotlight7098329zGrynpyret (Spotlight)z4https://soundcloud.com/one-thousand-and-one/comments	992430331z7x11x13-testing (Comments)zstream/users/%szusers/%s/trackszusers/%s/albumszusers/%s/playlistszstream/users/%s/repostszusers/%s/likeszusers/%s/spotlightzusers/%s/comments)rB  r  albumssetsr)  r%  	spotlightcommentsc           	         | j                  |      }|j                  d      }| j                  | j                  | j                  |z         |d| j
                        }|j                  d      xs d}| j                  | j                  | j                  |   |d   z  z   t        |j                  d            dj                  |d   |j                                     S )	Nr   Downloading user infor  rsrcrB  r   {} ({})r   )r  r>  r   rX  r   r   r  r1  _BASE_URL_MAPr   r   r   
capitalize)r   r   rR  r  r   resources         r"   r#   zSoundcloudUserIE._real_extract  s    $$S)::f%~~T^^h67-t}}  F ::f%.%% 2 28 <tDz II'T*-x/B/B/DEG 	Gr$   Nr%   r&   r'   r(   r  r  r  r#   r+   r$   r"   r  r  S  s   J  G:&
   B)
   B)
  4(
  7+
  7'
  <,
  F1
 c8Fv !##$,!)'	MGr$   r  c                   .    e Zd ZdZdZddddddgZd	 Zy
)SoundcloudUserPermalinkIEz/https?://api\.soundcloud\.com/users/(?P<id>\d+)zsoundcloud:user:permalinkz)https://api.soundcloud.com/users/3090986930909869neilcicr     r  c                    | j                  |      }| j                  | j                  |      |d| j                        }| j	                  | j
                   d|d    dt        |d         |j                  d            S )Nr  r  zusers/r   z/tracksr   )	_match_idr   rX  r   r  r1  ry   r   )r   r   user_idr   s       r"   r#   z'SoundcloudUserPermalinkIE._real_extract  s    ..%~~S!7,CT]]  \ %%  !T
|7;Sd_dhhWaNbd 	dr$   Nr  r+   r$   r"   r   r     s1    CJ)G:
   Fdr$   r   c                   .    e Zd ZdZdZddddddgZd	 Zy
)SoundcloudTrackStationIEzNhttps?://(?:(?:www|m)\.)?soundcloud\.com/stations/track/[^/]+/(?P<id>[^/?#&]+)zsoundcloud:trackstationz?https://soundcloud.com/stations/track/officialsundial/your-text	286017854zTrack station: your textr  r4   r  c                 2   | j                  |      }| j                  | j                  |      || j                        }| j	                  d|d   d      }| j                  | j                  dj                  |d         z   |dj                  |d               S )Nr  zsoundcloud:track-stations:(\d+)r   ztrack idzstations/{}/trackszTrack station: {}r  )r  r   rX  r   ri   r  r1  r   )r   r   
track_namer  rF  s        r"   r#   z&SoundcloudTrackStationIE._real_extract  s    ^^C(
t//4j$--X%%.dZI %% 4 ; ;E$K HH)00w@B 	Br$   Nr  r+   r$   r"   r  r    s1    bJ'GP/
   F	Br$   r  c                   Z    e 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gZddddZd Zy)SoundcloudRelatedIEzjhttps?://(?:(?:www|m)\.)?soundcloud\.com/(?P<slug>[\w\d-]+/[\w\d-]+)/(?P<relation>albums|sets|recommended)zsoundcloud:relatedz;https://soundcloud.com/wajang/sexapil-pingers-5/recommended
1084577272z!Sexapil - Pingers 5 (Recommended)r  2   r  z6https://soundcloud.com/wajang/sexapil-pingers-5/albumszSexapil - Pingers 5 (Albums)r   z4https://soundcloud.com/wajang/sexapil-pingers-5/setszSexapil - Pingers 5 (Sets)r   ztracks/%s/albumsz"tracks/%s/playlists_without_albumsztracks/%s/related)r  r  recommendedc           	      .   | j                  |      j                  dd      \  }}| j                  | j                  | j                  |z         |d| j
                        }|j                  d      r6t        | j                   ddj                  d |d   D              z  d	
      | j                  | j                  | j                  |   |d   z  z   t        |d         dj                  |j                  d      xs ||j                                     S )NslugrelationzDownloading track infor  r  z	 said: %sr  c              3   8   K   | ]  }t        |d            ywr  r  r  s     r"   rS   z4SoundcloudRelatedIE._real_extract.<locals>.<genexpr>  s#      GF.1C()GFr  Tr   r   r  r  )r  r>  r   rX  r   r   r   r	   r  rN   r  r1  r  ry   r   r  )r   r   r  r  r  s        r"   r#   z!SoundcloudRelatedIE._real_extract   s   ..s399&*MhT^^d23*DMM  C 99X DLL>!;chh GF5:8_GF ?F "FPTV V %% 2 28 <uT{ JJCPUVZP[L\UYYw/749L9L9NOQ 	Qr$   Nr  r+   r$   r"   r  r    sy    ~J"GL8
   H3
  F1
 F0 %4*MQr$   r  c            
       <    e Zd ZdZdZdddddddgd	dd
ddgZd Zy)SoundcloudPlaylistIEzfhttps?://api(?:-v2)?\.soundcloud\.com/playlists/(?P<id>[0-9]+)(?:/?\?secret_token=(?P<token>[^&]+?))?$zsoundcloud:playlistz,https://api.soundcloud.com/playlists/41103094110309z=TILT Brass - Bowery Poetry Club, August '03 [Non-Site SCR 02]z%re:.*?TILT Brass - Bowery Poetry ClubzNon-Site Records33660914r  )r   r  r  r  r  r  r  r  r  r   rf  playlist_countc                     | j                  |      }|j                  d      }i }|j                  d      }|r||d<   | j                  | j                  dz   |z   |d|| j                        }| j                  ||      S )Nr   r   r   z
playlists/zDownloading playlistr   )r  r>  r   r1  r   r  )r   r   rR  r  r    r   r   s          r"   r#   z"SoundcloudPlaylistIE._real_extract"  s    $$S)jj&

7#$)E.!~~,{:/udmm  U   u--r$   Nr  r+   r$   r"   r  r    sE    zJ#G=UB*%01$U	
  F.r$   r  c                   @    e Zd ZdZdZdZddddddgZd	Zd
Zd Z	d Z
y)SoundcloudSearchIEzsoundcloud:searchzSoundcloud searchscsearchzscsearch15:post-avant jazzcorezpost-avant jazzcorer     r  r  r  c           
   +     K   t        |j                  d| j                        | j                        }|j	                  |ddd       t        | j                  |z   |      }t        j                  d      D ]  }| j                  ||d| d| j                        }|j                  d      xs g D ]A  }|s | j                  |d	   t        j                         fi | j                  |d
       C |j                  d      }|r y  y w)Nr  r   r   r  zDownloading page zUnable to download API pager  r  uriT)rE  r  )minr   _DEFAULT_RESULTS_PER_PAGE_MAX_RESULTS_PER_PAGEr@  r   r1  r  r  r   r   r   rY   rU   rU  )	r   endpointcollection_idr    r  next_urlr   r  items	            r"   _get_collectionz"SoundcloudSearchIE._get_collectionB  s"    IIgt==>&&( 	#$
 	
 $D$5$5$@%H# 	A~~-+<QC)@-t}} & FH !\28b p)$//U\%8%8%:p>B>U>UVZim>U>np pp
  ||K0H	s   B4D7AD	Dc           
          | j                  t        j                  | j                  d|||      d|t	        d      k(  rd n|      ||      S )Nzsearch/tracks)r  qr   inf)r  r  islicer)  float)r   r    r   s      r"   _get_n_resultsz!SoundcloudSearchIE._get_n_results[  sR    ##I$4$4  %qE JqE%L(ta%127@ 	@r$   N)r%   r&   r'   r  IE_DESC_SEARCH_KEYr  r$  r#  r)  r/  r+   r$   r"   r  r  2  sI    !G!GK/'*
  F   "2@r$   r  )&r\  r  r   rK   commonr   r   
networkingr   networking.exceptionsr   utilsr	   r
   r   r   r   r   r   r   r   r   r   r   utils.traversalr   r   r-   rY   r  r  r  r  r   r  r  r  r  r+   r$   r"   <module>r7     s       	 6 $ -    +( ($U7} U7p
~&# ~&B
&
/ &
R-.. -.`2&$4 2&j]G4 ]G@d = d*B< B0-Q7 -Q`.3 .D,@)+> ,@r$   