Skip to content

Movies Library Metadata Explorer using Django and Django REST framework

License

Notifications You must be signed in to change notification settings

japinol7/movies_lib_explorer

Repository files navigation

Movies Library Metadata Explorer - MLME

Movies Library Metadata Explorer using Django.
It includes a REST API for the catalog models using Django REST Framework.

About the demo data: All the MLME demo metadata has been entered
manually over the years as a hobby by the author of MLME.

Starting with version 0.1.0, MLME includes a TMDB integration with
the TMDB REST API that the user can use to get movie data from TMDB.

  • Regarding the TMDB integration:
    • This product uses the TMDB API but is not endorsed or certified by TMDB
    • You will need to get a TMDB API access token to use this integration:
      https://api.themoviedb.org

The program

program: MLME. Movies Library Metadata Explorer using Django.
name as a package: movies_lib_explorer 
version: 0.1.4
author: Joan A. Pinol
author_nickname: japinol
author_gitHub: japinol7
author_twitter: @japinol
Python requires: 3.12 or greater.

Screenshots
















Starting with version 0.1.3 you can export the movie data to Excel




Catalog Directors REST API

http://127.0.0.1:8000/catalog/api/v1/directors
http://127.0.0.1:8000/catalog/api/v1/directors/1

Catalog Actors REST API

http://127.0.0.1:8000/catalog/api/v1/actors
http://127.0.0.1:8000/catalog/api/v1/actors/27

Similar to directors REST API. For example:

Catalog Movies REST API

http://127.0.0.1:8000/catalog/api/v1/movies
http://127.0.0.1:8000/catalog/api/v1/movies/1

Catalog Movies REST API - Format as XML instead of JSON

Similar to previous examples but adding format=xml. For example:

How to create a token to authenticate on the REST API

How to create a token for a given user; for example, the admin user

./manage.py drf_create_token admin

  • Then set an env variable MLME_REST_API_TOKEN to the generated token

How to ask a token to the API for a given user

  • First, set env variables for the username and their password: MLME_USERNAME, MLME_PASSWORD .
  • Then:
    curl -i http://127.0.0.1:8000/catalog/api/v1/token-auth \
    -X POST \
    -d 'username='$MLME_USERNAME \
    -d 'password='$MLME_PASSWORD
  • Then set an env variable MLME_REST_API_TOKEN to the generated token

Default API settings

  • Pagination
    API_PAGE_SIZE = 300

  • Throttling for anonymous and authorized users
    API_DEFAULT_THROTTLE_RATES_ANON = '300/day'
    API_DEFAULT_THROTTLE_RATES_USER = '30/minute'


Default local url

http://127.0.0.1:8000/

User Guide

  • Only staff users have permission to edit catalog data. This includes uploading photos.
    So, the following buttons are hidden from no-staff users: [Edit]   [Upload ... Photo]
  • Any user can add a movie review and edit the reviews they wrote.

To run the tests for this project

  • You need to run the tests using the test settings file this way:
    python manage.py test --settings=movies_lib_explorer.test_settings

To make this app server work - Quick start with data already loaded

Do this:
    1. Clone this repository in your local system.
    2. Go to its folder in your system.
    3. $ pip install -r requirements.txt
    4. Follow the instructions we put in this file regarding the django app secret key
       ./extras/movies_lib_explorer_secret_keys/movies_lib_explorer_secret_key.key
    5. Optional; only if you want to use the TMDB integration: 
          Follow the instructions we put in this file regarding the TMDB API key
           ./extras/movies_lib_explorer_secret_keys/tmdb_api_key.key  
    6. The first time you must create/update the database with the right tables this way:
       $ python manage.py migrate
       4.1 You can also create an admin user this way, so you can log in, create other users, etc:
          $ python manage.py createsuperuser
    7. Run as local environment:
       $ python manage.py runserver --settings=movies_lib_explorer.local_settings
    8. Open the website indicated in the console in your browser.
       Example: http://127.0.0.1:8000/



To make this app server work - Recommended steps

Do this:
    1. Clone this repository in your local system.
    2. Go to its folder in your system.
       2.1 Delete the demo database file: db.sqlite3
    3. $ pip install -r requirements.txt
    4. Follow the instructions we put in this file regarding the django app secret key
       ./extras/movies_lib_explorer_secret_keys/movies_lib_explorer_secret_key.key
    5. Optional; only if you want to use the TMDB integration: 
          Follow the instructions we put in this file regarding the TMDB API key
           ./extras/movies_lib_explorer_secret_keys/tmdb_api_key.key  
    6. The first time you must create a new database with the right tables this way:
       $ python manage.py migrate
       4.1 You can also create an admin user this way, so you can log in, create other users, etc:
          $ python manage.py createsuperuser
    7. Run as local environment:
       $ python manage.py runserver --settings=movies_lib_explorer.local_settings
    8. Open the website indicated in the console in your browser.
       Example: http://127.0.0.1:8000/
    9. The first time, press the button [Load Initial Data] on the main web page.
       This imports sample data with several movies, directors and actors.
       This also creates links between actors and movies.