MovieRanker is a prototype web application written in Django. Its primary goal is to help users discover movies tailored to their preferences using The Movie Database (TMDB) API.
- Integration with TMDB API: Fetch movie genres, ranks, and other details using TMDB API endpoints.
- Genre Filtering: Filter movies by selecting genres from a dropdown menu.
- Dynamic Movie List: Display a ranked list of movies based on the selected genre.
- Movie Details Page: View detailed information about a selected movie.
-
api.py
:- Interacts with the TMDB API.
- Fetches genres, movies by genre, and detailed movie information.
-
views.py
:- Handles user requests and business logic.
- Includes views for the movie list and movie details.
-
models.py
:- Defines the data structure for movies.
-
movie_list.html
:- Frontend template for viewing and filtering movies by genre.
-
movie_details.html
:- Frontend template for displaying detailed information about a specific movie.
Follow these steps to set up and run MovieRanker locally:
- Python 3.9 or higher
- Django installed
- TMDB API Key (for API integration)
-
Clone the Repository:
git clone https://github.com/Mike014/MovieRanker.git cd MovieRanker
-
Set Up a Virtual Environment:
python3 -m venv venv source venv/bin/activate # Mac/Linux venv\\Scripts\\activate # Windows
-
Install Dependencies:
pip install -r requirements.txt
-
Run Database Migrations:
python manage.py migrate
-
Set Up TMDB API Key: • Create a .env file in the root directory. • Add your TMDB API key:
TMDB_API_KEY=your_api_key_here
-
Run the Development Server:
python manage.py runserver
-
Access the Application:
http://127.0.0.1:8000/
-
This project uses Pylint, Black, and isort for linting and formatting. Pre-commit hooks are set up to enforce these standards.
- Install pre-commit:
pip install pre-commit pre-commit install
- Run pre-commit hooks:
pre-commit run --all-files
To run tests, use:
pytest
Using Tox Tox is configured to automate testing and linting:
tox
GitHub Actions The project includes a GitHub Actions workflow for automated testing and linting. The configuration is in .github/workflows/lint-and-test.yml.
Running Django Tests To run Django tests for the Movies app and discover any bugs, you can use the following command:
python manage.py test movies
- Install pre-commit:
-
Fetch Genre List:
https://api.themoviedb.org/3/genre/movie/list
-
Discover Movies by Genre:
https://api.themoviedb.org/3/discover/movie
-
Get Movie Details:
https://api.themoviedb.org/3/movie/{movie_id}
-
Fetch Similar Movies:
https://api.themoviedb.org/3/movie/{movie_id}/similar
-
Install Docker:
- Visit Docker Desktop and download the version for your operating system (Windows, macOS, Linux).
- Follow the installation instructions.
-
Start a PostgreSQL Container:
docker run --name postgres -e POSTGRES_PASSWORD=your_password_here -d -p 5432:5432 postgres
-
Verify the PostgreSQL Container is Running::
docker ps
- Displays all active containers.
-
Test Database Connection::
docker ps
OR
python manage.py dbshell
- Perform Database Migrations
python manage.py makemigrations python manage.py migrate
- First i have created a Custom Management Command:
movies/
management/
__init__.py
commands/
__init__.py
query_movies.py
- To run the command, use:
python manage.py query_movies --type all
- Check in the query_mvovies.py which command you can use for querying the database
- The documentation for MovieRanker is available at: MovieRanker Documentation
- Created a new requirements.txt file with command:
pip install pipreqs
pipreqs .
- created docker file, you can buld the image with this command:
docker build . -t movies:latest && docker run -e PYTHONUNBUFFERED=1 -p 8000:8000 movies
- Go to Link
- Implement content-based and collaborative filtering for advanced movie recommendations.
- Enhance user interface and add user authentication.
- Deploy the application on a cloud platform.
This project is licensed under the MIT License.
Contributions are welcome! Feel free to fork the repository and submit pull requests.
Maintainer: Michele Grimaldi GitHub: Mike014Mike014