mirror of
https://github.com/Dispatcharr/Dispatcharr.git
synced 2026-01-23 02:35:14 +00:00
Fixes CRSF issues.
This commit is contained in:
parent
5e5f087013
commit
0750b7dd80
1 changed files with 23 additions and 23 deletions
|
|
@ -9,6 +9,28 @@ from .server import ProxyServer
|
|||
logger = logging.getLogger(__name__)
|
||||
proxy_server = ProxyServer()
|
||||
|
||||
@csrf_exempt
|
||||
@require_http_methods(["POST"])
|
||||
def initialize_stream(request, channel_id):
|
||||
"""Initialize a new stream channel"""
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
url = data.get('url')
|
||||
if not url:
|
||||
return JsonResponse({'error': 'No URL provided'}, status=400)
|
||||
|
||||
proxy_server.initialize_channel(url, channel_id)
|
||||
return JsonResponse({
|
||||
'message': 'Stream initialized',
|
||||
'channel': channel_id,
|
||||
'url': url
|
||||
})
|
||||
except json.JSONDecodeError:
|
||||
return JsonResponse({'error': 'Invalid JSON'}, status=400)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to initialize stream: {e}")
|
||||
return JsonResponse({'error': str(e)}, status=500)
|
||||
|
||||
@csrf_exempt
|
||||
@require_http_methods(["GET"])
|
||||
def stream_ts(request, channel_id):
|
||||
|
|
@ -39,7 +61,7 @@ def stream_ts(request, channel_id):
|
|||
|
||||
except Exception as e:
|
||||
logger.error(f"Streaming error for channel {channel_id}: {e}")
|
||||
finally: # Add finally block to ensure cleanup
|
||||
finally:
|
||||
try:
|
||||
if channel_id in proxy_server.client_managers:
|
||||
remaining = proxy_server.client_managers[channel_id].remove_client(client_id)
|
||||
|
|
@ -54,28 +76,6 @@ def stream_ts(request, channel_id):
|
|||
content_type='video/MP2T'
|
||||
)
|
||||
|
||||
@csrf_exempt
|
||||
@require_http_methods(["POST"])
|
||||
def initialize_stream(request, channel_id):
|
||||
"""Initialize a new stream channel"""
|
||||
try:
|
||||
data = json.loads(request.body)
|
||||
url = data.get('url')
|
||||
if not url:
|
||||
return JsonResponse({'error': 'No URL provided'}, status=400)
|
||||
|
||||
proxy_server.initialize_channel(url, channel_id)
|
||||
return JsonResponse({
|
||||
'message': 'Stream initialized',
|
||||
'channel': channel_id,
|
||||
'url': url
|
||||
})
|
||||
except json.JSONDecodeError:
|
||||
return JsonResponse({'error': 'Invalid JSON'}, status=400)
|
||||
except Exception as e:
|
||||
logger.error(f"Failed to initialize stream: {e}")
|
||||
return JsonResponse({'error': str(e)}, status=500)
|
||||
|
||||
@csrf_exempt
|
||||
@require_http_methods(["POST"])
|
||||
def change_stream(request, channel_id):
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue