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


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

base = "https://dagestan.mediacdn.ru/cdn/dagestan/tracks-v2al/mono.ts.m3u8"
with urllib.request.urlopen(base, timeout=10) as r:
    lines = r.read().decode().splitlines()

segment = next((x.strip() for x in lines if x.strip() and not x.startswith("#")), None)
if not segment:
    print("Сегмент не найден в плейлисте")
    raise SystemExit

url = urljoin(base, segment)
print("Ссылка на сегмент:", url)

req = urllib.request.Request(url, method="GET", headers={"Range": "bytes=0-1023"})
try:
    with urllib.request.urlopen(req, timeout=10) as r:
        print("HTTP:", r.status)
        print("Content-Type:", r.headers.get("Content-Type"))
        print("Получено байт:", len(r.read(1024)))
except Exception as e:
    print("Ошибка сегмента:", e)
PY