Добавлен проверка на лок переменной SHOTMAP

This commit is contained in:
Alexey Barabanov
2025-11-26 13:16:10 +03:00
parent 101a5a09d3
commit 9aa698dcfe

View File

@@ -3237,9 +3237,11 @@ def change_vmix_datasource_urls(xml_data, new_base_url: str) -> bytes:
root = ET.fromstring(text) root = ET.fromstring(text)
# 4. Меняем URL # 4. Меняем URL
for url_tag in root.findall(".//datasource[@friendlyName='JSON']//instance//state/xml/url"): for url_tag in root.findall(
".//datasource[@friendlyName='JSON']//instance//state/xml/url"
):
old_url = url_tag.text.strip() old_url = url_tag.text.strip()
pattern = r'https?:\/\/[^\/]+' pattern = r"https?:\/\/[^\/]+"
new_url = re.sub(pattern, new_base_url, old_url, count=0, flags=0) new_url = re.sub(pattern, new_base_url, old_url, count=0, flags=0)
url_tag.text = new_url url_tag.text = new_url
@@ -3633,6 +3635,7 @@ async def get_shotmap_image(player_id_shots: str):
Отдаёт картинку карты бросков из оперативной памяти. Отдаёт картинку карты бросков из оперативной памяти.
player_id_shots должен совпадать с ключом в SHOTMAP_CACHE, например "23_shots". player_id_shots должен совпадать с ключом в SHOTMAP_CACHE, например "23_shots".
""" """
async with SHOTMAPS_LOCK:
data = SHOTMAP_CACHE.get(player_id_shots) data = SHOTMAP_CACHE.get(player_id_shots)
if not data: if not data:
raise HTTPException(status_code=404, detail="Shotmap not found in memory") raise HTTPException(status_code=404, detail="Shotmap not found in memory")
@@ -3916,7 +3919,8 @@ async def commentary():
plus_minus = p.get("plusMinus", "") plus_minus = p.get("plusMinus", "")
kpi = p.get("kpi", "") kpi = p.get("kpi", "")
rows.append(f""" rows.append(
f"""
<tr> <tr>
<td>{num}</td> <td>{num}</td>
<td class="player-name" <td class="player-name"
@@ -3939,7 +3943,8 @@ async def commentary():
<td class="extra-col">{plus_minus}</td> <td class="extra-col">{plus_minus}</td>
<td class="extra-col">{kpi}</td> <td class="extra-col">{kpi}</td>
</tr> </tr>
""") """
)
return f""" return f"""
<h3>{title}</h3> <h3>{title}</h3>