-
Notifications
You must be signed in to change notification settings - Fork 1
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Release V1.b: Add login procedure, basic API call and main routes 🎉 (#15
) * Modify username by email and improve auth and register form * Add activation mail with code * Update email password to env.variable * Improve readability of code, add active link in email * Bug fix at check for account already activate * Feature: add the login_required decorator to required routes (#9) * Feature: add the error handling function (#10) * Feature: Add password minimum requirements and checks (#11) * Feature: add the API querying function and parsing request (#13) * Maintenance: removing database from remote (#14) Co-authored-by: HNTQ <[email protected]>
- Loading branch information
1 parent
8a3dc93
commit d0d5063
Showing
18 changed files
with
619 additions
and
56 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
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -145,3 +145,6 @@ dmypy.json | |
# Cython debug symbols | ||
cython_debug/ | ||
|
||
# Database | ||
application.db | ||
|
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.
Oops, something went wrong.
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 @@ | ||
""" | ||
All API queries, parsing, and formatting functions are stored in this file | ||
This project use the TMD API. | ||
""" | ||
import os | ||
import requests | ||
|
||
API_KEY = os.environ.get("API_KEY") | ||
|
||
|
||
# Queries | ||
def query_by_title(title): | ||
"""Will look for all types""" | ||
try: | ||
url = f"https://api.themoviedb.org/3/search/multi?api_key={API_KEY}&query={title}" | ||
response = requests.get(url) | ||
response.raise_for_status() | ||
except requests.RequestException: | ||
return None | ||
|
||
return response.json() | ||
|
||
|
||
# Parse and formats | ||
def parse_query_by_title(response): | ||
""" Will return the data used in search movie for the query by title""" | ||
parsed_response = { | ||
"movies": [], | ||
"series": [] | ||
} | ||
if not response: | ||
return response | ||
|
||
def generic(r): | ||
return { | ||
"id": r["id"], | ||
"poster_path": r["poster_path"], | ||
"backdrop_path": r["backdrop_path"], | ||
"overview": r["overview"], | ||
"media_type": r["media_type"], | ||
"vote_average": r["vote_average"] | ||
} | ||
|
||
for result in response["results"]: | ||
if "movie" in result["media_type"]: | ||
movie_dict = generic(result) | ||
movie_dict["title"] = result["original_title"] | ||
movie_dict["release_date"] = result["release_date"] | ||
parsed_response["movies"].append(movie_dict) | ||
elif "tv" in result["media_type"]: | ||
series_dict = generic(result) | ||
movie_dict["title"] = result["name"] | ||
parsed_response["series"].append(series_dict) | ||
|
||
return parsed_response |
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
Binary file not shown.
Oops, something went wrong.