-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmedia_engine_client.py
More file actions
40 lines (36 loc) · 1.43 KB
/
media_engine_client.py
File metadata and controls
40 lines (36 loc) · 1.43 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
import requests
from typing import Optional, Dict, Any
class MediaEngineClient:
def __init__(self, base_url: str = "http://localhost:5000"):
self.base_url = base_url
def get_current_track(self) -> Optional[Dict[str, Any]]:
"""Получить информацию о текущем треке"""
try:
response = requests.get(f"{self.base_url}/api/track", timeout=2)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Error getting track: {e}")
return None
def set_delay(self, delay_ms: int) -> bool:
"""Установить задержку в миллисекундах"""
try:
response = requests.post(
f"{self.base_url}/api/delay",
params={"delayMs": delay_ms},
timeout=2
)
response.raise_for_status()
return True
except Exception as e:
print(f"Error setting delay: {e}")
return False
def get_status(self) -> Optional[Dict[str, Any]]:
"""Получить статус сервиса"""
try:
response = requests.get(f"{self.base_url}/api/status", timeout=2)
response.raise_for_status()
return response.json()
except Exception as e:
print(f"Error getting status: {e}")
return None