updated core settings, use default stream profile

This commit is contained in:
kappa118 2025-03-01 10:18:59 -05:00
parent a5113660bc
commit d58f33fe31
4 changed files with 54 additions and 67 deletions

View file

@ -36,34 +36,6 @@ class CoreSettingsAdmin(admin.ModelAdmin):
just list and allow editing of any instance.
"""
list_display = (
"default_user_agent",
"default_stream_profile",
"stream_command_timeout",
"enable_stream_logging",
"useragent_cache_timeout",
"streamprofile_cache_timeout",
"streamlink_path",
"vlc_path",
)
fieldsets = (
(None, {
"fields": (
"default_user_agent",
"default_stream_profile",
"stream_command_timeout",
"enable_stream_logging",
)
}),
("Caching", {
"fields": (
"useragent_cache_timeout",
"streamprofile_cache_timeout",
)
}),
("Paths", {
"fields": (
"streamlink_path",
"vlc_path",
)
}),
"key",
"value",
)

View file

@ -0,0 +1,44 @@
[
{
"model": "core.useragent",
"pk": 1,
"fields": {
"user_agent_name": "TiviMate",
"user_agent": "TiviMate/5.1.6 (Android 12)",
"description": "",
"is_active": true
}
},
{
"model": "core.useragent",
"pk": 2,
"fields": {
"user_agent_name": "VLC",
"user_agent": "VLC/3.0.21 LibVLC 3.0.21",
"description": "",
"is_active": true
}
},
{
"model": "core.streamprofile",
"pk": 1,
"fields": {
"profile_name": "ffmpeg",
"command": "ffmpeg",
"parameters": "-i {streamUrl} -c:v copy -c:a copy -f mpegts pipe:1",
"is_active": true,
"user_agent": "1"
}
},
{
"model": "core.streamprofile",
"pk": 2,
"fields": {
"profile_name": "streamlink",
"command": "streamlink",
"parameters": "{streamUrl} best --stdout",
"is_active": true,
"user_agent": "1"
}
}
]

View file

@ -49,46 +49,16 @@ class StreamProfile(models.Model):
class CoreSettings(models.Model):
default_user_agent = models.CharField(
max_length=512,
default="Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 Chrome/112.0.0.0 Safari/537.36",
help_text="The default User-Agent string to use if none is provided."
)
default_stream_profile = models.CharField(
key = models.CharField(
max_length=255,
default="default_profile",
help_text="Name or identifier for the default stream profile."
unique=True,
)
stream_command_timeout = models.PositiveIntegerField(
default=300,
help_text="Timeout in seconds for running stream commands."
)
enable_stream_logging = models.BooleanField(
default=True,
help_text="Toggle verbose logging for stream commands."
)
useragent_cache_timeout = models.PositiveIntegerField(
default=300,
help_text="Cache timeout in seconds for user agent data."
)
streamprofile_cache_timeout = models.PositiveIntegerField(
default=300,
help_text="Cache timeout in seconds for stream profile data."
)
streamlink_path = models.CharField(
name = models.CharField(
max_length=255,
default="/usr/bin/streamlink",
help_text="Override path for the streamlink command."
)
vlc_path = models.CharField(
value = models.CharField(
max_length=255,
default="/usr/bin/vlc",
help_text="Override path for the VLC command."
)
def __str__(self):
return "Core Settings"
class Meta:
verbose_name = "Core Setting"
verbose_name_plural = "Core Settings"

View file

@ -12,7 +12,7 @@ from django.shortcuts import render
from apps.channels.models import Channel, Stream
from apps.m3u.models import M3UAccountProfile
from core.models import StreamProfile
from core.models import StreamProfile, CoreSettings
# Import the persistent lock (the “real” lock)
from dispatcharr.persistent_lock import PersistentLock
@ -89,8 +89,9 @@ def stream_view(request, stream_id):
# Get the stream profile set on the channel.
stream_profile = channel.stream_profile
if not stream_profile:
logger.error("No stream profile set for channel ID=%s", channel.id)
return HttpResponseServerError("No stream profile set for this channel.")
logger.error("No stream profile set for channel ID=%s, using default", channel.id)
stream_profile = StreamProfile.objects.get(id=CoreSettings.objects.get(key="default-stream-profile").value)
logger.debug("Stream profile used: %s", stream_profile.profile_name)
# Determine the user agent to use.