From 1dd905dc66ba3568b30bb5ed36f46d1f66a9d7a1 Mon Sep 17 00:00:00 2001 From: Fabio Manganiello Date: Sun, 23 Jun 2024 23:42:04 +0200 Subject: [PATCH] [torrent] Normalized `limit`/`page` parameters in `torrent.search`. --- platypush/plugins/torrent/__init__.py | 11 ++++++++--- platypush/plugins/torrent/_search/_popcorntime.py | 2 +- 2 files changed, 9 insertions(+), 4 deletions(-) diff --git a/platypush/plugins/torrent/__init__.py b/platypush/plugins/torrent/__init__.py index e88349b751..d0af397ad2 100644 --- a/platypush/plugins/torrent/__init__.py +++ b/platypush/plugins/torrent/__init__.py @@ -211,8 +211,10 @@ class TorrentPlugin(Plugin): def search( self, query: str, - providers: Optional[Union[str, Iterable[str]]] = None, *args, + providers: Optional[Union[str, Iterable[str]]] = None, + limit: int = 25, + page: int = 1, **filters, ): """ @@ -224,9 +226,10 @@ class TorrentPlugin(Plugin): :param filters: Additional filters to apply to the search, depending on what the configured search providers support. For example, ``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) """ - results = [] def worker(provider: TorrentSearchProvider): @@ -235,7 +238,9 @@ class TorrentPlugin(Plugin): provider.provider_name(), query, ) - results.extend(provider.search(query, *args, **filters)) + results.extend( + provider.search(query, *args, limit=limit, page=page, **filters) + ) if providers: providers = [providers] if isinstance(providers, str) else providers diff --git a/platypush/plugins/torrent/_search/_popcorntime.py b/platypush/plugins/torrent/_search/_popcorntime.py index eace8fdb78..8363963a95 100644 --- a/platypush/plugins/torrent/_search/_popcorntime.py +++ b/platypush/plugins/torrent/_search/_popcorntime.py @@ -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( self._search_torrents(query, 'movies'), language=language )