
    AF[i`                        d Z ddlZddlmZ ddlmZ  ee      j                  dz  Zedz  edz  edz  ed	z  ed
z  gZ	dde
dee
   de
fdZddee
   de
fdZddee
   de
fdZddee
   de
fdZddee
   de
fdZddee
   de
fdZy)a2  
Media Registry for Gradio Demos

This module provides a centralized way to access media files.

Usage:
    from gradio.media import get_image, get_video, get_audio, get_model3d, get_file

    # Get specific media files
    cheetah_img = get_image("cheetah1.jpg")
    world_video = get_video("world.mp4")
    cantina_audio = get_audio("cantina.wav")
    bunny_model = get_model3d("Bunny.obj")
    titanic_data = get_file("titanic.csv")

    # Get random media of a type
    random_img = get_image()
    random_video = get_video()
    random_audio = get_audio()

    N)Path)Optionalmedia_assetsimagesvideosaudiomodels3ddata
media_typefilenamereturnc                 r   t         | z  }|j                         st        d|       |@t        |j	                  d            }|st        d|       t        j                  |      }n|j                  d      r|S ||z  }|j                         st        d|       t        |j                               S )a  
    Internal function to get the path to a media file.

    Args:
        media_type: Type of media (images, videos, audio, models3d, data)
        filename: Optional filename of the media file. If None, returns a random file.

    Returns:
        Absolute path to the media file

    Raises:
        ValueError: If media_type is invalid
        FileNotFoundError: If the media file doesn't exist
    zMedia directory not found: *zNo media files found in )zhttp://zhttps://zMedia file not found: )
MEDIA_ROOTexists
ValueErrorlistglobrandomchoice
startswithFileNotFoundErrorstrabsolute)r   r   	media_dirmedia_files	file_paths        U/var/www/html/chatbot/moweb-chatbot/venv/lib/python3.12/site-packages/gradio/media.py_get_media_pathr   %   s     Z'I6ykBCC9>>#./7	{CDDMM+.	67O(	"8 DEEy!!#$$    c                     t        d|       S )a7  
    Get path to an image file.

    Args:
        filename: Filename of the image (e.g., "tower.jpg"). If None, returns a random image.

    Returns:
        Absolute path to the image file

    Examples:
        >>> get_image("tower.jpg")  # Get specific image
        >>> get_image()  # Get random image
    r   r   r   s    r   	get_imager$   K        8X..r    c                     t        d|       S )a6  
    Get path to a video file.

    Args:
        filename: Filename of the video (e.g., "world.mp4"). If None, returns a random video.

    Returns:
        Absolute path to the video file

    Examples:
        >>> get_video("world.mp4")  # Get specific video
        >>> get_video()  # Get random video
    r   r"   r#   s    r   	get_videor'   \   r%   r    c                     t        d|       S )a@  
    Get path to an audio file.

    Args:
        filename: Filename of the audio (e.g., "cantina.wav"). If None, returns a random audio file.

    Returns:
        Absolute path to the audio file

    Examples:
        >>> get_audio("cantina.wav")  # Get specific audio
        >>> get_audio()  # Get random audio
    r   r"   r#   s    r   	get_audior)   m   s     7H--r    c                     t        d|       S )aD  
    Get path to a 3D model file.

    Args:
        filename: Filename of the 3D model (e.g., "Duck.glb"). If None, returns a random model.

    Returns:
        Absolute path to the 3D model file

    Examples:
        >>> get_model3d("Duck.glb")  # Get specific model
        >>> get_model3d()  # Get random 3D model
    r	   r"   r#   s    r   get_model3dr+   ~   s     :x00r    c                     t        d|       S )aT  
    Get path to a data file (CSV, JSON, text, etc.).

    Args:
        filename: Filename of the data file (e.g., "titanic.csv"). If None, returns a random file.

    Returns:
        Absolute path to the data file

    Examples:
        >>> get_file("titanic.csv")  # Get specific file
        >>> get_file()  # Get random data file
    r
   r"   r#   s    r   get_filer-      s     68,,r    )N)__doc__r   pathlibr   typingr   __file__parentr   MEDIA_PATHSr   r   r$   r'   r)   r+   r-    r    r   <module>r5      s   ,   (^""^3
#% #%x} #% #%L/ / /"/ / /". . ."1(3- 13 1"-x} - -r    