33from httpx import post
44
55from simplejustwatchapi .query import (
6- Episode ,
7- MediaEntry ,
8- Offer ,
96 parse_details_response ,
107 parse_episodes_response ,
118 parse_offers_for_countries_response ,
1714 prepare_search_request ,
1815 prepare_seasons_request ,
1916)
17+ from simplejustwatchapi .tuples import Episode , MediaEntry , Offer
2018
2119_GRAPHQL_API_URL = "https://apis.justwatch.com/graphql"
2220
@@ -33,19 +31,22 @@ def search(
3331
3432 Returns a list of entries up to ``count``.
3533
36- ``best_only`` allows filtering out redundant offers, e.g. when if provide offers service
34+ ``best_only`` allows filtering out redundant offers, e.g. when service provides offers
3735 in 4K, HD and SD, using ``best_only = True`` returns only 4K option, ``best_only = False``
3836 returns all three.
3937
4038 Args:
41- title: title to search
42- country: country to search for offers, ``US`` by default
43- language: language of responses, ``en`` by default
44- count: how many responses should be returned
45- best_only: return only best offers if ``True``, return all offers if ``False``
39+ title (str): Title to search.
40+ country (str): Country to search for offers, ``US`` by default.
41+ language (str): Language of responses, ``en`` by default.
42+ count (int): How many responses should be returned.
43+ best_only (bool): Return only best offers if ``True``, return all offers if ``False``.
4644
4745 Returns:
48- List of ``MediaEntry`` NamedTuples parsed from JustWatch response
46+ list[MediaEntry]: List of ``MediaEntry`` NamedTuples parsed from JustWatch response.
47+
48+ Raises:
49+ httpx.HTTPStatusError: If JustWatch API doesn't respond with success code.
4950
5051 """
5152 request = prepare_search_request (title , country , language , count , best_only )
@@ -68,15 +69,18 @@ def details(
6869 returns all three.
6970
7071 Args:
71- node_id: ID of entry to look up
72- country: country to search for offers, ``US`` by default
73- language: language of responses, ``en`` by default
74- best_only: return only best offers if ``True``, return all offers if ``False``
72+ node_id (str) : ID of entry to look up.
73+ country (str): Country to search for offers, ``US`` by default.
74+ language (str): Language of responses, ``en`` by default.
75+ best_only (bool): Return only best offers if ``True``, return all offers if ``False``.
7576
7677 Returns:
77- ``MediaEntry`` NamedTuple with data about requested entry,
78+ MediaEntry | None: ``MediaEntry`` NamedTuple with data about requested entry,
7879 or None in case data for a given node ID was not found
7980
81+ Raises:
82+ httpx.HTTPStatusError: If JustWatch API doesn't respond with success code.
83+
8084 """
8185 request = prepare_details_request (node_id , country , language , best_only )
8286 response = post (_GRAPHQL_API_URL , json = request )
@@ -95,15 +99,18 @@ def seasons(
9599 returns all three.
96100
97101 Args:
98- show_id: ID of show to look up seasons for
99- country: country to search for offers, ``US`` by default
100- language: language of responses, ``en`` by default
101- best_only: return only best offers if ``True``, return all offers if ``False``
102+ show_id (str) : ID of show to look up seasons for.
103+ country (str): Country to search for offers, ``US`` by default.
104+ language (str): Language of responses, ``en`` by default.
105+ best_only (bool): Return only best offers if ``True``, return all offers if ``False``.
102106
103107 Returns:
104- ``MediaEntry`` NamedTuple with data about requested entry,
108+ list[MediaEntry] | None: List of ``MediaEntry`` NamedTuples with data about requested entry,
105109 or None in case data for a given node ID was not found
106110
111+ Raises:
112+ httpx.HTTPStatusError: If JustWatch API doesn't respond with success code.
113+
107114 """
108115 request = prepare_seasons_request (show_id , country , language , best_only )
109116 response = post (_GRAPHQL_API_URL , json = request )
@@ -122,14 +129,17 @@ def episodes(
122129 returns all three.
123130
124131 Args:
125- season_id: ID of season to look up episodes for
126- country: country to search for offers, ``US`` by default
127- language: language of responses, ``en`` by default
128- best_only: return only best offers if ``True``, return all offers if ``False``
132+ season_id (str) : ID of season to look up episodes for.
133+ country (str): Country to search for offers, ``US`` by default.
134+ language (str): Language of responses, ``en`` by default.
135+ best_only (bool): Return only best offers if ``True``, return all offers if ``False``.
129136
130137 Returns:
131- ``MediaEntry`` NamedTuple with data about requested entry,
132- or None in case data for a given node ID was not found
138+ list[Episode] | None: List of ``Episode`` NamedTuples with data about requested entry,
139+ or None in case data for a given node ID was not found.
140+
141+ Raises:
142+ httpx.HTTPStatusError: If JustWatch API doesn't respond with success code.
133143
134144 """
135145 request = prepare_episodes_request (season_id , country , language , best_only )
@@ -176,14 +186,17 @@ def offers_for_countries(
176186 returns all three.
177187
178188 Args:
179- node_id: ID of entry to look up offers for
180- countries: set of country codes to search for offers
181- language: language of responses, ``en`` by default
182- best_only: return only best offers if ``True``, return all offers if ``False``
189+ node_id (str) : ID of entry to look up offers for.
190+ countries ( set[str]): 2-letter country codes to search for offers.
191+ language (str): Language of responses, ``en`` by default.
192+ best_only (bool): Return only best offers if ``True``, return all offers if ``False``.
183193
184194 Returns:
185- ``dict`` where keys match values in ``countries`` and keys are all found offers for their
186- respective countries
195+ dict[str, list[Offer]]: ``dict`` where keys match values in ``countries``
196+ and keys are all found offers for their respective countries.
197+
198+ Raises:
199+ httpx.HTTPStatusError: If JustWatch API doesn't respond with success code.
187200
188201 """
189202 if not countries :
0 commit comments