Files
maxapi/maxapi/methods/get_video.py
2025-07-25 00:52:16 +03:00

50 lines
1.3 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

from typing import TYPE_CHECKING
from ..types.attachments.video import Video
from ..enums.http_method import HTTPMethod
from ..enums.api_path import ApiPath
from ..connection.base import BaseConnection
if TYPE_CHECKING:
from ..bot import Bot
class GetVideo(BaseConnection):
"""
Класс для получения информации о видео по его токену.
Args:
bot (Bot): Экземпляр бота для выполнения запроса.
video_token (str): Токен видео для запроса.
"""
def __init__(
self,
bot: 'Bot',
video_token: str
):
self.bot = bot
self.video_token = video_token
async def fetch(self) -> Video:
"""
Выполняет GET-запрос для получения данных видео по токену.
Returns:
Video: Объект с информацией о видео.
"""
if self.bot is None:
raise RuntimeError('Bot не инициализирован')
return await super().request(
method=HTTPMethod.GET,
path=ApiPath.VIDEOS.value + '/' + self.video_token,
model=Video,
params=self.bot.params,
)