o
    i                     @   sL   d dl Z d dlZddlmZ ddlmZmZmZmZm	Z	 G dd deZ
dS )    N   )PostProcessor   )PostProcessingErrorXAttrMetadataErrorXAttrUnavailableErrorhyphenate_datewrite_xattrc                   @   s0   e Zd ZdZddddddddZd	Zd
d ZdS )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uploaderformatdescription)zuser.xdg.referrer.urlzuser.dublincore.titlezuser.dublincore.datezuser.dublincore.contributorzuser.dublincore.formatzuser.dublincore.description$com.apple.metadata:kMDItemWhereFromsz<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<array>
	<string>%s</string>
</array>
</plist>c                 C   sB  t |d j}| d | j D ]\}}z,||}|rA|dkr't|}n|dkr7tj	dkr2W q| j
| }t|d ||  W q tyT } ztt|d }~w ty } z4|jdkrj| d| d n|jd	kry| d
| d nt jdkrdnd}td| W Y d }~qd }~ww | |d || g |fS )Nfilepathz!Writing metadata to file's xattrsr   r   darwinNO_SPACEzhThere's no disk space left, disk quota exceeded or filesystem xattr limit exceeded. Extended attribute "z" was not written.VALUE_TOO_LONGz$Unable to write extended attribute "z" 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   sysplatformAPPLE_PLIST_TEMPLATEr	   encoder   r   strr   reasonreport_warningname	try_utime)selfinfomtime	xattrnameinfonamevalueetip r/   P/home/ubuntu/.local/lib/python3.10/site-packages/yt_dlp/postprocessor/xattrpp.pyrun0   sD   






zXAttrMetadataPP.runN)__name__
__module____qualname____doc__r   r    r1   r/   r/   r/   r0   r
      s    r
   )r   r   commonr   utilsr   r   r   r   r	   r
   r/   r/   r/   r0   <module>   s
    	