U
    Vh                     @   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	   [/var/www/html/arya_register/venvv2/lib/python3.8/site-packages/telethonv2/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   s   |  tjdS )z1
        The file name of this document.
        	file_name)
_from_attrr   DocumentAttributeFilenamer   r	   r	   r
   name)   s    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   s8   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   s   | ]}t |d dV  qdS )wr   Ngetattr.0sr	   r	   r
   	<genexpr>N   s     zFile.width.<locals>.<genexpr>r   	r   r   r   r   maxsizesr   DocumentAttributeImageSizeDocumentAttributeVideor   r	   r	   r
   widthH   s     z
File.widthc                 C   s8   t | jtjr$tdd | jjD S | tjtjfdS )zP
        The height in pixels of this media if it's a photo or a video.
        c                 s   s   | ]}t |d dV  qdS )hr   Nr    r"   r	   r	   r
   r%   Y   s     zFile.height.<locals>.<genexpr>r,   r&   r   r	   r	   r
   heightS   s     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
   r.   ^   s     zFile.durationc                 C   s   |  tjdS )z(
        The title of the song.
        titler   r   r/   r   r	   r	   r
   r0   f   s    z
File.titlec                 C   s   |  tjdS )z,
        The performer of the song.
        	performerr1   r   r	   r	   r
   r2   m   s    zFile.performerc                 C   s   |  tjdS )zM
        A string with all emoji that represent the current sticker.
        altr   r   DocumentAttributeStickerr   r	   r	   r
   emojit   s    z
File.emojic                 C   s   |  tjdS )zN
        The :tl:`InputStickerSet` to which the sticker file belongs.
        
stickersetr4   r   r	   r	   r
   sticker_set{   s    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
rB| 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
   r=      s    z	File.sizec                 C   s:   t | jtjr6| jjD ]}t ||rt||d   S q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   r+   r-   r.   r0   r2   r6   r8   r=   r   r	   r	   r	   r
   r      s6   	



	









r   )r   r   r   r   tlr   r   r	   r	   r	   r
   <module>   s   