fix load more on categories videos
This commit is contained in:
@@ -12,14 +12,22 @@ if (!isset($_SERVER['HTTP_X_REQUESTED_WITH']) || strtolower($_SERVER['HTTP_X_REQ
|
||||
// Récupérer les paramètres
|
||||
$type = isset($_GET['type']) ? $_GET['type'] : '';
|
||||
$page = isset($_GET['page']) ? intval($_GET['page']) : 1;
|
||||
$categoryId = isset($_GET['category']) ? intval($_GET['category']) : 0;
|
||||
|
||||
// Vérifier que le type est valide
|
||||
if (!in_array($type, ['recent', 'trending', 'independence'])) {
|
||||
if (!in_array($type, ['recent', 'trending', 'independence', 'category'])) {
|
||||
http_response_code(400); // Requête incorrecte
|
||||
echo json_encode(['error' => 'Type de vidéos non valide']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Vérifier que la catégorie est fournie si le type est 'category'
|
||||
if ($type === 'category' && $categoryId <= 0) {
|
||||
http_response_code(400); // Requête incorrecte
|
||||
echo json_encode(['error' => 'ID de catégorie manquant ou invalide']);
|
||||
exit;
|
||||
}
|
||||
|
||||
// Récupérer les vidéos en fonction du type
|
||||
$videos = [];
|
||||
$offset = $page * LOAD_MORE_COUNT;
|
||||
@@ -57,6 +65,18 @@ switch ($type) {
|
||||
]);
|
||||
$videos = formatVideosData($data['data'] ?? []);
|
||||
break;
|
||||
|
||||
case 'category':
|
||||
// Récupérer les vidéos de la catégorie
|
||||
$data = callPeerTubeApi('videos', [
|
||||
'categoryOneOf' => $categoryId,
|
||||
'count' => LOAD_MORE_COUNT,
|
||||
'start' => $offset,
|
||||
'sort' => '-publishedAt', // Les plus récentes d'abord
|
||||
'isLocal' => true
|
||||
]);
|
||||
$videos = formatVideosData($data['data'] ?? []);
|
||||
break;
|
||||
}
|
||||
|
||||
// Préparer la réponse HTML
|
||||
|
||||
Reference in New Issue
Block a user