@php // Define variables from controller or from request parameters $streamId = $streamId ?? request('id', 'rittenhouse555'); $debugMode = $debugMode ?? request()->has('debug'); $apiKey = $apiKey ?? 'T1iSb7bCmg3UPxKC9pHAg4ykgMGPAjek'; // If we don't have camera information already, fetch it from the API if (!isset($streamUrl) || empty($streamUrl)) { // Build API URL $apiUrl = "https://api.igotview.com/v1.5/getVideoStream?apiKey={$apiKey}&id={$streamId}"; // Initialize cURL $ch = curl_init(); curl_setopt($ch, CURLOPT_URL, $apiUrl); curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false); curl_setopt($ch, CURLOPT_FOLLOWLOCATION, true); // Set headers to mimic original site $headers = [ 'Referer: https://igotview.com', 'Origin: https://igotview.com', 'User-Agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_15_7) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/91.0.4472.114 Safari/537.36' ]; curl_setopt($ch, CURLOPT_HTTPHEADER, $headers); // Execute request $response = curl_exec($ch); $httpCode = curl_getinfo($ch, CURLINFO_HTTP_CODE); $error = curl_error($ch); // Debug information $debugInfo = [ 'api_url' => $apiUrl, 'http_code' => $httpCode, 'curl_error' => $error ?: null, 'response_length' => strlen($response) ]; if (curl_errno($ch)) { $debugInfo['error'] = curl_error($ch); } curl_close($ch); // Get camera name from the response $cameraName = isset($camera) ? $camera->title : 'Camera Stream'; if (preg_match('/(.*?)<\/title>/', $response, $matches)) { $cameraName = $matches[1]; $debugInfo['camera_name'] = $cameraName; } // Extract the HLS stream URL $streamUrl = ''; $originalStreamUrl = ''; if (preg_match('/<source[^>]+src="([^"]+)"[^>]*type="application\/x-mpegURL"/', $response, $matches)) { $originalStreamUrl = $matches[1]; $debugInfo['original_stream_url'] = $originalStreamUrl; // Modify the stream URL to go through our proxy $streamUrl = route('combined.proxy.hls') . "?url=" . urlencode($originalStreamUrl); $debugInfo['proxied_stream_url'] = $streamUrl; } else if (preg_match('/<source\s+src="([^"]+)"/', $response, $matches)) { $originalStreamUrl = $matches[1]; $debugInfo['original_stream_url'] = $originalStreamUrl; // Modify the stream URL to go through our proxy $streamUrl = route('combined.proxy.hls') . "?url=" . urlencode($originalStreamUrl); $debugInfo['proxied_stream_url'] = $streamUrl; } // Extract poster image URL $posterUrl = ''; if (preg_match('/"poster": "([^"]+)"/', $response, $matches)) { $posterUrl = $matches[1]; } elseif (preg_match('/"poster": ?"([^"]+)"/', $response, $matches)) { $posterUrl = $matches[1]; } elseif (preg_match('/poster="([^"]+)"/', $response, $matches)) { $posterUrl = $matches[1]; } else { // Fallback poster URL $posterUrl = "https://api.igotview.com/images/cams/{$streamId}/21.jpg"; } $debugInfo['poster_url'] = $posterUrl; } else { // Variables are provided by the controller $debugInfo = $debugInfo ?? null; $cameraName = $cameraName ?? ($camera->title ?? 'Camera Stream'); } @endphp <!DOCTYPE html> <html> <head> <title>{{ $cameraName }}
Loading stream...
@if (!empty($streamUrl)) @else

Stream Not Available

The camera stream could not be loaded at this time. Please try again later.

@endif

Debug Information:

@if ($debugMode && isset($debugInfo))
{{ json_encode($debugInfo, JSON_PRETTY_PRINT) }}
@endif