-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #36 from dbatten5/tmdb
Tmdb
- Loading branch information
Showing
13 changed files
with
430 additions
and
10 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,6 +1,6 @@ | ||
[tool.poetry] | ||
name = "phylm" | ||
version = "4.1.0" | ||
version = "4.2.0" | ||
description = "Phylm" | ||
authors = ["Dom Batten <[email protected]>"] | ||
license = "MIT" | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1 @@ | ||
"""Clients.""" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
"""Client to interact with The Movie DB (TMDB).""" | ||
from typing import Any | ||
from typing import Dict | ||
from typing import List | ||
|
||
from requests import Session | ||
|
||
|
||
class TmdbClient: | ||
"""Class to abstract to the Tmdb API.""" | ||
|
||
def __init__(self, api_key: str) -> None: | ||
"""Initialize the client. | ||
Args: | ||
api_key: an api_key for authentication | ||
""" | ||
super().__init__() | ||
self.session = Session() | ||
self.api_key = api_key | ||
self._base = "https://api.themoviedb.org/3" | ||
|
||
def search_movies(self, query: str) -> List[Dict[str, Any]]: | ||
"""Search for movies. | ||
Args: | ||
query: the search query | ||
Returns: | ||
Any: the search results | ||
""" | ||
payload = { | ||
"api_key": self.api_key, | ||
"language": "en-GB", | ||
"query": query, | ||
"include_adult": False, | ||
"region": "GB", | ||
} | ||
res = self.session.get(f"{self._base}/search/movie", params=payload) | ||
results: List[Dict[str, Any]] = res.json()["results"] | ||
return results |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,55 @@ | ||
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/search/movie?include_adult=False&language=en-GB&query=aslkdjaskldjaslkdjaslkdjasd®ion=GB | ||
response: | ||
body: | ||
string: !!binary | | ||
H4sIAAAAAAAAA6tWKkhMT1WyMtRRKkotLs0pKVayio7VUSrJL0nMiQfJAQUMYHy4EoNaALNPV645 | ||
AAAA | ||
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=600 | ||
Connection: | ||
- keep-alive | ||
Content-Encoding: | ||
- gzip | ||
Content-Type: | ||
- application/json;charset=utf-8 | ||
Date: | ||
- Thu, 18 Nov 2021 13:36:12 GMT | ||
Server: | ||
- openresty | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Accept-Encoding | ||
Via: | ||
- 1.1 f781469e78b7a441c6f692b1629e1519.cloudfront.net (CloudFront) | ||
X-Amz-Cf-Id: | ||
- ZzoH_Hbughh50zblladdE7sdS_RFUstsVkCVQHAykhgmOgpaqP1jmQ== | ||
X-Amz-Cf-Pop: | ||
- LHR50-C1 | ||
X-Cache: | ||
- Miss from cloudfront | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
130 changes: 130 additions & 0 deletions
130
tests/fixtures/vcr_cassettes/clients/tmdb/the_matrix.yaml
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,130 @@ | ||
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/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/Yh4MsztBEoiKc29yGQW0dPrULATnmn5RG9HQo+kGOP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gp+tYUMujxGBQZF0VqNnI7tIyUMKCBQrWShE+Jcd8uEapaRBFGussZqqtgyg8Na | ||
8NW/1M8ncX7RyXaCi6iW9M6/jjZVITsVrzFn7zdtz/9DWG/+BdWBLXvD55IElomR8+xP39ACXYGO | ||
UYFuWai9JO+M9ylS2BBQ1DKnIXZtfrhivra36rD1L1edPD9ptPejXpo8dG+Pg4PQ+3ra6On3noi+ | ||
Z8lvuqDR+QO2yRRE6Q+6Yw+rNaZ/z67aN70//gPY7Egugi8AAA== | ||
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 | ||
Age: | ||
- "54" | ||
Cache-Control: | ||
- public, max-age=600 | ||
Connection: | ||
- keep-alive | ||
Content-Encoding: | ||
- gzip | ||
Content-Type: | ||
- application/json;charset=utf-8 | ||
Date: | ||
- Thu, 18 Nov 2021 13:32:48 GMT | ||
Server: | ||
- openresty | ||
Transfer-Encoding: | ||
- chunked | ||
Vary: | ||
- Accept-Encoding | ||
Via: | ||
- 1.1 a4ba6141247f3b441c87ee1a49ec2851.cloudfront.net (CloudFront) | ||
X-Amz-Cf-Id: | ||
- gF2BvyhPhl7nmCbKnW6QPgVc4yCb8q2BUsuosLPc8u1HFv3dMG1wAw== | ||
X-Amz-Cf-Pop: | ||
- LHR52-C1 | ||
X-Cache: | ||
- Hit from cloudfront | ||
status: | ||
code: 200 | ||
message: OK | ||
version: 1 |
Empty file.
Oops, something went wrong.