mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-07-17 16:50:53 +00:00
Added channel profile to metadata.
This commit is contained in:
parent
a4c69710b7
commit
5da288b15b
4 changed files with 18 additions and 14 deletions
|
|
@ -30,7 +30,8 @@ class ChannelStatus:
|
|||
'channel_id': channel_id,
|
||||
'state': metadata.get(b'state', b'unknown').decode('utf-8'),
|
||||
'url': metadata.get(b'url', b'').decode('utf-8'),
|
||||
'created_at': metadata.get(b'created_at', b'0').decode('utf-8'),
|
||||
'profile': metadata.get(b'profile', b'unknown').decode('utf-8'),
|
||||
'started_at': metadata.get(b'init_time', b'0').decode('utf-8'),
|
||||
'owner': metadata.get(b'owner', b'unknown').decode('utf-8'),
|
||||
|
||||
# Properly decode the buffer index value
|
||||
|
|
@ -43,9 +44,9 @@ class ChannelStatus:
|
|||
info['state_changed_at'] = state_changed_at
|
||||
info['state_duration'] = time.time() - state_changed_at
|
||||
|
||||
if b'created_at' in metadata:
|
||||
created_at = float(metadata[b'created_at'].decode('utf-8'))
|
||||
info['created_at'] = created_at
|
||||
if b'init_time' in metadata:
|
||||
created_at = float(metadata[b'init_time'].decode('utf-8'))
|
||||
info['started_at'] = created_at
|
||||
info['uptime'] = time.time() - created_at
|
||||
|
||||
# Get client information
|
||||
|
|
@ -203,6 +204,7 @@ class ChannelStatus:
|
|||
'channel_id': channel_id,
|
||||
'state': metadata.get(b'state', b'unknown').decode('utf-8'),
|
||||
'url': metadata.get(b'url', b'').decode('utf-8'),
|
||||
'profile': metadata.get(b'profile', b'unknown').decode('utf-8'),
|
||||
'owner': metadata.get(b'owner', b'unknown').decode('utf-8'),
|
||||
'buffer_index': int(buffer_index_value.decode('utf-8')) if buffer_index_value else 0,
|
||||
'client_count': client_count,
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ class ProxyServer:
|
|||
pubsub = self.redis_client.pubsub()
|
||||
pubsub.psubscribe("ts_proxy:events:*")
|
||||
|
||||
logger.info("Started Redis event listener for client activity")
|
||||
logger.info(f"Started Redis event listener for client activity")
|
||||
|
||||
for message in pubsub.listen():
|
||||
if message["type"] != "pmessage":
|
||||
|
|
@ -483,7 +483,7 @@ class ProxyServer:
|
|||
if stream_thread.is_alive():
|
||||
logger.warning(f"Stream thread did not terminate within timeout")
|
||||
except RuntimeError:
|
||||
logger.debug("Could not join stream thread (may be current thread)")
|
||||
logger.debug(f"Could not join stream thread (may be current thread)")
|
||||
|
||||
# Release ownership
|
||||
self.release_ownership(channel_id)
|
||||
|
|
@ -742,7 +742,7 @@ class ProxyServer:
|
|||
# Update activity timestamp in metadata only
|
||||
self.redis_client.hset(metadata_key, "last_active", str(time.time()))
|
||||
self.redis_client.expire(metadata_key, 30) # Reset TTL on metadata hash
|
||||
logger.debug("Refreshed metadata TTL for channel {channel_id}")
|
||||
logger.debug(f"Refreshed metadata TTL for channel {channel_id}")
|
||||
def update_channel_state(self, channel_id, new_state, additional_fields=None):
|
||||
"""Update channel state with proper history tracking and logging"""
|
||||
if not self.redis_client:
|
||||
|
|
|
|||
|
|
@ -139,7 +139,7 @@ class StreamManager:
|
|||
if response.status_code == 200:
|
||||
self.connected = True
|
||||
self.healthy = True
|
||||
logger.info("Successfully connected to stream source")
|
||||
logger.info(f"Successfully connected to stream source")
|
||||
|
||||
# Set channel state to waiting for clients
|
||||
self._set_waiting_for_clients()
|
||||
|
|
@ -246,7 +246,7 @@ class StreamManager:
|
|||
except:
|
||||
pass
|
||||
|
||||
logger.info("Stream manager stopped")
|
||||
logger.info(f"Stream manager stopped")
|
||||
|
||||
def stop(self):
|
||||
"""Stop this stream"""
|
||||
|
|
@ -327,7 +327,7 @@ class StreamManager:
|
|||
self.healthy = False
|
||||
elif self.connected and not self.healthy:
|
||||
# Auto-recover health when data resumes
|
||||
logger.info("Stream health restored")
|
||||
logger.info(f"Stream health restored")
|
||||
self.healthy = True
|
||||
|
||||
except Exception as e:
|
||||
|
|
|
|||
|
|
@ -81,7 +81,7 @@ def stream_ts(request, channel_id):
|
|||
# Need to check if profile is transcoded
|
||||
logger.debug(f"Using profile {stream_profile} for stream {stream_id}")
|
||||
if stream_profile == 'PROXY' or stream_profile is None:
|
||||
transcode = True
|
||||
transcode = False
|
||||
else:
|
||||
transcode = True
|
||||
|
||||
|
|
@ -89,7 +89,8 @@ def stream_ts(request, channel_id):
|
|||
success = proxy_server.initialize_channel(stream_url, channel_id, stream_user_agent, transcode)
|
||||
if proxy_server.redis_client:
|
||||
metadata_key = f"ts_proxy:channel:{channel_id}:metadata"
|
||||
proxy_server.redis_client.hset(metadata_key, "transcode", "1" if transcode else "0")
|
||||
profile_value = str(stream_profile)
|
||||
proxy_server.redis_client.hset(metadata_key, "profile", profile_value)
|
||||
if not success:
|
||||
return JsonResponse({'error': 'Failed to initialize channel'}, status=500)
|
||||
|
||||
|
|
@ -124,14 +125,15 @@ def stream_ts(request, channel_id):
|
|||
metadata_key = f"ts_proxy:channel:{channel_id}:metadata"
|
||||
url_bytes = proxy_server.redis_client.hget(metadata_key, "url")
|
||||
ua_bytes = proxy_server.redis_client.hget(metadata_key, "user_agent")
|
||||
transcode_bytes = proxy_server.redis_client.hget(metadata_key, "transcode")
|
||||
profile_bytes = proxy_server.redis_client.hget(metadata_key, "profile")
|
||||
|
||||
if url_bytes:
|
||||
url = url_bytes.decode('utf-8')
|
||||
if ua_bytes:
|
||||
stream_user_agent = ua_bytes.decode('utf-8')
|
||||
# Extract transcode setting from Redis
|
||||
use_transcode = transcode_bytes == b'1' if transcode_bytes else False
|
||||
profile_str = profile_bytes.decode('utf-8')
|
||||
use_transcode = (profile_str == 'PROXY' or profile_str == 'None')
|
||||
|
||||
# Use client_user_agent as fallback if stream_user_agent is None
|
||||
success = proxy_server.initialize_channel(url, channel_id, stream_user_agent or client_user_agent, use_transcode)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue