From 2b3c882d258e75c4353f3021b196d437f819f3a7 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=D0=AE=D1=80=D0=B8=D0=B9=20=D0=A7=D0=B5=D1=80=D0=BD=D0=B5?= =?UTF-8?q?=D0=BD=D0=BA=D0=BE?= Date: Sat, 4 Jul 2026 10:15:55 +0300 Subject: [PATCH] =?UTF-8?q?=D0=B7=D0=B0=D0=BC=D0=B5=D0=BD=D0=B0=20url=20?= =?UTF-8?q?=D0=B4=D0=BB=D1=8F=20=D1=82=D0=B5=D0=BA=D1=81=D1=82=D0=BE=D0=B2?= =?UTF-8?q?=D0=BE=D0=B3=D0=BE=20=D0=B4=D0=B0=D1=82=D0=B0=D1=81=D0=BE=D1=80?= =?UTF-8?q?=D1=81=D0=B0?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- vmix/vmix_service.py | 25 ++++++++++++++----------- 1 file changed, 14 insertions(+), 11 deletions(-) diff --git a/vmix/vmix_service.py b/vmix/vmix_service.py index 65b09c4..6dc4067 100644 --- a/vmix/vmix_service.py +++ b/vmix/vmix_service.py @@ -25,7 +25,6 @@ def get_syno_settings() -> tuple[str | None, str | None, str | None]: ) - def normalize_source_key(source_key: str | None) -> str: return str(source_key or "").upper().strip() @@ -144,10 +143,11 @@ def change_vmix_datasource_urls( text = raw_bytes.decode("utf-8", errors="replace") root = ET.fromstring(text) - - for url_tag in root.findall( + url_tags = root.findall( ".//datasource[@friendlyName='JSON']//instance//state/xml/url" - ): + ) + root.findall(".//datasource[@friendlyName='Text']//instance//state/xml/url") + + for url_tag in url_tags: old_url = (url_tag.text or "").strip() url_tag.text = rebuild_vmix_url(old_url, new_base_url, session_token) @@ -159,7 +159,6 @@ def change_vmix_datasource_urls( if dynamic is None: dynamic = ET.SubElement(dynamic_settings, "Dynamic") - def get_or_create_dynamic_value(index: int): values = dynamic.findall("DynamicValue") @@ -171,7 +170,6 @@ def change_vmix_datasource_urls( return values[index] - # value1 = session get_or_create_dynamic_value(0).text = str(session_token) @@ -179,15 +177,18 @@ def change_vmix_datasource_urls( get_or_create_dynamic_value(1).text = "" if match_id is None else str(match_id) # value3 = source_key (SUPERLEAGUE / RUSSIAN_CUP) - get_or_create_dynamic_value(2).text = "" if not source_key else normalize_source_key(source_key) + get_or_create_dynamic_value(2).text = ( + "" if not source_key else normalize_source_key(source_key) + ) # value4 = operator_login - get_or_create_dynamic_value(3).text = "" if not operator_login else str(operator_login) + get_or_create_dynamic_value(3).text = ( + "" if not operator_login else str(operator_login) + ) return ET.tostring(root, encoding="utf-8", method="xml") - def build_vmix_project_bytes( session_token: str, match_id: str | int | None = None, @@ -197,7 +198,9 @@ def build_vmix_project_bytes( source_key = normalize_source_key(source_key) vmix_preset_path = get_vmix_preset_path(source_key) if not vmix_preset_path: - raise RuntimeError("Не задан путь к vMix-пресету: SYNO_PATH_VMIX или SYNO_PATH_VMIX_2") + raise RuntimeError( + "Не задан путь к vMix-пресету: SYNO_PATH_VMIX или SYNO_PATH_VMIX_2" + ) syno_url, syno_username, syno_password = get_syno_settings() print(f"[vmix] source_key={source_key or '-'} preset_path={vmix_preset_path}") @@ -231,4 +234,4 @@ def build_vmix_filename(session_row) -> str: tour = session_row[10] date_str = session_row[9].strftime("%d%m%Y") filename = f"ЖФЛ_{home} VS {away}_{tour}_{date_str}.vmix" - return filename \ No newline at end of file + return filename