@@ -50,13 +50,22 @@ def search(
5050 in 4K, HD and SD, using ``best_only = True`` returns only 4K option, ``best_only = False``
5151 returns all three.
5252
53+ ``providers`` is a list of (usually) 3-letter service identifiers (e.g, ``nfx`` for "Netflix).
54+ Only entries which are available for given providers will be returned.
55+ For single provider you can either pass a single string, or a list of one string.
56+ For ``None`` (also a default value) entries for all providers will be looked up.
57+ Invalid names will be ignored, however if all are invalid, then no filtering will be done.
58+ You can look up values through ``providers`` function.
59+
5360 Args:
5461 title (str): Title to search.
5562 country (str): Country to search for offers, ``US`` by default.
5663 language (str): Language of responses, ``en`` by default.
5764 count (int): How many responses should be returned.
5865 best_only (bool): Return only best offers if ``True``, return all offers if ``False``.
5966 offset (int): Search results offset.
67+ providers (list[str] | str | None): 3-letter service identifier(s),
68+ or ``None`` for all providers.
6069
6170 Returns:
6271 list[MediaEntry]: List of ``MediaEntry`` NamedTuples parsed from JustWatch response.
@@ -79,6 +88,47 @@ def popular(
7988 offset : int = 0 ,
8089 providers : list [str ] | str | None = None ,
8190) -> list [MediaEntry ]:
91+ """
92+ Look up all currently popular titles on JustWatch.
93+
94+ Returns a list of entries up to ``count``.
95+
96+ ``offset`` specifies how many first entries should be skipped. This is done on API side,
97+ not the library side; the returned list is still directly parsed from API response.
98+ I'm not sure if it guarantees stability of results - whether repeated calls to this function
99+ with increasing offset will guarantee that you won't get repeats.
100+
101+ JustWatch API won't allow for getting more than 2000 responses, either through ``count``, or
102+ when ``count + offset`` is equal or greater than 2000 - it will return an empty list instead
103+ (ALWAYS an empty list, if ``offset`` is lower than 2000 it won't include entries up to 2000).
104+
105+ ``best_only`` allows filtering out redundant offers, e.g. when service provides offers
106+ in 4K, HD and SD, using ``best_only = True`` returns only 4K option, ``best_only = False``
107+ returns all three.
108+
109+ ``providers`` is a list of (usually) 3-letter service identifiers (e.g, ``nfx`` for "Netflix).
110+ Only entries which are available for given providers will be returned.
111+ For single provider you can either pass a single string, or a list of one string.
112+ For ``None`` (also a default value) entries for all providers will be looked up.
113+ Invalid names will be ignored, however if all are invalid, then no filtering will be done.
114+ You can look up values through ``providers`` function.
115+
116+ Args:
117+ country (str): Country to search for offers, ``US`` by default.
118+ language (str): Language of responses, ``en`` by default.
119+ count (int): How many responses should be returned.
120+ best_only (bool): Return only best offers if ``True``, return all offers if ``False``.
121+ offset (int): Search results offset.
122+ providers (list[str] | str | None): 3-letter service identifier(s),
123+ or ``None`` for all providers.
124+
125+ Returns:
126+ list[MediaEntry]: List of ``MediaEntry`` NamedTuples parsed from JustWatch response.
127+
128+ Raises:
129+ httpx.HTTPStatusError: If JustWatch API doesn't respond with success code.
130+
131+ """
82132 request = prepare_popular_request (country , language , count , best_only , offset , providers )
83133 response = post (_GRAPHQL_API_URL , json = request )
84134 response .raise_for_status ()
@@ -238,6 +288,18 @@ def offers_for_countries(
238288
239289
240290def providers (country : str ) -> list [OfferPackage ]:
291+ """
292+ Look up all providers for the given country code.
293+
294+ Args:
295+ country (str): 2-letter country code.
296+
297+ Returns:
298+ list[OfferPackage]: List of all found providers. ``OfferPackage`` tuple matches
299+ values in ``Offer`` (and thus in ``MediaEntry``), but the data structure is the same,
300+ so the same tuple is reused.
301+
302+ """
241303 request = prepare_providers_request (country )
242304 response = post (_GRAPHQL_API_URL , json = request )
243305 response .raise_for_status ()
0 commit comments