This commit is contained in:
@@ -56,7 +56,7 @@ Each channel in the M3U points to a **continuous live stream** (`/live/<id>`): F
|
|||||||
- `GET /epg.xml` or `GET /xmltv.xml` — XMLTV EPG (duration set by `EPG_TIMESPAN`, UTC)
|
- `GET /epg.xml` or `GET /xmltv.xml` — XMLTV EPG (duration set by `EPG_TIMESPAN`, UTC)
|
||||||
- `GET /live/<channel_id>` — continuous MPEG-TS stream for that channel (for tuning/recording)
|
- `GET /live/<channel_id>` — continuous MPEG-TS stream for that channel (for tuning/recording)
|
||||||
- `GET /channel/<id>/playlist.m3u` — single channel M3U (list of individual video URLs)
|
- `GET /channel/<id>/playlist.m3u` — single channel M3U (list of individual video URLs)
|
||||||
- `GET /stream?path=movies/...` or `path=series/...` — stream a single video file (audio track is auto-selected: Dutch/Flemish → English → default)
|
- `GET /stream?path=movies/...` or `path=series/...` — stream a single video file (audio track is auto-selected: Dutch → Flemish → default)
|
||||||
|
|
||||||
## Shuffle behaviour
|
## Shuffle behaviour
|
||||||
|
|
||||||
|
|||||||
@@ -58,5 +58,5 @@ except (TypeError, ValueError):
|
|||||||
TMDB_IMAGE_BASE = "https://image.tmdb.org/t/p"
|
TMDB_IMAGE_BASE = "https://image.tmdb.org/t/p"
|
||||||
TMDB_IMAGE_STILL_SIZE = "w500"
|
TMDB_IMAGE_STILL_SIZE = "w500"
|
||||||
|
|
||||||
# Preferred audio languages for streaming
|
# Preferred audio languages for streaming (in order): Dutch → Flemish → default
|
||||||
PREFERRED_AUDIO_LANGUAGES = ("nld", "dut", "eng")
|
PREFERRED_AUDIO_LANGUAGES = ("nld", "dut", "nl", "vls")
|
||||||
|
|||||||
@@ -7,12 +7,7 @@ import tempfile
|
|||||||
from pathlib import Path
|
from pathlib import Path
|
||||||
from urllib.parse import unquote
|
from urllib.parse import unquote
|
||||||
|
|
||||||
from .config import (
|
from .config import VIDEO_EXTENSIONS, MOVIES_ROOT, SERIES_ROOT
|
||||||
VIDEO_EXTENSIONS,
|
|
||||||
MOVIES_ROOT,
|
|
||||||
SERIES_ROOT,
|
|
||||||
PREFERRED_AUDIO_LANGUAGES,
|
|
||||||
)
|
|
||||||
|
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
@@ -50,7 +45,7 @@ def path_to_absolute(path_param: str) -> Path | None:
|
|||||||
def get_preferred_audio_stream_index(path: Path) -> int | None:
|
def get_preferred_audio_stream_index(path: Path) -> int | None:
|
||||||
"""
|
"""
|
||||||
Probe the file with ffprobe and return the 0-based audio stream index to use:
|
Probe the file with ffprobe and return the 0-based audio stream index to use:
|
||||||
first Dutch/Flemish (nld/dut), else first English (eng), else first audio stream.
|
Dutch (nld/dut/nl) if available, else Flemish (vls), else default (first audio).
|
||||||
Returns None on probe failure or no audio streams.
|
Returns None on probe failure or no audio streams.
|
||||||
"""
|
"""
|
||||||
try:
|
try:
|
||||||
@@ -79,14 +74,19 @@ def get_preferred_audio_stream_index(path: Path) -> int | None:
|
|||||||
if idx is None:
|
if idx is None:
|
||||||
continue
|
continue
|
||||||
tags = s.get("tags") or {}
|
tags = s.get("tags") or {}
|
||||||
lang = (tags.get("language") or "").strip().lower()[:3]
|
raw = (tags.get("language") or "").strip().lower()
|
||||||
audio_streams.append((idx, lang))
|
lang = raw[:3] if len(raw) >= 3 else raw
|
||||||
|
audio_streams.append((idx, lang, raw))
|
||||||
if not audio_streams:
|
if not audio_streams:
|
||||||
return None
|
return None
|
||||||
for pref in PREFERRED_AUDIO_LANGUAGES:
|
dutch = ("nld", "dut", "nl")
|
||||||
for idx, lang in audio_streams:
|
flemish = ("vls", "nl-be", "nlb")
|
||||||
if lang == pref:
|
for idx, lang, raw in audio_streams:
|
||||||
return idx
|
if lang in dutch or raw in dutch:
|
||||||
|
return idx
|
||||||
|
for idx, lang, raw in audio_streams:
|
||||||
|
if lang in flemish or raw in flemish:
|
||||||
|
return idx
|
||||||
return audio_streams[0][0]
|
return audio_streams[0][0]
|
||||||
except (
|
except (
|
||||||
subprocess.TimeoutExpired,
|
subprocess.TimeoutExpired,
|
||||||
|
|||||||
Reference in New Issue
Block a user