замена url для текстового датасорса
This commit is contained in:
@@ -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
|
||||
return filename
|
||||
|
||||
Reference in New Issue
Block a user