Ë
    :É„j¬  ã                   óT   — d dl Z d dlmZmZmZ d dlZd dlmZ d dlmZ  G d„ d«      Z	y)é    N)ÚUnionÚOptionalÚBinaryIO)Útypes)ÚFileIdc                   óH   — e Zd Z	 	 d
dddedef   dededeeeef      f
d„Zy	)ÚStreamMediaÚselfzpyrogram.ClientÚmessageztypes.MessageÚlimitÚoffsetÚreturnc                óÆ  K  — d}t        |t        j                  «      r#|D ]  }t        ||d«      }|€Œ n t	        d«      ‚|}t        |t
        «      r|}n|j                  }t        j                  |«      }t        |dd«      }	|dk  r0|	dk(  rt	        d«      ‚t        j                  |	dz  dz  «      }
||
z  }| j                  ||	||«      2 3 d{  –—† }|­–— Œ7 Œ
6 y­w)as  Stream the media from a message chunk by chunk.

        You can use this method to partially download a file into memory or to selectively download chunks of file.
        The chunk maximum size is 1 MiB (1024 * 1024 bytes).

        .. include:: /_includes/usable-by/users-bots.rst

        Parameters:
            message (:obj:`~pyrogram.types.Message` | ``str``):
                Pass a Message containing the media, the media itself (message.audio, message.video, ...) or a file id
                as string.

            limit (``int``, *optional*):
                Limit the amount of chunks to stream.
                Defaults to 0 (stream the whole media).

            offset (``int``, *optional*):
                How many chunks to skip before starting to stream.
                Defaults to 0 (start from the beginning).

        Returns:
            ``Generator``: A generator yielding bytes chunk by chunk

        Example:
            .. code-block:: python

                # Stream the whole media
                async for chunk in app.stream_media(message):
                    print(len(chunk))

                # Stream the first 3 chunks only
                async for chunk in app.stream_media(message, limit=3):
                    print(len(chunk))

                # Stream the rest of the media by skipping the first 3 chunks
                async for chunk in app.stream_media(message, offset=3):
                    print(len(chunk))

                # Stream the last 3 chunks only (negative offset)
                async for chunk in app.stream_media(message, offset=-3):
                    print(len(chunk))
        )	ÚaudioÚdocumentÚphotoÚstickerÚ	animationÚvideoÚvoiceÚ
video_noteÚnew_chat_photoNz3This message doesn't contain any downloadable mediaÚ	file_sizer   zNNegative offsets are not supported for file ids, pass a Message object insteadi   )Ú
isinstancer   ÚMessageÚgetattrÚ
ValueErrorÚstrÚfile_idr   ÚdecodeÚmathÚceilÚget_file)r
   r   r   r   Úavailable_mediaÚkindÚmediaÚfile_id_strÚfile_id_objr   ÚchunksÚchunks               ú]/var/www/html/GAP/venv/lib/python3.12/site-packages/pyrogram/methods/messages/stream_media.pyÚstream_mediazStreamMedia.stream_media   sõ   è ø€ ð`-ˆô �gœuŸ}™}Ô-Ø'ò X�Ü ¨¨tÓ4�àÑ$Ùð	Xô !Ð!VÓWÐWàˆEä�eœSÔ!Ø‰KàŸ-™-ˆKä—m‘m KÓ0ˆÜ˜E ;°Ó2ˆ	à�AŠ:Ø˜AŠ~Ü Ð!qÓrÐrä—Y‘Y˜y¨4Ñ/°$Ñ6Ó7ˆFØ�fÑˆFàŸ=™=¨°iÀÈÓO÷ 	ð 	�%ØŒKð	øÑOùs/   ‚1C!´BC!ÃCÃCÃCÃC!ÃCÃC!N)r   r   )	Ú__name__Ú
__module__Ú__qualname__r   r   Úintr   r   r,   © ó    r+   r	   r	      s[   „ ð Øñ	NØðNà�¨Ð+Ñ,ðNð ðNð ð	Nð
 
�%˜˜X˜Ñ&Ñ	'ôNr2   r	   )
r!   Útypingr   r   r   Úpyrogramr   Úpyrogram.file_idr   r	   r1   r2   r+   ú<module>r6      s%   ðó( ß ,Ñ ,ã Ý Ý #÷Oò Or2   