mirror of
https://github.com/ceratic/MediaCollectorLibary.git
synced 2026-05-13 23:56:46 +02:00
...
This commit is contained in:
107
test_xbvr.php
Normal file
107
test_xbvr.php
Normal file
@@ -0,0 +1,107 @@
|
||||
<?php
|
||||
|
||||
require_once __DIR__ . '/vendor/autoload.php';
|
||||
|
||||
// Load helper functions
|
||||
require_once __DIR__ . '/app/helpers.php';
|
||||
|
||||
// Load environment variables
|
||||
$dotenv = Dotenv\Dotenv::createImmutable(__DIR__);
|
||||
$dotenv->load();
|
||||
|
||||
// Load database configuration
|
||||
$dbConfig = require __DIR__ . '/config/database.php';
|
||||
|
||||
// Set up database connection
|
||||
try {
|
||||
\App\Database\Database::setConfig($dbConfig);
|
||||
$pdo = \App\Database\Database::getInstance();
|
||||
echo "Database connection established successfully.\n";
|
||||
} catch (Exception $e) {
|
||||
die('Database connection failed: ' . $e->getMessage() . "\n");
|
||||
}
|
||||
|
||||
// Test XBVR connectivity
|
||||
echo "\nTesting XBVR source connectivity...\n";
|
||||
|
||||
// Find XBVR source
|
||||
$stmt = $pdo->prepare("SELECT * FROM sources WHERE name = 'xbvr' AND is_active = 1 LIMIT 1");
|
||||
$stmt->execute();
|
||||
$xbvrSource = $stmt->fetch(PDO::FETCH_ASSOC);
|
||||
|
||||
if (!$xbvrSource) {
|
||||
echo "No active XBVR source found. Please create an XBVR source first.\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "Found XBVR source: {$xbvrSource['display_name']} ({$xbvrSource['api_url']})\n";
|
||||
|
||||
// Test basic connectivity
|
||||
$baseUrl = rtrim($xbvrSource['api_url'], '/');
|
||||
|
||||
try {
|
||||
$httpClient = new GuzzleHttp\Client([
|
||||
'timeout' => 10,
|
||||
'headers' => [
|
||||
'User-Agent' => 'MediaCollector/1.0'
|
||||
],
|
||||
'verify' => false
|
||||
]);
|
||||
|
||||
// Try different XBVR API endpoints
|
||||
$endpoints = [
|
||||
"{$baseUrl}/deovr"
|
||||
];
|
||||
|
||||
foreach ($endpoints as $endpoint) {
|
||||
echo "\nTrying endpoint: {$endpoint}\n";
|
||||
|
||||
try {
|
||||
$response = $httpClient->get($endpoint, [
|
||||
'timeout' => 10,
|
||||
'connect_timeout' => 5
|
||||
]);
|
||||
|
||||
echo "✓ Status: {$response->getStatusCode()}\n";
|
||||
echo "Content-Type: " . $response->getHeaderLine('content-type') . "\n";
|
||||
|
||||
$data = json_decode($response->getBody(), true);
|
||||
echo "Response keys: " . implode(', ', array_keys($data)) . "\n";
|
||||
|
||||
// XBVR DeoVR API response structure
|
||||
$scenes = null;
|
||||
|
||||
// Try different DeoVR response structures
|
||||
if (isset($data['scenes'])) {
|
||||
$scenes = $data['scenes'];
|
||||
} elseif (isset($data['content'])) {
|
||||
$scenes = $data['content'];
|
||||
} elseif (isset($data['videos'])) {
|
||||
$scenes = $data['videos'];
|
||||
} elseif (isset($data[0]) && is_array($data[0])) {
|
||||
// Array of scenes directly
|
||||
$scenes = $data;
|
||||
}
|
||||
|
||||
if ($scenes !== null) {
|
||||
echo "✓ Found " . count($scenes) . " scenes in XBVR DeoVR response\n";
|
||||
if (count($scenes) > 0) {
|
||||
echo "Sample scene keys: " . implode(', ', array_keys($scenes[0])) . "\n";
|
||||
}
|
||||
break;
|
||||
} else {
|
||||
echo "✗ No scenes array found in response. Response keys: " . implode(', ', array_keys($data)) . "\n";
|
||||
echo "Sample response structure: " . json_encode(array_slice($data, 0, 2), JSON_PRETTY_PRINT) . "\n";
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "✗ Error: " . $e->getMessage() . "\n";
|
||||
}
|
||||
}
|
||||
|
||||
} catch (Exception $e) {
|
||||
echo "Error testing XBVR connectivity: " . $e->getMessage() . "\n";
|
||||
exit(1);
|
||||
}
|
||||
|
||||
echo "\nXBVR connectivity test complete.\n";
|
||||
Reference in New Issue
Block a user