
    yf	                     V    d dl Z ddlmZ ddlmZ ddlmZmZmZm	Z	m
Z
  G d de      Zy)	    N   )PostProcessor   )compat_os_name)PostProcessingErrorXAttrMetadataErrorXAttrUnavailableErrorhyphenate_datewrite_xattrc                   (    e Zd ZdZdddddddZd	 Zy
)XAttrMetadataPPa  Set extended attributes on downloaded file (if xattr support is found)

    More info about extended attributes for media:
        http://freedesktop.org/wiki/CommonExtendedAttributes/
        http://www.freedesktop.org/wiki/PhreedomDraft/
        http://dublincore.org/documents/usageguide/elements.shtml

    TODO:
        * capture youtube keywords and put them in 'user.dublincore.subject' (comma-separated)
        * figure out which xattrs can be used for 'duration', 'thumbnail', 'resolution'
    webpage_urltitleupload_datedescriptionuploaderformat)zuser.xdg.referrer.urlzuser.dublincore.titlezuser.dublincore.datezuser.dublincore.descriptionzuser.dublincore.contributorzuser.dublincore.formatc                    t        j                  |d         j                  }| j                  d       	 | j                  j                         D ]G  \  }}|j                  |      }|s|dk(  rt        |      }t        |d   ||j                                I 	 | j#                  |d   ||       g |fS # t        $ r}t        t        |            d }~wt        $ rg}|j                  dk(  r| j                  d       n<|j                  dk(  r| j                  d       nt         dk(  rd	nd
}t        d|       Y d }~d }~ww xY w)Nfilepathz!Writing metadata to file's xattrsr   NO_SPACEz|There's no disk space left, disk quota exceeded or filesystem xattr limit exceeded. Some extended attributes are not writtenVALUE_TOO_LONGz;Unable to write extended attributes due to too long values.ntzYou need to use NTFSz0You may have to enable them in your "/etc/fstab"z5This filesystem doesn't support extended attributes. )osstatst_mtime	to_screenXATTR_MAPPINGitemsgetr
   r   encoder	   r   strr   reasonreport_warningr   	try_utime)selfinfomtime	xattrnameinfonamevalueetips           >/usr/lib/python3/dist-packages/yt_dlp/postprocessor/xattrpp.pyrunzXAttrMetadataPP.run%   s@   Z()22;<	j'+'9'9'?'?'A M#	8*=0 .u 5Z 0)U\\^LM* 	tJ'64x % 	.%c!f--! 
	jxx:%##?@ --##$ab1?41G-N ),bcfbg*hii
	js*   3B4 )0B4 4	E=CEAD??EN)__name__
__module____qualname____doc__r   r.        r-   r   r      s'    
 "/!( -'4'1"*Mr4   r   )r   commonr   compatr   utilsr   r   r	   r
   r   r   r3   r4   r-   <module>r8      s$    	 ! # 1m 1r4   