mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-08-02 14:52:15 +00:00
Add stream name to channel status.
This commit is contained in:
parent
8b057818b7
commit
81fecde3b5
1 changed files with 39 additions and 0 deletions
|
|
@ -6,6 +6,7 @@ from .redis_keys import RedisKeys
|
|||
from .constants import TS_PACKET_SIZE, ChannelMetadataField
|
||||
from redis.exceptions import ConnectionError, TimeoutError
|
||||
from .utils import get_logger
|
||||
from django.db import DatabaseError # Add import for error handling
|
||||
|
||||
logger = get_logger()
|
||||
|
||||
|
|
@ -45,6 +46,25 @@ class ChannelStatus:
|
|||
'buffer_index': int(buffer_index_value.decode('utf-8')) if buffer_index_value else 0,
|
||||
}
|
||||
|
||||
# Add stream ID and name information
|
||||
stream_id_bytes = metadata.get(ChannelMetadataField.STREAM_ID.encode('utf-8'))
|
||||
if stream_id_bytes:
|
||||
try:
|
||||
stream_id = int(stream_id_bytes.decode('utf-8'))
|
||||
info['stream_id'] = stream_id
|
||||
|
||||
# Look up stream name from database
|
||||
try:
|
||||
from apps.channels.models import Stream
|
||||
stream = Stream.objects.filter(id=stream_id).first()
|
||||
if stream:
|
||||
info['stream_name'] = stream.name
|
||||
logger.debug(f"Added stream name '{stream.name}' for stream ID {stream_id}")
|
||||
except (ImportError, DatabaseError) as e:
|
||||
logger.warning(f"Failed to get stream name for ID {stream_id}: {e}")
|
||||
except ValueError:
|
||||
logger.warning(f"Invalid stream_id format in Redis: {stream_id_bytes}")
|
||||
|
||||
# Add timing information
|
||||
state_changed_field = ChannelMetadataField.STATE_CHANGED_AT.encode('utf-8')
|
||||
if state_changed_field in metadata:
|
||||
|
|
@ -285,6 +305,25 @@ class ChannelStatus:
|
|||
'uptime': uptime
|
||||
}
|
||||
|
||||
# Add stream ID and name information
|
||||
stream_id_bytes = metadata.get(ChannelMetadataField.STREAM_ID.encode('utf-8'))
|
||||
if stream_id_bytes:
|
||||
try:
|
||||
stream_id = int(stream_id_bytes.decode('utf-8'))
|
||||
info['stream_id'] = stream_id
|
||||
|
||||
# Look up stream name from database
|
||||
try:
|
||||
from apps.channels.models import Stream
|
||||
stream = Stream.objects.filter(id=stream_id).first()
|
||||
if stream:
|
||||
info['stream_name'] = stream.name
|
||||
logger.debug(f"Added stream name '{stream.name}' for stream ID {stream_id}")
|
||||
except (ImportError, DatabaseError) as e:
|
||||
logger.warning(f"Failed to get stream name for ID {stream_id}: {e}")
|
||||
except ValueError:
|
||||
logger.warning(f"Invalid stream_id format in Redis: {stream_id_bytes}")
|
||||
|
||||
# Add data throughput information to basic info
|
||||
total_bytes_bytes = proxy_server.redis_client.hget(metadata_key, ChannelMetadataField.TOTAL_BYTES.encode('utf-8'))
|
||||
if total_bytes_bytes:
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue