from ..services import Episode, RenderData
from .base_renderer import BaseRenderer
from .pillow.episode_card import draw_episode_card


class EpisodeRenderer(BaseRenderer):
    async def render_episode(
        self,
        episode_data: Episode,
        rpc_url: str | None = None,
        headless: bool = True,
        max_retries: int = 3,
    ) -> str | None:
        render_data: RenderData = episode_data.model_dump()
        return await self.render(
            template_path="update/episode.html",
            render_data=render_data,
            selector="#card-container",
            local_render_func=lambda: draw_episode_card(render_data, self._session),
            rpc_url=rpc_url,
            timeout=30000,
        )
