diff --git a/app/Models/Category.php b/app/Models/Category.php index 834794c42..5a9fc2c6d 100644 --- a/app/Models/Category.php +++ b/app/Models/Category.php @@ -310,13 +310,13 @@ class Category extends Model { $categories = []; - // if searchType is tv return TV categories - if ($searchType === 'tv') { + // if searchType is tv return TV categories (only if no specific categories provided) + if ($searchType === 'tv' && (empty($cat) || $cat === [-1] || $cat === ['-1'])) { $cat = self::TV_GROUP; } - // is searchType is movies return MOVIES categories - if ($searchType === 'movies') { + // is searchType is movies return MOVIES categories (only if no specific categories provided) + if ($searchType === 'movies' && (empty($cat) || $cat === [-1] || $cat === ['-1'])) { $cat = self::MOVIES_GROUP; } diff --git a/app/Services/Releases/ReleaseSearchService.php b/app/Services/Releases/ReleaseSearchService.php index 0c3656991..b48215f7b 100644 --- a/app/Services/Releases/ReleaseSearchService.php +++ b/app/Services/Releases/ReleaseSearchService.php @@ -729,7 +729,6 @@ class ReleaseSearchService */ public function moviesSearch(int $imDbId = -1, int $tmDbId = -1, int $traktId = -1, int $offset = 0, int $limit = 100, string $name = '', array $cat = [-1], int $maxAge = -1, int $minSize = 0, array $excludedCategories = []): mixed { - // Early return if searching by name yields no results $searchResult = []; // OPTIMIZATION: If we have external IDs, use the search index to find releases directly @@ -768,18 +767,16 @@ class ReleaseSearchService $searchResult = $this->performMySQLSearch(['searchname' => $name], $limit); } + // Only return empty if we were specifically searching by name but found nothing if (empty($searchResult)) { return collect(); } } - // If we still have no results (no name and no external IDs found anything), return empty - if (empty($searchResult) && empty($externalIds)) { - return collect(); - } - + // Build the base conditions for movie search + // Note: we don't have MOVIE_ROOT constant that marks a parent category, + // so we'll rely on the category search logic instead $conditions = [ - sprintf('r.categories_id BETWEEN %d AND %d', Category::MOVIE_ROOT, Category::MOVIE_OTHER), sprintf('r.passwordstatus %s', $this->showPasswords()), ];