новый файл для скрипта создал
This commit is contained in:
44
app.py
44
app.py
@@ -14,6 +14,7 @@ from fastapi.responses import (
|
|||||||
JSONResponse,
|
JSONResponse,
|
||||||
RedirectResponse,
|
RedirectResponse,
|
||||||
StreamingResponse,
|
StreamingResponse,
|
||||||
|
PlainTextResponse,
|
||||||
)
|
)
|
||||||
from fastapi.templating import Jinja2Templates
|
from fastapi.templating import Jinja2Templates
|
||||||
from fastapi.staticfiles import StaticFiles
|
from fastapi.staticfiles import StaticFiles
|
||||||
@@ -2011,6 +2012,49 @@ def vmix_match_events(session_token: str):
|
|||||||
return new_events
|
return new_events
|
||||||
|
|
||||||
|
|
||||||
|
def _build_goal_authors_text(match_id: int) -> str:
|
||||||
|
"""Возвращает авторов голов в 2 строки для текстового Data Source vMix.
|
||||||
|
|
||||||
|
1-я строка — голы первой команды, 2-я строка — голы второй команды.
|
||||||
|
Авторы внутри строки разделяются символом |.
|
||||||
|
"""
|
||||||
|
events = get_vmix_players_goal(match_id)
|
||||||
|
|
||||||
|
home_authors = []
|
||||||
|
away_authors = []
|
||||||
|
|
||||||
|
for home_goal, away_goal in events:
|
||||||
|
home_goal = (home_goal or "").strip()
|
||||||
|
away_goal = (away_goal or "").strip()
|
||||||
|
|
||||||
|
if home_goal:
|
||||||
|
home_authors.append(home_goal)
|
||||||
|
if away_goal:
|
||||||
|
away_authors.append(away_goal)
|
||||||
|
|
||||||
|
return "|".join(home_authors) + "\n" + "|".join(away_authors)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/vmix/session/{session_token}/goal-authors.txt", response_class=PlainTextResponse)
|
||||||
|
def vmix_goal_authors_txt(session_token: str):
|
||||||
|
session_row = get_match_session_by_token(session_token)
|
||||||
|
if not session_row:
|
||||||
|
return PlainTextResponse("session_not_found", status_code=404)
|
||||||
|
|
||||||
|
text = _build_goal_authors_text(session_row[1])
|
||||||
|
return PlainTextResponse(
|
||||||
|
text,
|
||||||
|
media_type="text/plain; charset=utf-8",
|
||||||
|
headers={
|
||||||
|
"Cache-Control": "no-store, no-cache, must-revalidate, max-age=0",
|
||||||
|
"Pragma": "no-cache",
|
||||||
|
},
|
||||||
|
)
|
||||||
|
|
||||||
|
|
||||||
|
@app.get("/vmix/session/{session_token}/goal-authors", response_class=PlainTextResponse)
|
||||||
|
def vmix_goal_authors_text(session_token: str):
|
||||||
|
return vmix_goal_authors_txt(session_token)
|
||||||
|
|
||||||
|
|
||||||
@app.get("/vmix/session/{session_token}/penalties")
|
@app.get("/vmix/session/{session_token}/penalties")
|
||||||
|
|||||||
Reference in New Issue
Block a user