U
    y^n                     @   sP   d dl mZ ddlmZ ddlmZ ddlmZmZm	Z	m
Z
 G dd deZd	S )
    )unicode_literals   )PostProcessor   )compat_os_name)hyphenate_datewrite_xattrXAttrMetadataErrorXAttrUnavailableErrorc                   @   s   e Zd Zdd ZdS )XAttrMetadataPPc              
   C   sh  | j d |d }znddddddd	}d
}| D ]D\}}||}|r4|dkrZt|}|d}t||| |d7 }q4g |fW S  tk
r }	 z | j t	|	 g |f W Y S d}	~	X Y n t
k
rb }	 z|	jdkr | j d|rdndd    nF|	jdkr| j d n,d}
tdkr2|
d7 }
n|
d7 }
| j |
 g |f W Y S d}	~	X Y nX dS )zI Set extended attributes on downloaded file (if xattr support is found). z,[metadata] Writing metadata to file's xattrsfilepath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.formatr   zutf-8r   NNO_SPACEzTThere's no disk space left, disk quota exceeded or filesystem xattr limit exceeded. zSome  z$extended attributes are not written.VALUE_TOO_LONGz;Unable to write extended attributes due to too long values.z5This filesystem doesn't support extended attributes. ntzYou need to use NTFS.z0(You may have to enable them in your /etc/fstab))_downloader	to_screenitemsgetr   encoder   r
   report_errorstrr	   reasonreport_warning
capitalizer   )selfinfofilenameZxattr_mappingZnum_writtenZ	xattrnameZinfonamevalueZ
byte_valueemsg r'   SC:\Users\TaGoRe\Desktop\beinconnect-dl\binaries\youtube_dl\postprocessor\xattrpp.pyrun   sP    






zXAttrMetadataPP.runN)__name__
__module____qualname__r)   r'   r'   r'   r(   r      s   r   N)
__future__r   commonr   compatr   utilsr   r   r	   r
   r   r'   r'   r'   r(   <module>   s   