3
äb`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   sV  | j jdƒ |d }ypddddddd	œ}d
}xP|jƒ D ]D\}}|j|ƒ}|r6|dkr\t|ƒ}|jdƒ}t|||ƒ |d7 }q6W g |fS  tk
r¸ }	 z| j jt	|	ƒƒ g |fS d}	~	X nš t
k
�rP }	 z||	jdk� rø| j jd|rædndd jƒ  ƒ nF|	jdk�r| j jdƒ n,d}
tdk�r*|
d7 }
n|
d7 }
| j j|
ƒ g |fS d}	~	X 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'   úQC:\Users\Broad\Desktop\BeinConnetFix\binaries\youtube_dl\postprocessor\xattrpp.pyÚrun   sH    



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   