MCPcopy Index your code
hub / github.com/AstrBotDevs/AstrBot / open

Method open

astrbot/core/utils/media_utils.py:869–882  ·  view source on GitHub ↗

Open resolved media as a file object inside a cleanup context.

(
        self,
        mode: str = "rb",
        *,
        target_format: str | None = None,
        preserve_mp3: bool = False,
    )

Source from the content-addressed store, hash-verified

867
868 @asynccontextmanager
869 async def open(
870 self,
871 mode: str = "rb",
872 *,
873 target_format: str | None = None,
874 preserve_mp3: bool = False,
875 ):
876 """Open resolved media as a file object inside a cleanup context."""
877 async with self.as_path(
878 target_format=target_format,
879 preserve_mp3=preserve_mp3,
880 ) as resolved:
881 with resolved.open(mode) as file_obj:
882 yield file_obj
883
884
885async def resolve_image_ref_to_base64_data(

Callers 15

_download_fileMethod · 0.45
openMethod · 0.45
detect_image_mime_typeFunction · 0.45
ensure_jpegFunction · 0.45
convert_image_to_jpegFunction · 0.45
_compress_image_syncFunction · 0.45
_exceeds_max_sizeFunction · 0.45
tencent_silk_to_wavFunction · 0.45
wav_to_tencent_silkFunction · 0.45
load_imageMethod · 0.45
_load_plugin_metadataMethod · 0.45
_load_plugin_i18nMethod · 0.45

Calls 1

as_pathMethod · 0.95