
    5pj7                        % S r SSKJr  SSKrSSKrSSKrSSKJr  0 SS_SS_S	S
_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS_SS _S!S"_S#S$_S%S&0ErS'\	S('   S+S) jr
S*/rg),z.Media file encoding utilities for Hub uploads.    )annotationsN)Pathz.webpz
image/webpz.avifz
image/avifz.heicz
image/heicz.heifz
image/heifz.jpgz
image/jpegz.jpegz.pngz	image/pngz.gifz	image/gifz.bmpz	image/bmpz.svgzimage/svg+xmlz.tiffz
image/tiffz.tifz.icozimage/x-iconz.mp4z	video/mp4z.webmz
video/webmz.avizvideo/x-msvideoz.movzvideo/quicktimez.mkvzvideo/x-matroskazdict[str, str]_FALLBACK_MIME_TYPESc                ,   [        [        R                  " U 5      5      R                  5       nUR	                  5       (       d  [        SU 35      eUR                  5       (       d  [        SU 35      e[        R                  " UR                  5       5      u  p#Uc-  [        R                  UR                  R                  5       5      nUc  [        SU 35      e[        R                   " UR#                  5       5      R%                  S5      nSU SU 3$ )a  Encode a media file as a base64 data URL string.

Returns a string of the form ``data:{mime_type};base64,{data}``.

Raises:
    FileNotFoundError: if the path does not exist.
    ValueError: if the path is not a regular file or the MIME
        type cannot be determined.
zMedia file not found: zPath is not a file: z%Cannot determine MIME type for file: asciizdata:z;base64,)r   osfspath
expanduserexistsFileNotFoundErroris_file
ValueError	mimetypes
guess_typeas_posixr   getsuffixlowerbase64	b64encode
read_bytesdecode)media_file_pathpath	mime_type_encodeds        V/var/www/html/pdf-tiff/venv/lib/python3.13/site-packages/modelscope_hub/utils/media.pyencode_media_to_base64r   "   s     		/*+668D;;=="8 ?@@<<>>/v677''8LI(,,T[[->->-@A	@GHHt0188AG9+XgY//    r   )r   zstr | os.PathLikereturnstr)__doc__
__future__r   r   r   r   pathlibr   r   __annotations__r   __all__ r    r   <module>r)      s   4 "   	 (\(\( \( \	(
 L( \( K( K( K( O( \( L( N( K( \(  !(" #($ %( n ,06 $
$r    