Initialize a new HLS stream channel
(request, channel_id)
| 81 | @csrf_exempt |
| 82 | @require_http_methods(["POST"]) |
| 83 | def initialize_stream(request, channel_id): |
| 84 | """Initialize a new HLS stream channel""" |
| 85 | try: |
| 86 | data = json.loads(request.body) |
| 87 | url = data.get('url') |
| 88 | if not url: |
| 89 | return JsonResponse({'error': 'No URL provided'}, status=400) |
| 90 | |
| 91 | proxy_server.initialize_channel(url, channel_id) |
| 92 | return JsonResponse({ |
| 93 | 'message': 'Stream initialized', |
| 94 | 'channel': channel_id, |
| 95 | 'url': url |
| 96 | }) |
| 97 | except json.JSONDecodeError: |
| 98 | return JsonResponse({'error': 'Invalid JSON'}, status=400) |
| 99 | except Exception as e: |
| 100 | logger.error(f"Failed to initialize stream: {e}") |
| 101 | return JsonResponse({'error': str(e)}, status=500) |
nothing calls this directly
no test coverage detected