diff --git a/src/frontend/src/app/api.service.ts b/src/frontend/src/app/api.service.ts index 06e17022..2ac538b7 100644 --- a/src/frontend/src/app/api.service.ts +++ b/src/frontend/src/app/api.service.ts @@ -388,8 +388,8 @@ export class ApiService { ); } - public searchTorrents(query: string, mediaType: string): Observable { - return this.http.get(`${this.API_URL_SEARCH_TORRENTS}?q=${query}&media_type=${mediaType}`, {headers: this._requestHeaders()}).pipe( + public searchTorrents(query: string, mediaType: string, useCategories: boolean): Observable { + return this.http.get(`${this.API_URL_SEARCH_TORRENTS}?q=${query}&media_type=${mediaType}&use_categories=${useCategories}`, {headers: this._requestHeaders()}).pipe( map((data: any) => { return data; }), diff --git a/src/frontend/src/app/search/search-manual.component.html b/src/frontend/src/app/search/search-manual.component.html index bb600716..b904121e 100644 --- a/src/frontend/src/app/search/search-manual.component.html +++ b/src/frontend/src/app/search/search-manual.component.html @@ -10,6 +10,7 @@ Search + Search by category diff --git a/src/frontend/src/app/search/search-manual.component.ts b/src/frontend/src/app/search/search-manual.component.ts index 2a0cd350..800a94de 100644 --- a/src/frontend/src/app/search/search-manual.component.ts +++ b/src/frontend/src/app/search/search-manual.component.ts @@ -16,6 +16,7 @@ export class SearchManualComponent implements OnInit { @Input('mediaType') mediaType: string; @Output() downloaded = new EventEmitter(); public searchInput: string; + public useCategories: boolean = true; public orderByOptions = ['Name', 'Seeders', 'Size']; public results: any[] = []; public isSearching = false; @@ -43,7 +44,7 @@ export class SearchManualComponent implements OnInit { public search() { this.results = []; this.isSearching = true; - this.apiService.searchTorrents(this.searchInput, this.mediaType).subscribe( + this.apiService.searchTorrents(this.searchInput, this.mediaType, this.useCategories ?? false).subscribe( (results) => { this.results = results; this.filterChange(); diff --git a/src/nefarious/api/views.py b/src/nefarious/api/views.py index 59bdd91b..87e04a98 100644 --- a/src/nefarious/api/views.py +++ b/src/nefarious/api/views.py @@ -185,7 +185,8 @@ class SearchTorrentsView(views.APIView): def get(self, request): query = request.query_params.get('q') media_type = request.query_params.get('media_type', SEARCH_MEDIA_TYPE_MOVIE) - search = SearchTorrents(media_type, query) + use_category = request.query_params.get('use_categories', True) + search = SearchTorrents(media_type, query, use_category) if not search.ok: return Response({'error': search.error_content}, status=status.HTTP_500_INTERNAL_SERVER_ERROR) return Response(search.results) diff --git a/src/nefarious/search.py b/src/nefarious/search.py index 2d58d2b2..c7b443b3 100644 --- a/src/nefarious/search.py +++ b/src/nefarious/search.py @@ -14,16 +14,18 @@ class SearchTorrents: error_content = None nefarious_settings: NefariousSettings - def __init__(self, media_type: str, query: str): + def __init__(self, media_type: str, query: str, include_category = True): assert media_type in [SEARCH_MEDIA_TYPE_TV, SEARCH_MEDIA_TYPE_MOVIE] self.nefarious_settings = NefariousSettings.get() params = { 'apikey': self.nefarious_settings.jackett_token, 'Query': query, - 'Category[]': self._categories(media_type), } + if include_category: + params['Category[]'] = self._categories(media_type), + res = requests.get(get_jackett_search_url(self.nefarious_settings), params, timeout=90) logger_background.info(f'jackett search: query={query}, url={res.url}')