From f6466a77af9a6f347a892554b4df249bdfe3427b Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Fri, 19 Nov 2021 12:46:27 +0000 Subject: [PATCH 1/7] add `get_streaming_providers` method to tmdb client --- src/phylm/clients/tmdb.py | 23 +++ .../clients/tmdb/matrix_providers.yaml | 134 ++++++++++++++++++ .../clients/tmdb/no_results_providers.yaml | 63 ++++++++ tests/unit/clients/test_tmdb.py | 39 +++++ 4 files changed, 259 insertions(+) create mode 100644 tests/fixtures/vcr_cassettes/clients/tmdb/matrix_providers.yaml create mode 100644 tests/fixtures/vcr_cassettes/clients/tmdb/no_results_providers.yaml diff --git a/src/phylm/clients/tmdb.py b/src/phylm/clients/tmdb.py index d7da3d0..7a41118 100644 --- a/src/phylm/clients/tmdb.py +++ b/src/phylm/clients/tmdb.py @@ -39,3 +39,26 @@ def search_movies(self, query: str) -> List[Dict[str, Any]]: res = self.session.get(f"{self._base}/search/movie", params=payload) results: List[Dict[str, Any]] = res.json()["results"] return results + + def get_streaming_providers( + self, movie_id: str, regions: List[str] + ) -> Dict[str, Any]: + """Return a list of streaming providers for a given movie. + + Args: + movie_id: the tmdb id of the movie + regions: a list of regions to trim down the return list + + Returns: + Dict[str, Any]: a dictionary of streaming providers, keyed by region name + """ + payload = {"api_key": self.api_key} + res = self.session.get( + f"{self._base}/movie/{movie_id}/watch/providers", params=payload + ) + + res.raise_for_status() + + results: Dict[str, Any] = res.json()["results"] + + return {key: results[key.upper()] for key in regions} diff --git a/tests/fixtures/vcr_cassettes/clients/tmdb/matrix_providers.yaml b/tests/fixtures/vcr_cassettes/clients/tmdb/matrix_providers.yaml new file mode 100644 index 0000000..2e855e0 --- /dev/null +++ b/tests/fixtures/vcr_cassettes/clients/tmdb/matrix_providers.yaml @@ -0,0 +1,134 @@ +interactions: + - request: + body: null + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.themoviedb.org/3/movie/603/watch/providers + response: + body: + string: !!binary | + H4sIAAAAAAAAA+1d65KiyLZ+lYr63TMtN4GO2HFCuQgiKKCinpiYAEVF7jcVJ/qBznOcFztY0/tG + pdXVZ9PiFPlnomcmOpeZ+a1v3ZM/np3N85duB/v0nNhp7mXp85c/nnva9Z+eE7jPX573WRalXz5/ + Pp1Ov2Z72w+Pjr2xfg2T3eeXP38u//Yv5f/4xTezxDl/PpnZev9fXrg2Pftv5UrXlYPs+ct///G8 + cdLIM4vfo8QJEycrnr+gn569cBf+HpnZvpT1Oe5mXle0uguCn1IdTfbWrGWfxRDXs18P0a5cLEpK + oRs7+f36w9F/+ffA9O1yiV4UefaTM80DO33++gkkFKsIjbAVgu6kGI2PQ3M2lm1JmaH+RZqLNEgo + 9lroIAx3pdRJKedJvh7KLdF0RXSys0xPMaxevjdcTxCIYS/gCcw42AVQNEa/Fn4VmGZm8iL++etv + n563XnkVZmbfOHSq8iNMHb0ch0ZA+yeHGdumybjiHj959koH/ggKf/0jhP74STbPL+KtvGjfdf/2 + 9dNzb1qb3kyfW3qOQNFVxEarna0b0fbIEvS5my67aTYl1t18je5BohGs81q47hZPehYm9g2ZSKci + 9JTPnYJ1LT7CE3Ieix17OzGIPb9VD8D9Eq9laqabZ3bwNJ3fEopUhB4Pkq2TS3qrFLGSHSNUGzNr + EnFyJAcJxQEbZfaO57xXXjrvczwZk6P4IPQMPZBOrHXxE5STl8CTBcjr+eYlDJ7m5X8Lb4klKmL9 + MFWyk6AwMeMfXDIgwo20Wy636EAEAhgg1jfPm9C3377TbkWuu0G3U8H3XSZf4R6Tr7fUWcCp1KOA + GEYwAIpfNmrlaWYnN8TiZBW/ZoyG6EbcqsF5zWnpPIzJZUpJywsFEtulAKzvrJMwDbfZ3zf8fd6v + ApruIUN97uvntDD7Eq7P+HQ5j63ecmuAfgXgRyh2tvWc841tV3eNr319snNinVseODsaHchtn5wM + NQ5ngQp0Q2mnztq1s3cyhWNwjrqQTC0TYttbSdludiiSZWiYXSCw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0yAD9tH55aDt+vX/8PGusB + 38z8AAA= + headers: + Access-Control-Allow-Methods: + - GET, HEAD, POST, PUT, DELETE, OPTIONS + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - ETag, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, + Content-Length, Content-Range + Cache-Control: + - public, max-age=28800 + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json;charset=utf-8 + Date: + - Fri, 19 Nov 2021 12:29:06 GMT + ETag: + - W/"051aaa37d61d82e502fec7c75fa8fb5b" + Server: + - openresty + Transfer-Encoding: + - chunked + Vary: + - Accept-Encoding + Via: + - 1.1 cd8f4ac94836dc54b056844b56c2bb70.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - s8gnJ7U710L605Db0xE0GqyuojnJOGtyc5Tr_J15Kc41ykLr8o6Nqg== + X-Amz-Cf-Pop: + - LHR62-C5 + X-Cache: + - Miss from cloudfront + X-Memc: + - HIT + X-Memc-Age: + - "13266" + X-Memc-Expires: + - "3121" + X-Memc-Key: + - ef74d3db9d756ce3497f67fdbcefc39de41f661e + status: + code: 200 + message: OK +version: 1 diff --git a/tests/fixtures/vcr_cassettes/clients/tmdb/no_results_providers.yaml b/tests/fixtures/vcr_cassettes/clients/tmdb/no_results_providers.yaml new file mode 100644 index 0000000..bd14208 --- /dev/null +++ b/tests/fixtures/vcr_cassettes/clients/tmdb/no_results_providers.yaml @@ -0,0 +1,63 @@ +interactions: + - request: + body: null + headers: + Accept: + - "*/*" + Accept-Encoding: + - gzip, deflate + Connection: + - keep-alive + User-Agent: + - python-requests/2.26.0 + method: GET + uri: https://api.themoviedb.org/3/movie/-1/watch/providers + response: + body: + string: !!binary | + H4sIAAAAAAAAAz3KIQ6AMAxG4as01QQDinPgyeh+QIw1rKsghLszhXxf3sPmIjDjaQvJ0LHVUN0W + 0QiehvGHs01hb8bzASow9SKgW73F5bCKSKKeImWttII29Rx7fj94apY6ZAAAAA== + headers: + Access-Control-Allow-Methods: + - GET, HEAD, POST, PUT, DELETE, OPTIONS + Access-Control-Allow-Origin: + - "*" + Access-Control-Expose-Headers: + - ETag, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, + Content-Length, Content-Range + Cache-Control: + - public, max-age=28800 + Connection: + - keep-alive + Content-Encoding: + - gzip + Content-Type: + - application/json;charset=utf-8 + Date: + - Fri, 19 Nov 2021 12:36:20 GMT + Server: + - openresty + Transfer-Encoding: + - chunked + Vary: + - Accept-Encoding + Via: + - 1.1 9c46a92c66fe21525310bd5d2f471e46.cloudfront.net (CloudFront) + X-Amz-Cf-Id: + - eGBK3-_IiZnsDjldxkR9DDZX9rq9QJ3aSOotB9ZX7VWpkbUnkDRuTA== + X-Amz-Cf-Pop: + - LHR61-C2 + X-Cache: + - Error from cloudfront + X-Memc: + - MISS + X-Memc-Age: + - "0" + X-Memc-Expires: + - "14687" + X-Memc-Key: + - eae09eb6e89d7ab563e7bd6dc85e159fb173badd + status: + code: 404 + message: Not Found +version: 1 diff --git a/tests/unit/clients/test_tmdb.py b/tests/unit/clients/test_tmdb.py index 6cdb503..fc2860b 100644 --- a/tests/unit/clients/test_tmdb.py +++ b/tests/unit/clients/test_tmdb.py @@ -1,5 +1,7 @@ """Tests for the Tmdb client.""" +import pytest import vcr +from requests.exceptions import HTTPError from tests.conftest import FIXTURES_DIR from phylm.clients.tmdb import TmdbClient @@ -41,3 +43,40 @@ def test_no_results(self) -> None: results = client.search_movies(query="aslkdjaskldjaslkdjaslkdjasd") assert len(results) == 0 + + +class TestStreamingProviders: + """Tests for the `get_streaming_providers` method.""" + + @vcr.use_cassette( + f"{VCR_FIXTURES_DIR}/matrix_providers.yaml", filter_query_parameters=["api_key"] + ) + def test_results(self) -> None: + """ + Given a movie id, + When the `get_streaming_providers` method is invoked with the id, + Then search results are returned from the api and keyed by region name + """ + client = TmdbClient(api_key="dummy_key") + + results = client.get_streaming_providers(movie_id="603", regions=["gb", "fr"]) + + assert "fr" in results + assert "gb" in results + assert "flatrate" in results["gb"] + assert len(results["gb"]["flatrate"]) + + @vcr.use_cassette( + f"{VCR_FIXTURES_DIR}/no_results_providers.yaml", + filter_query_parameters=["api_key"], + ) + def test_no_results(self) -> None: + """ + Given an unrecognized movie id, + When the `get_streaming_providers` method is invoked with the id, + Then search results are returned from the api + """ + client = TmdbClient(api_key="dummy_key") + + with pytest.raises(HTTPError): + client.get_streaming_providers(movie_id="-1", regions=["gb"]) From 464827acbeb53fecf5655b43676bb26d0aee91c5 Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Fri, 19 Nov 2021 14:03:52 +0000 Subject: [PATCH 2/7] add `get_streaming_providers` tool function --- src/phylm/tools.py | 49 ++++++++++++++++++++++++++++------ tests/unit/tools/test_tools.py | 28 +++++++++++++++++++ 2 files changed, 69 insertions(+), 8 deletions(-) diff --git a/src/phylm/tools.py b/src/phylm/tools.py index 9692e0c..bb43644 100644 --- a/src/phylm/tools.py +++ b/src/phylm/tools.py @@ -36,6 +36,26 @@ def search_movies(query: str) -> List[Dict[str, Union[str, int]]]: ] +def _initialize_tmdb_client(api_key: Optional[str] = None) -> TmdbClient: + """Initialize and return a TmdbClient. + + Args: + api_key: an optional api_key to take precedence over an env var key + + Raises: + NoTMDbApiKeyError: when no api_key has been provided + + Returns: + TmdbClient: an authorized Tmdb client + """ + tmdb_api_key = api_key or os.environ.get("TMDB_API_KEY") + + if not tmdb_api_key: + raise NoTMDbApiKeyError("An `api_key` must be provided to use this service") + + return TmdbClient(api_key=tmdb_api_key) + + def search_tmdb_movies( query: str, api_key: Optional[str] = None ) -> List[Dict[str, Any]]: @@ -46,17 +66,30 @@ def search_tmdb_movies( api_key: an api_key can either be provided here or through a TMDB_API_KEY env var - Raises: - NoTMDbApiKeyError: when no api_key has been provided - Returns: List[Dict[str, Any]]: the search results """ - tmdb_api_key = api_key or os.environ.get("TMDB_API_KEY") + client = _initialize_tmdb_client(api_key=api_key) - if not tmdb_api_key: - raise NoTMDbApiKeyError("An `api_key` must be provided to use this service") + return client.search_movies(query=query) - client = TmdbClient(api_key=tmdb_api_key) - return client.search_movies(query=query) +def get_streaming_providers( + tmdb_movie_id: str, + regions: List[str], + api_key: Optional[str] = None, +) -> Dict[str, Any]: + """Return a list of streaming providers for a given movie. + + Args: + tmdb_movie_id: the tmdb id of the movie + regions: a list of regions to trim down the return list + api_key: an api_key can either be provided here or through a TMDB_API_KEY env + var + + Returns: + Dict[str, Any]: a dictionary of streaming providers, keyed by region name + """ + client = _initialize_tmdb_client(api_key=api_key) + + return client.get_streaming_providers(movie_id=tmdb_movie_id, regions=regions) diff --git a/tests/unit/tools/test_tools.py b/tests/unit/tools/test_tools.py index 5fb9a98..fbba66e 100644 --- a/tests/unit/tools/test_tools.py +++ b/tests/unit/tools/test_tools.py @@ -9,6 +9,7 @@ from imdb.Movie import Movie from phylm.errors import NoTMDbApiKeyError +from phylm.tools import get_streaming_providers from phylm.tools import search_movies from phylm.tools import search_tmdb_movies @@ -110,3 +111,30 @@ def test_with_api_key_arg_preferred( assert results == [{"title": "The Matrix"}] mock_tmdb_client_class.assert_called_once_with(api_key=api_key) + + +class TestGetStreamingProviders: + """Tests for the `get_streaming_providers` method.""" + + @patch(f"{TOOLS_MODULE_PATH}.TmdbClient", autospec=True) + def test_success( + self, + mock_initialize_client: MagicMock, + ) -> None: + """ + Given an api_key supplied as an arg, + When the `get_streaming_providers` function is invoked, + Then the results are returned + """ + api_key = "nice_key" + mock_tmdb_client = mock_initialize_client.return_value + mock_tmdb_client.get_streaming_providers.return_value = {"gb": "Netflix"} + + results = get_streaming_providers( + tmdb_movie_id="123", + regions=["gb"], + api_key=api_key, + ) + + assert results == {"gb": "Netflix"} + mock_initialize_client.assert_called_once_with(api_key=api_key) From 1a327ab28a47c75eefc552ebc5fdafbb146a31a7 Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Fri, 19 Nov 2021 14:11:30 +0000 Subject: [PATCH 3/7] add `get_streaming_providers` to the docs --- docs/tools.md | 37 +++++++++++++++++++++++++++++++++---- 1 file changed, 33 insertions(+), 4 deletions(-) diff --git a/docs/tools.md b/docs/tools.md index 91f9e44..45752ee 100644 --- a/docs/tools.md +++ b/docs/tools.md @@ -2,7 +2,7 @@ # Search movies -For a given movie title query you can return a list of search results from `IMDb` +For a given movie title query you can return a list of search results from _IMDb_ through `search_movies`: ```python @@ -31,17 +31,17 @@ through `search_movies`: # TMDB -`phylm` also provides tools to interact with [The Movie Database](https://www.themoviedb.org/) (TMDb). +`phylm` also provides tools to interact with [The Movie Database](https://www.themoviedb.org/) (_TMDb_). !!! info "" - To use TMDB tools you'll need to sign up for an API key, instructions [here](https://developers.themoviedb.org/3). + To use _TMDb_ tools you'll need to sign up for an API key, instructions [here](https://developers.themoviedb.org/3). Once you have your key, export it as an env var called `TMDB_API_KEY` so that it's available to use in these tools. You also have the option of passing in the key as an argument to each function. ## Search movies -For a given movie title query you can return a list of search results from `TMDb` +For a given movie title query you can return a list of search results from _TMDb_ through `search_tmdb_movies`. Note that this search performs a lot quicker than the `imdb` `search_movies`. @@ -72,3 +72,32 @@ through `search_tmdb_movies`. Note that this search performs a lot quicker than rendering: show_signature_annotations: true heading_level: 3 + +## Get streaming providers + +For a given movie _TMDb_ id and list of regions, you can return a list of streaming +providers from _TMDb_ via _Just Watch_ through `get_streaming_providers`. + +```python +>>> from phylm.tools import get_streaming_providers +>>> get_streaming_providers(tmdb_movie_id="438631", regions=["gb"], api_key="abc") +{ + 'gb': { + 'link': 'https://www.themoviedb.org/movie/438631-dune/watch?locale=GB', + 'rent': [{ + 'display_priority': 8, + 'logo_path': '/pZgeSWpfvD59x6sY6stT5c6uc2h.jpg', + 'provider_id': 130, + 'provider_name': 'Sky Store', + }], + }, +} +``` + +Consult the [TMDb docs](https://developers.themoviedb.org/3/movies/get-movie-watch-providers) +for more information on the data that's returned. + +::: phylm.tools.get_streaming_providers + rendering: + show_signature_annotations: true + heading_level: 3 From 021f4c479bd2e5c5663ce923b8d7ce871c88758f Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Fri, 19 Nov 2021 14:13:37 +0000 Subject: [PATCH 4/7] add `types-requests` to nox mypy --- noxfile.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/noxfile.py b/noxfile.py index 1fbaf14..aad758f 100644 --- a/noxfile.py +++ b/noxfile.py @@ -117,7 +117,7 @@ def mypy(session: Session) -> None: """Type-check using mypy.""" args = session.posargs or ["src", "tests"] session.install(".") - session.install("mypy", "pytest") + session.install("mypy", "pytest", "types-requests") session.run("mypy", *args) if not session.posargs: session.run("mypy", f"--python-executable={sys.executable}", "noxfile.py") From 4c03e5d2400f7d8557c9456ceea1b388e7a9386a Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Fri, 19 Nov 2021 14:24:39 +0000 Subject: [PATCH 5/7] fix the types in search_movies request payload --- src/phylm/clients/tmdb.py | 2 +- .../clients/tmdb/no_results.yaml | 8 +- .../clients/tmdb/the_matrix.yaml | 171 +++++++++--------- 3 files changed, 93 insertions(+), 88 deletions(-) diff --git a/src/phylm/clients/tmdb.py b/src/phylm/clients/tmdb.py index 7a41118..8fd7c71 100644 --- a/src/phylm/clients/tmdb.py +++ b/src/phylm/clients/tmdb.py @@ -33,7 +33,7 @@ def search_movies(self, query: str) -> List[Dict[str, Any]]: "api_key": self.api_key, "language": "en-GB", "query": query, - "include_adult": False, + "include_adult": "false", "region": "GB", } res = self.session.get(f"{self._base}/search/movie", params=payload) diff --git a/tests/fixtures/vcr_cassettes/clients/tmdb/no_results.yaml b/tests/fixtures/vcr_cassettes/clients/tmdb/no_results.yaml index 265733c..8195f4b 100644 --- a/tests/fixtures/vcr_cassettes/clients/tmdb/no_results.yaml +++ b/tests/fixtures/vcr_cassettes/clients/tmdb/no_results.yaml @@ -11,7 +11,7 @@ interactions: User-Agent: - python-requests/2.26.0 method: GET - uri: https://api.themoviedb.org/3/search/movie?include_adult=False&language=en-GB&query=aslkdjaskldjaslkdjaslkdjasd®ion=GB + uri: https://api.themoviedb.org/3/search/movie?include_adult=false&language=en-GB&query=aslkdjaskldjaslkdjaslkdjasd®ion=GB response: body: string: !!binary | @@ -34,7 +34,7 @@ interactions: Content-Type: - application/json;charset=utf-8 Date: - - Thu, 18 Nov 2021 13:36:12 GMT + - Fri, 19 Nov 2021 14:23:36 GMT Server: - openresty Transfer-Encoding: @@ -42,9 +42,9 @@ interactions: Vary: - Accept-Encoding Via: - - 1.1 f781469e78b7a441c6f692b1629e1519.cloudfront.net (CloudFront) + - 1.1 68126347056de2d05be3dd362ccba987.cloudfront.net (CloudFront) X-Amz-Cf-Id: - - ZzoH_Hbughh50zblladdE7sdS_RFUstsVkCVQHAykhgmOgpaqP1jmQ== + - MZgNnx0ZejBqMqIgXJ86OP5OtMBnbboSC5jTI8w_I5BKmv2vpMLJLA== X-Amz-Cf-Pop: - LHR50-C1 X-Cache: diff --git a/tests/fixtures/vcr_cassettes/clients/tmdb/the_matrix.yaml b/tests/fixtures/vcr_cassettes/clients/tmdb/the_matrix.yaml index 45c04b0..7f57bfa 100644 --- a/tests/fixtures/vcr_cassettes/clients/tmdb/the_matrix.yaml +++ b/tests/fixtures/vcr_cassettes/clients/tmdb/the_matrix.yaml @@ -11,85 +11,92 @@ interactions: User-Agent: - python-requests/2.26.0 method: GET - uri: https://api.themoviedb.org/3/search/movie?include_adult=False&language=en-GB&query=The+Matrix®ion=GB + uri: https://api.themoviedb.org/3/search/movie?include_adult=false&language=en-GB&query=The+Matrix®ion=GB response: body: string: !!binary | - H4sIAAAAAAAAA8Va227bSpb9lYIeOtOApCPqLvfDgW+xnfhux048GQQlsiSWTbLoKlKy3DhA/8M8 - ze/1l/TaVZSsm5XY5wADBLFNFuu211577V31z1LKh6K05ZVLWpg8ykxp67//WeIBfi1tDXhkRLnU - 5/5DoFX6I+VZWNoq/TY4PejIzuXjyb5+8B9DFd7Uedu/8fbDSfU+HZbKpaFItPghA+qu3i13O93/ - KZdkUNpq1xrlktJyKBMe/Yh4MsztB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4/KnTkTiQstCbhhnfqyDyOqJhhP0NZQ6l/OEsFlKW+o/laFh5Q7531+RiE + E0tX0U9lZut3Nl8uBWkkpGYTMZi/GtDJm+u+chktGAryLie1ZRNVu11ZoU1hE2FsGiwa8pKvVGE4 + tR9guClo0HYRyARQtT2FsRrwGBtBvaoaDvFIWoKbAMKUzijysv8lV7nLp3KtnOI2hR4LGcfUKDez + svMI129nUctzpGR39tuXIsvtASjzPAxYsz1htpOh3KYfFSgUdgJOSmGN2nzjTTFwgS3faAPXEgeV + Sb2Os0100SEvKwmhgL5Pnzopg0jCWCHmeE4NNrb1xvbbUDpoO/VcK5/tUIP+1sJtH1Zb2BqXOzBe + AK2NA08IEO5RaUM2yWEC1PDp8PhHBcmDoVQF8y/pqc6O1GRWv8VCCY20Ots8ZMlgPmbNFeU5i4sA + M7A9em/t64hek1lpjXrvbHMcrgdYHN3AIkdOlduXaEOoy9NOciLKVkGLfVfMEdqmEW/XQlSztX5O + mH+8PGuPLrwW10e7X6/3+f0R908+fQ7V8+1zLarzL5VVf4tF/uJmoij/zk8OPre8M//EdJPoejz6 + 1Puw73sHzW3l/naj3Wu8KC/+nXL/ccrebH7uTdXRIPAC87uNek/1SeoJ4PH0UZiy9dII+sP2dZ19 + gJCD9d+xT4LawJFJ2/5OcqcxcuT4SSQ6wO9hT6bsTEzATlVknxk2a17Pc010mcLkCL3Ias2UMtwy + 77Yf10Ek8mmGX2M4RDw3HpXw1xqPGvW+t46k7vjm020zfn8ZdMQHc3LXTh/H9zwY68OLZxtaelSg + 9xbFzqsK9J3/lyJut/X6rvKnOhfbVwURwUIj13q1zJS1+pnAL3d/seu2PFDGtmxsy1r29HVZ43+5 + 7BbFabNzEPez9K53fRIeRt63s2Zfv7a541dr3H7At5anY+NtwPpJ/48EJmnOfp//d5KW98//A/P2 + pzhmMgAA headers: Access-Control-Allow-Methods: - GET, HEAD, POST, PUT, DELETE, OPTIONS @@ -98,8 +105,6 @@ interactions: Access-Control-Expose-Headers: - ETag, X-RateLimit-Limit, X-RateLimit-Remaining, X-RateLimit-Reset, Retry-After, Content-Length, Content-Range - Age: - - "54" Cache-Control: - public, max-age=600 Connection: @@ -109,7 +114,7 @@ interactions: Content-Type: - application/json;charset=utf-8 Date: - - Thu, 18 Nov 2021 13:32:48 GMT + - Fri, 19 Nov 2021 14:23:26 GMT Server: - openresty Transfer-Encoding: @@ -117,13 +122,13 @@ interactions: Vary: - Accept-Encoding Via: - - 1.1 a4ba6141247f3b441c87ee1a49ec2851.cloudfront.net (CloudFront) + - 1.1 f1b5ae62d9afc4ed1ebb4ac99a508445.cloudfront.net (CloudFront) X-Amz-Cf-Id: - - gF2BvyhPhl7nmCbKnW6QPgVc4yCb8q2BUsuosLPc8u1HFv3dMG1wAw== + - n0cFBejLSVn_QpriksKTnni-WGO0lSz7j7CW62BD2OQ_1co1Wm7CnA== X-Amz-Cf-Pop: - - LHR52-C1 + - LHR50-C1 X-Cache: - - Hit from cloudfront + - Miss from cloudfront status: code: 200 message: OK From 2e76b6ab58253e6eca5bcb40ab5a5dc6b5065d57 Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Fri, 19 Nov 2021 14:28:51 +0000 Subject: [PATCH 6/7] bump version --- pyproject.toml | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/pyproject.toml b/pyproject.toml index 67f1802..de2a0a0 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "phylm" -version = "4.2.2" +version = "4.3.0" description = "Phylm" authors = ["Dom Batten "] license = "MIT" From 39070d1c2b01f097e5358f2984b7d3760b67b891 Mon Sep 17 00:00:00 2001 From: Dom Batten Date: Fri, 19 Nov 2021 14:33:37 +0000 Subject: [PATCH 7/7] add `get_streaming_providers` to docs --- README.md | 22 ++++++++++++++++++++-- 1 file changed, 20 insertions(+), 2 deletions(-) diff --git a/README.md b/README.md index dcfef8e..2a8682b 100644 --- a/README.md +++ b/README.md @@ -32,10 +32,10 @@ pip install phylm 8.7 ``` -`phylm` also provides some tools around movie search results: +`phylm` also provides some tools around movie search results and more: ```python ->>> from phylm.tools import search_movies +>>> from phylm.tools import search_movies, get_streaming_providers >>> search_movies("the matrix") [{ 'title': 'The Matrix', @@ -51,6 +51,24 @@ pip install phylm 'imdb_id': '0234215', }, { ... +>>> get_streaming_providers("0234215", regions=["gb"]) +{ + 'gb': { + 'rent': [{ + 'display_priority': 8, + 'logo_path': '/pZgeSWpfvD59x6sY6stT5c6uc2h.jpg', + 'provider_id': 130, + 'provider_name': 'Sky Store', + }], + 'flatrate': [{ + 'display_priority': 8, + 'logo_path': '/ik9djlxNlex6sY6Kjsundc2h.jpg', + 'provider_id': 87, + 'provider_name': 'Netflix', + }] + }, { + ... +} ``` ## Help