Skip to content

StreamerResource

StreamerResource

Streamer management — screenshots and OCR for PiKVM.

Source code in src/aiopikvm/resources/streamer.py
class StreamerResource(BaseResource):
    """Streamer management — screenshots and OCR for PiKVM."""

    async def get_state(self) -> StreamerState:
        """Get the current streamer state.

        Returns:
            Current streamer subsystem state.
        """
        result = await self._get("/api/streamer")
        return StreamerState.model_validate(result)

    async def snapshot(self) -> bytes:
        """Take a JPEG screenshot.

        Returns:
            Raw JPEG image bytes.
        """
        response = await self._get_raw("/api/streamer/snapshot", accept="image/jpeg")
        return response.content

    async def ocr(self) -> str:
        """Perform OCR on the current screen.

        Returns:
            Recognized text.
        """
        result = await self._get("/api/streamer/ocr")
        return OCRResult.model_validate(result).ocr

    async def delete_snapshot(self) -> None:
        """Delete the cached snapshot."""
        await self._delete("/api/streamer/snapshot")

get_state() async

Get the current streamer state.

Returns:

Type Description
StreamerState

Current streamer subsystem state.

Source code in src/aiopikvm/resources/streamer.py
async def get_state(self) -> StreamerState:
    """Get the current streamer state.

    Returns:
        Current streamer subsystem state.
    """
    result = await self._get("/api/streamer")
    return StreamerState.model_validate(result)

snapshot() async

Take a JPEG screenshot.

Returns:

Type Description
bytes

Raw JPEG image bytes.

Source code in src/aiopikvm/resources/streamer.py
async def snapshot(self) -> bytes:
    """Take a JPEG screenshot.

    Returns:
        Raw JPEG image bytes.
    """
    response = await self._get_raw("/api/streamer/snapshot", accept="image/jpeg")
    return response.content

ocr() async

Perform OCR on the current screen.

Returns:

Type Description
str

Recognized text.

Source code in src/aiopikvm/resources/streamer.py
async def ocr(self) -> str:
    """Perform OCR on the current screen.

    Returns:
        Recognized text.
    """
    result = await self._get("/api/streamer/ocr")
    return OCRResult.model_validate(result).ocr

delete_snapshot() async

Delete the cached snapshot.

Source code in src/aiopikvm/resources/streamer.py
async def delete_snapshot(self) -> None:
    """Delete the cached snapshot."""
    await self._delete("/api/streamer/snapshot")