Загрузка данных


python3 - <<'PY'
import urllib.request
from urllib.parse import urljoin

base = "https://dagestan.mediacdn.ru/cdn/dagestan/tracks-v2al/mono.ts.m3u8"
req = urllib.request.Request(base, headers={"User-Agent": "Mozilla/5.0"})
with urllib.request.urlopen(req, timeout=10) as r:
    lines = r.read().decode().splitlines()

segments = [x.strip() for x in lines if x.strip() and not x.startswith("#")]
url = urljoin(base, segments[-1])
print("Проверяем:", url)

for headers in [
    {"User-Agent": "Mozilla/5.0"},
    {"User-Agent": "VLC/3.0.20"},
]:
    req = urllib.request.Request(url, headers=headers)
    try:
        with urllib.request.urlopen(req, timeout=10) as r:
            print(headers["User-Agent"], "HTTP", r.status, "bytes", len(r.read(1024)))
    except Exception as e:
        print(headers["User-Agent"], "ERROR", e)
PY