
    }j-                         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	 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y)   )InfoExtractor   )int_or_nonestr_or_noneunified_timestampurl_or_none)traverse_objc                   p    e Zd ZdZdddddddgd	d
gddgdddd
ddddddddgddgdddd	ddddgZd Zy )!IdagioTrackIEz`https?://(?:www\.)?app\.idagio\.com(?:/[a-z]{2})?/recordings/\d+\?(?:[^#]+&)?trackId=(?P<id>\d+)z;https://app.idagio.com/recordings/30576934?trackId=30576943 15148bd71804b2450a2508931a116b5630576943mp3zTheme. AndanteR   Edward ElgarVasily Petrenko&Royal Liverpool Philharmonic Orchestra
OrchestralOther Orchestral Musice\20190405)
idexttitleduration	composersartistsgenrestrack	timestampupload_date)urlmd5	info_dictzJhttps://app.idagio.com/recordings/20514467?trackId=20514478&utm_source=pcl 3acef2ea0feadf889123b70e5a1e7fa720514478zI. Adagio sostenutoi<  Ludwig van BeethovenKeyboardSonata (Keyboard)|Z20180208)	r   r   r   r   r   r   r   r   r    zMhttps://app.idagio.com/de/recordings/20514467?trackId=20514478&utm_source=pclTr!   only_matchingc                    | j                  |      }| j                  d| |dd      }t        |d      dk(  r| j                          | j                  d| |dd	d
d      }dd|t        |dt        hf      dt        |dddt
        hfddt        d      hfddt
        hfdt        hfddt
        hfdddt
        ht        fdddddt
        ht        t        t        f	dddddt
        ht        fd f      S )!Nz,https://api.idagio.com/v2.0/metadata/tracks/Fi  )fatalexpected_status
error_codezidagio.error.blocked.locationz*https://api.idagio.com/v1.8/content/track/02zweb-4)qualityformatclient_type)queryr   noner!   )r   vcodecr   r!   resultpiecer   	recording
created_at  scalelocationr   	conductor)	ensembles.)soloists.nameworkpartworkcomposergenresubgenre)r   r   r@   r   r   r   r   r   )		_match_id_download_jsonr	   raise_geo_restrictedr   strr   filterall)selfr!   track_id
track_infocontent_infos        J/root/.hermes/venv/lib/python3.12/site-packages/yt_dlp/extractor/idagio.py_real_extractzIdagioTrackIE._real_extract*   sO   >>#&((:8*EE3 ) 8
 
L15TT%%'**8
CX& +  u{m.DE	

 :!7SE2)<+D:Q9RS(*se<'+7!7SE2')]_ehkglntu%z6:vPSuV\^acij"J8MwY\X]_ef	3 	( 	
 	
    N)__name__
__module____qualname__
_VALID_URL_TESTSrW    rX   rV   r   r      s    tJL1%())+ST#%=>%#%
  \1*01!#67*#%

 _; FD
rX   r   c                        e Zd ZdZdZd Zd Zy)IdagioPlaylistBaseIEzESubclasses must set _API_URL_TMPL and define _parse_playlist_metadatar   c              #      K   t        |dd f      D ]8  }|d   }|d   d   }| j                  d| d| t        t        |             : y w)Ntracksc                      |d   xr |d   d   S )Nr   r;   r^   )_vs     rV   <lambda>z/IdagioPlaylistBaseIE._entries.<locals>.<lambda>Q   s    aPTgNnZ[\gZhimZn rX   r   r;   z"https://app.idagio.com/recordings/z	?trackId=)ievideo_id)r	   
url_resultr   r   )rR   playlist_info
track_datarS   recording_ids        rV   _entrieszIdagioPlaylistBaseIE._entriesP   so     &}xAn6op 	BJ!$'H%k248L//4\N)H:V ;x+@ " B B	Bs   AAc                     | j                  |      }| j                  | j                  j                  |      |      d   }dd| j                  |d| j                  |      i| j                  |      S )Nr9   _typeplaylistentries)rL   rM   _API_URL_TMPLr4   _PLAYLIST_ID_KEYrm   _parse_playlist_metadata)rR   r!   playlist_idrj   s       rV   rW   z"IdagioPlaylistBaseIE._real_extractX   s    nnS)++%%k2KAAIK Z!!;t}}]3
 ++M:	
 	
rX   N)rY   rZ   r[   __doc__rs   rm   rW   r^   rX   rV   r`   r`   L   s    OB

rX   r`   c                   h    e Zd ZdZddddgddgdd	gd
d
ddd	ddddddgddgdddddddgZdZd Zy)IdagioRecordingIEz`https?://(?:www\.)?app\.idagio\.com(?:/[a-z]{2})?/recordings/(?P<id>\d+)(?![^#]*[&?]trackId=\d+)z*https://app.idagio.com/recordings/3057693430576934z&Variations on an Original Theme op. 36r   r   r   r   r   r   r   )	r   r   r   r   r   r   modified_timestampmodified_dater       r!   r#   playlist_countz-https://app.idagio.com/de/recordings/2051446720514467z1Sonata for Piano No. 14 in C sharp minor op. 27/2r&   r'   r(   r)   r*   )r   r   r   r   r   r    rz   r{      z2https://api.idagio.com/v2.0/metadata/recordings/{}c                     t        |ddt        hfdt        d      hfdt        d      hfdt        hfddt        hfdd	dt        ht        fdd
dt        hfddt        hfd      S )NrG   r   r<   r=   r>   r@   rA   rE   rH   rI   tags.)r   r   rz   r@   r   r   r   r   )r	   rO   r   rQ   rR   rj   s     rV   rt   z*IdagioRecordingIE._parse_playlist_metadata   s    Mgu-&4)@(AB#/+D2I1J"K#cU+LfWZV[\ *fseSA4guES3%(	,
 	 		rX   NrY   rZ   r[   r\   r]   rr   rt   r^   rX   rV   rx   rx   e   s    tJ;=())+ST#%=>#",'%

  ?H01!#67#%",'	
 F8 IM
rX   rx   c                   p    e Zd ZdZddddddg dd	d
ddd
ddddddddg dddddddgdddgZdZd Zd! Zy")#IdagioAlbumIEzGhttps?://(?:www\.)?app\.idagio\.com(?:/[a-z]{2})?/albums/(?P<id>[\w-]+)zWhttps://app.idagio.com/albums/elgar-enigma-variations-in-the-south-serenade-for-stringsz$a9f139b8-f70d-4b8a-a9a4-5fe8d35eaf9cz9elgar-enigma-variations-in-the-south-serenade-for-stringsz<Elgar: Enigma Variations, In the South, Serenade for Strings z+re:https://.+/albums/880040420521/main\.jpg)r   r   r   i `\20190329g  HA20190708)
r   
display_idr   description	thumbnailr   r   r    rz   r{      r}   zbhttps://app.idagio.com/de/albums/brahms-ein-deutsches-requiem-3B403DF6-62D7-4A42-807B-47173F3E0192z$2862ad4e-4a61-45ad-9ce4-7fcf0c2626fezAbrahms-ein-deutsches-requiem-3B403DF6-62D7-4A42-807B-47173F3E0192zBrahms: Ein deutsches RequiemzEGRAMOPHONE CLASSICAL MUSIC AWARDS 2025 Recording of the Year & Choralz,re:https://.+/albums/3149020954522/main\.jpg)zSabine Devieilheu   Stéphane Degoutu   Raphaël Pichon	PygmalionzJohannes BrahmsiLh20251010i h20251016recommendedzrecent-release)r   r   r   r   r   r   r   r    rz   r{   r      z.https://api.idagio.com/v2.0/metadata/albums/{}r   c                     t        |dt        hfdt        hfdt        hfdt        hfdt        hfdt        hfddd	t        hfd
dt        hfd      S )Nr   r   publishDatelastModifiedimageUrlr   participants.rE   r   )r   r   r   rz   r   r   r   r   )r	   rO   r   r   r   s     rV   rt   z&IdagioAlbumIE._parse_playlist_metadata   so    M#-u%'*;)<=#14E3F"G${m4)C51&VcU;S3%(	,
 	 		rX   NrY   rZ   r[   r\   r]   rr   rs   rt   r^   rX   rV   r   r      s    [Jh8USGd#%".'
   t8]4bHr#%",'"$45
 F@ EM#
