
    bf                     ^    d dl Z ddlmZ ddlmZmZ ddlmZ ddlm	Z
  G d de
          Z	dS )	    N   )_DICT_VERSION_MEDIA)MastodonVersionErrorMastodonAPIError)api_version)Mastodonc                       e Zd Z edde          d             Z edde          d
d            Z edde          dd	            ZdS )r   3.1.4c                 ^    |                      |          }|                     dd|           S )z
        Get the updated JSON for one non-attached / in progress media upload belonging
        to the logged-in user.
        GET/api/v1/media/)_Mastodon__unpack_id_Mastodon__api_request)selfids     \/home/feoh/.local/pipx/venvs/mastodon-archive/lib/python3.11/site-packages/mastodon/media.pymediazMastodon.media   s6     b!!!!%)>")>)>???    z1.0.03.2.0NFc	                 b   d|                      |||          i}	||d          d|d          }|?|                     dd          st          d	          |                      ||          |	d
<   |                     dd          r|                     dd|	||d          }
n|                     dd|	||d          }
|rm|                     d          rVd|
vs|
j        J	 |                     |
          }
t          j        d           n#  t          d          xY wd|
vC|
j        Jn|
S |
S )a  
        Post an image, video or audio file. `media_file` can either be data or
        a file name. If data is passed directly, the mime type has to be specified
        manually, otherwise, it is determined from the file name. `focus` should be a tuple
        of floats between -1 and 1, giving the x and y coordinates of the images
        focus point for cropping (with the origin being the images center).

        Throws a `MastodonIllegalArgumentError` if the mime type of the
        passed data or file can not be determined properly.

        `file_name` can be specified to upload a file with the given name,
        which is ignored by Mastodon, but some other Fediverse server software
        will display it. If no name is specified, a random name will be generated.
        The filename of a file specified in media_file will be ignored.

        Starting with Mastodon 3.2.0, `thumbnail` can be specified in the same way as `media_file`
        to upload a custom thumbnail image for audio and video files.

        Returns a :ref:`media dict <media dict>`. This contains the id that can be used in
        status_post to attach the media file to a toot.

        When using the v2 API (post Mastodon version 3.1.4), the `url` in the
        returned dict will be `null`, since attachments are processed
        asynchronously. You can fetch an updated dict using `media`. Pass
        "synchronous" to emulate the old behaviour. Not recommended, inefficient
        and deprecated, will eat your API quota, you know the deal.
        fileNr   ,r   r   Tcached"Thumbnail requires version > 3.2.0	thumbnailr
   POSTz/api/v2/media)descriptionfocus)filesparamsz/api/v1/mediaurlg      @z!Attachment could not be processed)	_Mastodon__load_media_fileverify_minimum_versionr   r   r"   r   timesleepr   )r   
media_file	mime_typer   r   	file_namer   thumbnail_mime_typesynchronousr    ret_dicts              r   
media_postzMastodon.media_post   s   : //	9. . / Qx,,%(,,E ..wt.DD Q*+OPPP!%!7!7."0 "0E+ &&wt&<< 	k))u[ch=i=i * k kHH ))u[ch=i=i * k kH  
	 **733 	 8++x|/CT#'::h#7#7
3T./RSSS  8++x|/C  s   #)D Dz2.3.0c                    |                      |          }||d          d|d          }|                     t                      g d          }|Z|                     dd          st	          d	          d
|                     ||          i}|                     dd| ||          S |                     dd| |          S )z
        Update the metadata of the media file with the given `id`. `description` and
        `focus` and `thumbnail` are as in :ref:`media_post() <media_post()>` .

        Returns the updated :ref:`media dict <media dict>`.
        Nr   r   r   )r   r   r*   r   Tr   r   r   PUTr   )r    )r   _Mastodon__generate_paramslocalsr$   r   r#   r   )r   r   r   r   r   r*   r!   r    s           r   media_updatezMastodon.media_update\   s     b!!Qx,,%(,,E''HH@@@B B  ..wt.DD Q*+OPPP $"8"8.#0 #0 1E%%e-Bb-B-BFRW%XXX%%e-Bb-B-BFKKKr   )NNNNNNF)NNNN)__name__
__module____qualname__r   r   r   r-   r2    r   r   r   r      s         ['#677@ @ 87@ ['#677= = = 87=~ ['#677L L L 87L L Lr   r   )r%   versionsr   errorsr   r   utilityr   	internalsr   	Internalsr6   r   r   <module>r<      s     ) ) ) ) ) ) : : : : : : : :             , , , , , ,gL gL gL gL gLy gL gL gL gL gLr   