From a2475c262a344ac33103d947aa37e44af46192c4 Mon Sep 17 00:00:00 2001 From: Alexey Barabanov Date: Sat, 22 Nov 2025 19:19:17 +0300 Subject: [PATCH] =?UTF-8?q?=D0=9E=D0=BF=D1=82=D0=B8=D0=BC=D0=B8=D0=B7?= =?UTF-8?q?=D0=B8=D1=80=D0=BE=D0=B2=D0=B0=D0=BD=D0=B0=20=D0=B7=D0=B0=D0=BC?= =?UTF-8?q?=D0=B5=D0=BD=D0=B0=20URL=20=D0=B2=20=D1=84=D1=83=D0=BD=D0=BA?= =?UTF-8?q?=D1=86=D0=B8=D0=B8=20change=5Fvmix=5Fdatasource=5Furls?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- get_data.py | 15 ++++++--------- 1 file changed, 6 insertions(+), 9 deletions(-) diff --git a/get_data.py b/get_data.py index 313c306..5dadfd0 100644 --- a/get_data.py +++ b/get_data.py @@ -14,7 +14,7 @@ from dotenv import load_dotenv from pprint import pprint import nasio import io, os, platform, time -import xml.etree.ElementTree as ET +import xml.etree.ElementTree as ETя import re from PIL import Image, ImageDraw, ImageFont from io import BytesIO @@ -3194,14 +3194,11 @@ def change_vmix_datasource_urls(xml_data, new_base_url: str) -> bytes: root = ET.fromstring(text) # 4. Меняем URL - for ds in root.findall(".//datasource[@friendlyName='JSON']"): - for inst in ds.findall(".//instance"): - url_tag = inst.find(".//state/xml/url") - if url_tag is not None and url_tag.text: - old_url = url_tag.text.strip() - pattern = r"https?\:\/\/\w+\.\w+\.\w{2,}|https?\:\/\/\d{,3}\.\d{,3}\.\d{,3}\.\d{,3}\:\d*" - new_url = re.sub(pattern, new_base_url, old_url, count=0, flags=0) - url_tag.text = new_url + for url_tag in root.findall(".//datasource[@friendlyName='JSON']//instance//state/xml/url"): + old_url = url_tag.text.strip() + pattern = r'https?:\/\/[^\/]+' + new_url = re.sub(pattern, new_base_url, old_url, count=0, flags=0) + url_tag.text = new_url # 5. Сериализуем обратно в bytes new_xml = ET.tostring(root, encoding="utf-8", method="xml")