mirror of
https://github.com/NNTmux/newznab-tmux.git
synced 2026-08-29 01:08:56 +00:00
Fix radarr API issue
This commit is contained in:
@@ -313,9 +313,6 @@ class ApiController extends BasePageController
|
||||
$this->verifyEmptyParameter($request, 'imdbid');
|
||||
$this->verifyEmptyParameter($request, 'tmdbid');
|
||||
$this->verifyEmptyParameter($request, 'traktid');
|
||||
if (! $this->hasMovieSearchParameters($request)) {
|
||||
return showApiError(200, 'Missing parameter (q, imdbid, tmdbid or traktid)');
|
||||
}
|
||||
$maxAge = $this->maxAge($request);
|
||||
if (! is_int($maxAge)) {
|
||||
return $maxAge;
|
||||
@@ -325,6 +322,28 @@ class ApiController extends BasePageController
|
||||
return $sort;
|
||||
}
|
||||
UserRequest::addApiRequest($uid, $request->getRequestUri());
|
||||
$categoryID = $this->categoryID($request);
|
||||
$limit = $this->limit($request);
|
||||
|
||||
if (! $this->hasMovieSearchParameters($request)) {
|
||||
if ($categoryID === [-1]) {
|
||||
$categoryID = Category::MOVIES_GROUP;
|
||||
}
|
||||
|
||||
$relData = $this->releaseBrowseService->getBrowseRangeForApi(
|
||||
1,
|
||||
$categoryID,
|
||||
$offset,
|
||||
$limit,
|
||||
$sort,
|
||||
$maxAge,
|
||||
$catExclusions,
|
||||
-1,
|
||||
$minSize
|
||||
);
|
||||
$this->output($relData, $params, $outputXML, $offset, 'api');
|
||||
break;
|
||||
}
|
||||
|
||||
$imdbId = $request->has('imdbid') && $request->filled('imdbid')
|
||||
? (string) Str::replace('tt', '', (string) $request->input('imdbid'))
|
||||
@@ -337,9 +356,9 @@ class ApiController extends BasePageController
|
||||
$tmdbId,
|
||||
$traktId,
|
||||
$this->offset($request),
|
||||
$this->limit($request),
|
||||
$limit,
|
||||
$request->input('q') ?? '',
|
||||
$this->categoryID($request),
|
||||
$categoryID,
|
||||
$maxAge,
|
||||
$minSize,
|
||||
$catExclusions,
|
||||
|
||||
@@ -79,15 +79,43 @@ class ApiRequestMatrixTest extends TestCase
|
||||
->assertJsonPath('error', 'Incorrect parameter (maxage must be numeric)');
|
||||
}
|
||||
|
||||
public function test_v1_movie_requires_query_or_external_id(): void
|
||||
public function test_v1_movie_without_search_params_returns_recent_movie_feed(): void
|
||||
{
|
||||
$token = (string) DB::table('users')->value('api_token');
|
||||
$request = Request::create('/api/v1/api', 'GET', [
|
||||
't' => 'm',
|
||||
'apikey' => $token,
|
||||
]);
|
||||
|
||||
$response = $this->get('/api/v1/api?t=m&apikey='.$token);
|
||||
$releaseSearchService = Mockery::mock(ReleaseSearchService::class);
|
||||
$releaseBrowseService = Mockery::mock(ReleaseBrowseService::class);
|
||||
$releaseBrowseService->shouldReceive('getBrowseRangeForApi')
|
||||
->once()
|
||||
->andReturn(collect());
|
||||
|
||||
$response->assertOk();
|
||||
$response->assertSee('<error code="200"', false);
|
||||
$response->assertSee('Missing parameter (q, imdbid, tmdbid or traktid)', false);
|
||||
$controller = new class($releaseSearchService, $releaseBrowseService) extends ApiController
|
||||
{
|
||||
/**
|
||||
* @var array{data:mixed,params:array<string,mixed>,xml:bool,offset:int,type:string}|null
|
||||
*/
|
||||
public ?array $capturedOutput = null;
|
||||
|
||||
public function output(mixed $data, array $params, bool $xml, int $offset, string $type = '')
|
||||
{
|
||||
$this->capturedOutput = [
|
||||
'data' => $data,
|
||||
'params' => $params,
|
||||
'xml' => $xml,
|
||||
'offset' => $offset,
|
||||
'type' => $type,
|
||||
];
|
||||
}
|
||||
};
|
||||
|
||||
$controller->api($request);
|
||||
$this->assertNotNull($controller->capturedOutput);
|
||||
$this->assertSame('api', $controller->capturedOutput['type']);
|
||||
$this->assertInstanceOf(Collection::class, $controller->capturedOutput['data']);
|
||||
}
|
||||
|
||||
public function test_v1_tv_without_search_params_returns_recent_tv_feed(): void
|
||||
|
||||
Reference in New Issue
Block a user