'Accès non autorisé']); exit; } // Récupérer les paramètres $type = isset($_GET['type']) ? $_GET['type'] : ''; $page = isset($_GET['page']) ? intval($_GET['page']) : 1; // Vérifier que le type est valide if (!in_array($type, ['recent', 'trending', 'independence'])) { http_response_code(400); // Requête incorrecte echo json_encode(['error' => 'Type de vidéos non valide']); exit; } // Récupérer les vidéos en fonction du type $videos = []; $offset = $page * LOAD_MORE_COUNT; switch ($type) { case 'recent': // Récupérer les vidéos récentes $data = callPeerTubeApi('videos', [ 'sort' => '-publishedAt', 'count' => LOAD_MORE_COUNT, 'start' => $offset, 'isLocal' => true ]); $videos = formatVideosData($data['data'] ?? []); break; case 'trending': // Récupérer les vidéos tendances $data = callPeerTubeApi('videos', [ 'sort' => '-views', 'count' => LOAD_MORE_COUNT, 'start' => $offset, 'isLocal' => true ]); $videos = formatVideosData($data['data'] ?? []); break; case 'independence': // Récupérer les vidéos sur l'indépendance $data = callPeerTubeApi('videos', [ 'tagsOneOf' => TAG_INDEPENDENCE, 'count' => LOAD_MORE_COUNT, 'start' => $offset, 'isLocal' => true ]); $videos = formatVideosData($data['data'] ?? []); break; } // Préparer la réponse HTML $html = ''; foreach ($videos as $video) { $html .= '
'; $html .= '
'; $html .= ' ' . htmlspecialchars($video['title']) . ''; $html .= '
'; $html .= ' '; $html .= '
'; $html .= '
' . formatDuration($video['duration']) . '
'; $html .= '
'; $html .= '
'; $html .= '

' . htmlspecialchars($video['title']) . '

'; $html .= '
' . htmlspecialchars($video['channel']) . '
'; $html .= ' '; $html .= '
'; $html .= '
'; } // Retourner la réponse echo json_encode([ 'success' => true, 'html' => $html, 'page' => $page, 'hasMore' => count($videos) >= LOAD_MORE_COUNT ]); ?>