From 2770ae1ccc110639e9fa65765e8a354305968ea8 Mon Sep 17 00:00:00 2001 From: John Doe Date: Fri, 12 Jun 2026 12:15:31 +0300 Subject: [PATCH] fix: now supports video / gif baners --- Limoka.py | 9 ++++++--- LimokaLegacy.py | 6 +++++- 2 files changed, 11 insertions(+), 4 deletions(-) diff --git a/Limoka.py b/Limoka.py index 02054a6..8bd5de2 100644 --- a/Limoka.py +++ b/Limoka.py @@ -37,7 +37,7 @@ from .. import utils, loader from ..types import BotInlineCall, InlineCall logger = logging.getLogger("Limoka") -__version__ = (1, 5, 5) +__version__ = (1, 5, 6) def _parse_version_from_source(source: str): @@ -879,6 +879,9 @@ class Limoka(loader.Module): except (aiohttp.ClientError, asyncio.TimeoutError) as head_error: logger.debug(f"_validate_url: HEAD failed ({type(head_error).__name__}), will try GET for {url}") + def _is_supported_media(content_type: str) -> bool: + return content_type.startswith("image/") or content_type.startswith("video/mp4") + # If HEAD didn't work or returned non-200, try GET if ct is None: max_retries = 2 @@ -897,7 +900,7 @@ class Limoka(loader.Module): try: data = await response.content.read(2048) mime = filetype.guess_mime(data, mime=True) - if mime and mime.startswith("image/"): + if mime and _is_supported_media(mime): return url else: self._invalid_banners.add(url) @@ -913,7 +916,7 @@ class Limoka(loader.Module): return None # Check Content-Type from successful request - if ct and ct.startswith("image/"): + if ct and _is_supported_media(ct): return url elif ct: self._invalid_banners.add(url) diff --git a/LimokaLegacy.py b/LimokaLegacy.py index 9d85bbd..3034b40 100644 --- a/LimokaLegacy.py +++ b/LimokaLegacy.py @@ -523,6 +523,10 @@ class Limoka(loader.Module): async def _validate_url(self, url: str) -> Optional[str]: if not url or url in self._invalid_banners: return None + + def _is_supported_media(content_type: str) -> bool: + return content_type.startswith("image/") or content_type.startswith("video/mp4") + try: async with aiohttp.ClientSession() as session: async with session.head( @@ -532,7 +536,7 @@ class Limoka(loader.Module): self._invalid_banners.add(url) return None ct = response.headers.get("Content-Type", "").lower() - if not ct.startswith("image/"): + if not _is_supported_media(ct): self._invalid_banners.add(url) return None return url