rX   r   c            	       V    e Zd ZdZdddddddgd	d
ddddddddgd	ddgZdZdZd Zy)IdagioPlaylistIEzWhttps?://(?:www\.)?app\.idagio\.com(?:/[a-z]{2})?/playlists/(?!personal/)(?P<id>[\w-]+)zIhttps://app.idagio.com/playlists/beethoven-the-most-beautiful-piano-musicz$31652bec-8c5b-460e-a3f0-cf1f69817f53z(beethoven-the-most-beautiful-piano-musicz)Beethoven: the most beautiful piano musicz$md5:d41bb04b8896bb69377f5c2cd9345ad1zFre:https://.+/playlists/31652bec-8c5b-460e-a3f0-cf1f69817f53/main\.jpgIDAGIO)r   r   r   r   r   creators   )r!   r#   playlist_mincountzAhttps://app.idagio.com/de/playlists/piano-music-for-an-autumn-dayz$d70e9c7f-7080-4308-ae0f-f890dddeda82zpiano-music-for-an-autumn-dayzPiano Music for an Autumn DayzZGet ready to snuggle up and enjoy all the musical colours of this cosy, autumnal playlist.zFre:https://.+/playlists/d70e9c7f-7080-4308-ae0f-f890dddeda82/main\.jpg#   r}   z(https://api.idagio.com/v2.0/playlists/{}r   c                 x    t        |dt        hfdt        hfdt        hfdt        hfddt        ht        fd      S )Nr   r   r   r   curatorrE   )r   r   r   r   r   )r	   rO   r   rQ   r   s     rV   rt   z)IdagioPlaylistIE._parse_playlist_metadata   sK    M#-u%${m4)C51"FSE37,
  	rX   Nr   r^   rX   rV   r   r      so    kJZ8D@Ab!

   S894wb!

 F. ?M#rX   r   c            
       D    e Zd ZdZddddgdddd	d
