o
    Xzj…  ã                   @   s:   d dl Z d dlZddlmZ ddlmZ G dd„ dƒZdS )é    Né   )Úutils)Útypesc                   @   s°   e Zd ZdZdd„ Zedd„ ƒZedd„ ƒZedd	„ ƒZed
d„ ƒZ	edd„ ƒZ
edd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZedd„ ƒZdd„ ZdS )ÚFilea3  
    Convenience class over media like photos or documents, which
    supports accessing the attributes in a more convenient way.

    If any of the attributes are not present in the current media,
    the properties will be `None`.

    The original media is available through the ``media`` attribute.
    c                 C   s
   || _ d S ©N)Úmedia)Úselfr   © r	   úR/var/www/kodo/tsheker/venv/lib/python3.10/site-packages/telethon/tl/custom/file.pyÚ__init__   s   
zFile.__init__c                 C   s   t  | j¡S )aÕ  
        The old bot-API style ``file_id`` representing this file.

        .. warning::

            This feature has not been maintained for a long time and
            may not work. It will be removed in future versions.

        .. note::

            This file ID may not work under user accounts,
            but should still be usable by bot accounts.

            You can, however, still use it to identify
            a file in for example a database.
        )r   Úpack_bot_file_idr   ©r   r	   r	   r
   Úid   s   zFile.idc                 C   ó   |   tjd¡S )z1
        The file name of this document.
        Ú	file_name)Ú
_from_attrr   ÚDocumentAttributeFilenamer   r	   r	   r
   Úname)   ó   z	File.namec                 C   s&   t  | j¡ptj | jpd¡d pdS )z¦
        The extension from the mime type of this file.

        If the mime type is unknown, the extension
        from the file name (if any) will be used.
        Ú éÿÿÿÿN)Ú	mimetypesÚguess_extensionÚ	mime_typeÚosÚpathÚsplitextr   r   r	   r	   r
   Úext0   s
   	ÿýzFile.extc                 C   s,   t | jtjƒr	dS t | jtjƒr| jjS dS )z-
        The mime-type of this file.
        z
image/jpegN)Ú
isinstancer   r   ÚPhotoÚDocumentr   r   r	   r	   r
   r   >   s
   ÿzFile.mime_typec                 C   ó8   t | jtjƒrtdd„ | jjD ƒƒS |  tjtjfd¡S )zO
        The width in pixels of this media if it's a photo or a video.
        c                 s   ó   � | ]	}t |d dƒV  qdS )Úwr   N©Úgetattr©Ú.0Úsr	   r	   r
   Ú	<genexpr>N   ó   € zFile.width.<locals>.<genexpr>r#   ©	r   r   r   r   ÚmaxÚsizesr   ÚDocumentAttributeImageSizeÚDocumentAttributeVideor   r	   r	   r
   ÚwidthH   ó   ÿÿz
File.widthc                 C   r!   )zP
        The height in pixels of this media if it's a photo or a video.
        c                 s   r"   )Úhr   Nr$   r&   r	   r	   r
   r)   Y   r*   zFile.height.<locals>.<genexpr>r2   r+   r   r	   r	   r
   ÚheightS   r1   zFile.heightc                 C   s   |   tjtjfd¡S )z@
        The duration in seconds of the audio or video.
        Úduration)r   r   ÚDocumentAttributeAudior/   r   r	   r	   r
   r4   ^   s
   ÿÿzFile.durationc                 C   r   )z(
        The title of the song.
        Útitle©r   r   r5   r   r	   r	   r
   r6   f   r   z
File.titlec                 C   r   )z,
        The performer of the song.
        Ú	performerr7   r   r	   r	   r
   r8   m   r   zFile.performerc                 C   r   )zM
        A string with all emoji that represent the current sticker.
        Úalt©r   r   ÚDocumentAttributeStickerr   r	   r	   r
   Úemojit   r   z
File.emojic                 C   r   )zN
        The :tl:`InputStickerSet` to which the sticker file belongs.
        Ú
stickersetr:   r   r	   r	   r
   Ústicker_set{   r   zFile.sticker_setc                 C   sF   t | jtjƒrttdttj| jj	ƒƒdd�S t | jtj
ƒr!| jjS dS )z–
        The size in bytes of this file.

        For photos, this is the heaviest thumbnail, as it often repressents the largest dimensions.
        N)Údefault)r   r   r   r   r,   ÚfilterÚmapr   Ú_photo_size_byte_countr-   r    Úsizer   r	   r	   r
   rC   ‚   s
   ÿz	File.sizec                 C   s>   t | jtjƒr| jjD ]}t ||ƒrt||d ƒ  S qd S d S r   )r   r   r   r    Ú
attributesr%   )r   ÚclsÚfieldÚattrr	   r	   r
   r   Ž   s   
ÿþzFile._from_attrN)Ú__name__Ú
__module__Ú__qualname__Ú__doc__r   Úpropertyr   r   r   r   r0   r3   r4   r6   r8   r<   r>   rC   r   r	   r	   r	   r
   r      s8    	



	









r   )r   r   r   r   Útlr   r   r	   r	   r	   r
   Ú<module>   s
    