An application that allows you to search for similar movies or TV series. And also allows you to browse popular movies and upcoming premieres. The user can save the videos to his profile.
The user can enter his movie or series and then a list of similar movies will be returned to him. In this section user can add any video to his profile as "to watch" or "watched"
This section allows the user to view a list of upcoming releases. The whole is divided into many pages thanks to pagination.
This section allows the user to view the list of the most popular videos. The whole is divided into many pages thanks to pagination.
@property
@lru_cache(maxsize=128)
def return_id(self) -> Union[str, None]:
""" This method returns user movie ID """
base_url = f"https://api.themoviedb.org/3/search/{self.type}?api_key="
result = get(base_url + self.api_key + "&query=" + self.create_query())
json_result = json.loads(result.content)
data = json_result['results']
if result.status_code == 200:
try:
return str(data[0]['id'])
except KeyError:
return "None"
else:
raise Exception(f"Status code {result.status_code}")
Also I used @lru_cache decorator to increase efficienty of requests to the API.
Here is some tests that I did to compere the efficienty with @lru_cache and without it.
- Python (Flash)
- HTML & Bootstrap
- Rest API
Movie data is retrieved from the API provided by themoviedb
Clone the repository
git clone <link>
Install the requirements
pip install -r requirements.txt
Inside similar_movies folder add .env file. It should looks like this:
MOVIEDB_API_KEY=
SECRET_KEY=<SOME RANDOM CHARACTERS>
EMAIL_USERNAME=<GMAIL EMAIL>
EMAIL_PASSWORD=<GMAIL PASSWORD>
Key api you can get here: https://www.themoviedb.org/documentation/api
Password for your Gmail account you can get here: https://bit.ly/3lj3dhQ
Run the application by using this command
python main.py
To run tests, run the following command
pytest