ddddddgZdZd Zy)IdagioPersonalPlaylistIEzVhttps?://(?:www\.)?app\.idagio\.com(?:/[a-z]{2})?/playlists/personal/(?P<id>[\da-f-]+)zNhttps://app.idagio.com/playlists/personal/99dad72e-7b3a-45a4-b216-867c08046ed8z$99dad72e-7b3a-45a4-b216-867c08046ed8Testz$1a6f16a6-4514-4d0c-b481-3a9877835626z%re:https://.+/artists/86371/main\.jpgi_ih2020101620250819)r   r   r   r   r   rz   r    r{   d   r}   zQhttps://app.idagio.com/de/playlists/personal/99dad72e-7b3a-45a4-b216-867c08046ed8Tr+   z1https://api.idagio.com/v1.0/personal-playlists/{}c                     t        |dt        hfdt        hfdt        ht        fdt	        d      hfdt	        d      hfd      S )	Nr   	image_urluser_idr<   r=   r>   
updated_at)r   r   r   r   rz   )r	   rO   r   rQ   r   r   s     rV   rt   z1IdagioPersonalPlaylistIE._parse_playlist_metadata   sV    Mu%%}5"SE3/&4)@(AB#/+D2I1J"K,
  	rX   Nr   r^   rX   rV   r   r      sV    jJ_8?@A#",%'	
  cF" HMrX   r   N)commonr   utilsr   r   r   r   utils.traversalr	   r   r`   rx   r   r   r   r^   rX   rV   <module>r      sc    ! L L *C
M C
L
= 
2*, *Z/( /d#+ #L3 rX   