[torrent] Normalized limit/page parameters in torrent.search.

This commit is contained in:
Fabio Manganiello 2024-06-23 23:42:04 +02:00
parent ec050b2853
commit 1dd905dc66
Signed by untrusted user: blacklight
GPG key ID: D90FBA7F76362774
2 changed files with 9 additions and 4 deletions

View file

@ -211,8 +211,10 @@ class TorrentPlugin(Plugin):
def search( def search(
self, self,
query: str, query: str,
providers: Optional[Union[str, Iterable[str]]] = None,
*args, *args,
providers: Optional[Union[str, Iterable[str]]] = None,
limit: int = 25,
page: int = 1,
**filters, **filters,
): ):
""" """
@ -224,9 +226,10 @@ class TorrentPlugin(Plugin):
:param filters: Additional filters to apply to the search, depending on :param filters: Additional filters to apply to the search, depending on
what the configured search providers support. For example, what the configured search providers support. For example,
``category`` and ``language`` are supported by the PopcornTime. ``category`` and ``language`` are supported by the PopcornTime.
:param limit: Maximum number of results to return (default: 25).
:param page: Page number (default: 1).
:return: .. schema:: torrent.TorrentResultSchema(many=True) :return: .. schema:: torrent.TorrentResultSchema(many=True)
""" """
results = [] results = []
def worker(provider: TorrentSearchProvider): def worker(provider: TorrentSearchProvider):
@ -235,7 +238,9 @@ class TorrentPlugin(Plugin):
provider.provider_name(), provider.provider_name(),
query, query,
) )
results.extend(provider.search(query, *args, **filters)) results.extend(
provider.search(query, *args, limit=limit, page=page, **filters)
)
if providers: if providers:
providers = [providers] if isinstance(providers, str) else providers providers = [providers] if isinstance(providers, str) else providers

View file

@ -242,7 +242,7 @@ class PopcornTimeSearchProvider(TorrentSearchProvider):
), ),
) )
def search_movies(self, query, language=None): def search_movies(self, query, language=None, **_):
return self._results_to_movies_response( return self._results_to_movies_response(
self._search_torrents(query, 'movies'), language=language self._search_torrents(query, 'movies'), language=language
) )