Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
34 changes: 24 additions & 10 deletions plugins/multiview/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -519,27 +519,39 @@ def _build_warnings_fields(settings: dict) -> list:


def _get_multiview_channel_ids() -> set:
"""Return the set of Channel IDs that belong to the Dispatcharr Multiview M3U account."""
"""Return the set of Channel IDs backed by the Dispatcharr Multiview M3U account."""
try:
from apps.m3u.models import M3UAccount
from apps.channels.models import Channel
acct = M3UAccount.objects.filter(name="Dispatcharr Multiview").first()
if not acct:
return set()
for field in ("m3u_account", "account", "m3u_account_id", "source"):
try:
ids = set(Channel.objects.filter(**{field: acct}).values_list("id", flat=True))
return ids
except Exception:
continue
return set(
Channel.objects.filter(streams__m3u_account=acct)
.values_list("id", flat=True)
.distinct()
)
except Exception:
pass
return set()
return set()


def _get_streamless_channel_ids() -> set:
"""Return the set of Channel IDs with no streams assigned."""
try:
from django.db.models import Count
from apps.channels.models import Channel
return set(
Channel.objects.annotate(n_streams=Count("streams"))
.filter(n_streams=0)
.values_list("id", flat=True)
)
except Exception:
return set()


def _build_channel_options() -> list:
"""Return channel select options from the live DB, excluding multiview output channels."""
excluded = _get_multiview_channel_ids()
excluded = _get_multiview_channel_ids() | _get_streamless_channel_ids()
opts = [{"value": "_none", "label": "Select a channel"}]
try:
from apps.channels.models import Channel
Expand All @@ -560,8 +572,10 @@ def _build_layout_channel_options(layout_id: str, settings: dict, ch_count: int,
try:
from apps.channels.models import Channel
if selector_type == "regex" and regex_pattern:
excluded = _get_multiview_channel_ids() | _get_streamless_channel_ids()
for ch in (
Channel.objects.filter(name__iregex=regex_pattern)
.exclude(id__in=excluded)
.order_by("channel_number")[:ch_count]
.values("id", "name", "channel_number")
.distinct()
Expand Down

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion plugins/multiview/dash/static/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
<link rel="icon" type="image/png" href="./logo.png" />
<link rel="manifest" href="./manifest.json" />
<title>Multiview</title>
<script type="module" crossorigin src="./assets/index-CFcetVdh.js"></script>
<script type="module" crossorigin src="./assets/index-D909_1-I.js"></script>
<link rel="stylesheet" crossorigin href="./assets/index-BHGMNXvw.css">
</head>
<body>
Expand Down
4 changes: 4 additions & 0 deletions plugins/multiview/epg.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,8 @@
import os
from datetime import timedelta, timezone as dt_timezone

from . import config as _mvconfig

logger = logging.getLogger(__name__)


Expand All @@ -18,8 +20,10 @@ def resolve_channel_names(settings: dict, n: int) -> list:
pattern = settings.get(f"multiview_{n}_regex_pattern", "")
if not pattern:
return []
excluded = _mvconfig._get_multiview_channel_ids() | _mvconfig._get_streamless_channel_ids()
return list(
Channel.objects.filter(name__iregex=pattern)
.exclude(id__in=excluded)
.order_by("channel_number")[:ch_count]
.values_list("name", flat=True)
)
Expand Down
2 changes: 1 addition & 1 deletion plugins/multiview/plugin.json
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@
"description": "Tile multiple Dispatcharr channel streams into multi-view outputs using FFmpeg",
"author": "sethwv",

"version": "0.4.0",
"version": "0.4.1",
"min_dispatcharr_version": "v0.27.0",

"discord_thread": "https://discord.com/channels/1340492560220684331/1509200002407465001",
Expand Down
2 changes: 2 additions & 0 deletions plugins/multiview/server.py
Original file line number Diff line number Diff line change
Expand Up @@ -530,8 +530,10 @@ def _resolve_layout(self, layout_id: str):
pattern = settings.get(f"multiview_{layout_id}_regex_pattern", "").strip()
if not pattern:
raise LookupError(f"Layout {n} is in regex mode but has no pattern configured")
excluded = _mvconfig._get_multiview_channel_ids() | _mvconfig._get_streamless_channel_ids()
matched = list(
Channel.objects.select_related("logo").filter(name__iregex=pattern)
.exclude(id__in=excluded)
.order_by("channel_number")[:ch_count]
)
for ch in matched:
Expand Down
Loading