Sfoglia il codice sorgente

include offset in ombi api call

CauseFX 5 anni fa
parent
commit
4e7870f8b5
2 ha cambiato i file con 7 aggiunte e 5 eliminazioni
  1. 4 3
      api/homepage/ombi.php
  2. 3 2
      api/v2/routes/homepage.php

+ 4 - 3
api/homepage/ombi.php

@@ -37,7 +37,7 @@ trait OmbiHomepageItem
 		return $type == $this->config['ombiTvDefault'];
 	}
 	
-	public function getOmbiRequests($type = "both", $limit = 50)
+	public function getOmbiRequests($type = "both", $limit = 50, $offset = 0)
 	{
 		if (!$this->config['homepageOmbiEnabled']) {
 			$this->setAPIResponse('error', 'Ombi homepage item is not enabled', 409);
@@ -58,7 +58,8 @@ trait OmbiHomepageItem
 		$api['count'] = array(
 			'movie' => 0,
 			'tv' => 0,
-			'limit' => (integer)$limit
+			'limit' => (integer)$limit,
+			'offset' => (integer)$offset
 		);
 		$headers = array(
 			"Accept" => "application/json",
@@ -153,7 +154,7 @@ trait OmbiHomepageItem
 			$this->setAPIResponse('error', $e->getMessage(), 500);
 			return false;
 		};
-		$api['content'] = isset($requests) ? array_slice($requests, 0, $limit) : false;
+		$api['content'] = isset($requests) ? array_slice($requests, $offset, $limit) : false;
 		$this->setAPIResponse('success', null, 200, $api);
 		return $api;
 	}

+ 3 - 2
api/v2/routes/homepage.php

@@ -364,11 +364,12 @@ $app->get('/homepage/healthchecks/{tags}', function ($request, $response, $args)
 		->withStatus($GLOBALS['responseCode']);
 	
 });
-$app->get('/homepage/ombi/requests[/{type}[/{limit}]]', function ($request, $response, $args) {
+$app->get('/homepage/ombi/requests[/{type}[/{limit}[/{offset}]]]', function ($request, $response, $args) {
 	$Organizr = ($request->getAttribute('Organizr')) ?? new Organizr();
 	$args['type'] = $args['type'] ?? 'both';
 	$args['limit'] = $args['limit'] ?? $Organizr->config['ombiLimit'];
-	$Organizr->getOmbiRequests($args['type'], $args['limit']);
+	$args['offset'] = $args['offset'] ?? 0;
+	$Organizr->getOmbiRequests($args['type'], $args['limit'], $args['offset']);
 	$response->getBody()->write(jsonE($GLOBALS['api']));
 	return $response
 		->withHeader('Content-Type', 'application/json;charset=UTF-8')