rpiwebapp-public/movies/movies.py
Matthew Welch 308b1e1791 Re-structured code and added search feature for comics.
The project structure has been changed to make it more manageable and modular. A search feature has been added to the comics page.
2019-07-23 15:50:25 -07:00

81 lines
2.6 KiB
Python

from flask import Blueprint, render_template, request, make_response, send_file, send_from_directory
from flask_login import login_required
from urllib import parse
from io import BytesIO
from wand.image import Image
import os, pytz, datetime
from scripts import database, func
Movies = Blueprint("movies", __name__, template_folder="templates")
@Movies.route("/movies")
@login_required
def index():
return render_template("movies/index.html", title="Movies", movies=database.db_get_all_movies())
@Movies.route("/movies/<imdb_id>")
@login_required
def movie_view(imdb_id):
try:
movie_data = database.db_get_movie_by_imdb_id(imdb_id)
return render_template("movies/movieViewer.html", title="Movies: " + movie_data["title"], movie=movie_data)
except Exception as e:
print(e)
return str(e)
@Movies.route("/movies/<imdb_id>/extended")
@login_required
def movie_view_extended(imdb_id):
try:
movie_data = database.db_get_movie_by_imdb_id(imdb_id, extended=1)
return render_template("movies/movieViewer.html", title="Movies: " + movie_data["title"], movie=movie_data)
except Exception as e:
print(e)
return str(e)
@Movies.route("/movies/<imdb_id>/directors_cut")
@login_required
def movie_view_directors_cut(imdb_id):
try:
movie_data = database.db_get_movie_by_imdb_id(imdb_id, directors_cut=1)
return render_template("movies/movieViewer.html", title="Movies: " + movie_data["title"], movie=movie_data)
except Exception as e:
print(e)
return str(e)
@Movies.route("/movies/get_movie/<imdb_id>")
@login_required
def get_movie(imdb_id):
movie_data = database.db_get_movie_by_imdb_id(imdb_id)
filename = movie_data["title"]+" ("+str(movie_data["year"])+").mkv"
response = make_response(send_from_directory(func.MOVIES_DIRECTORY, filename))
response.headers["content-type"] = "video/webm"
return response
@Movies.route("/movies/get_movie/<imdb_id>/extended")
@login_required
def get_movie_extended(imdb_id):
movie_data = database.db_get_movie_by_imdb_id(imdb_id, extended=1)
filename = movie_data["title"]+" ("+str(movie_data["year"])+").mkv"
response = make_response(send_from_directory(func.MOVIES_DIRECTORY, filename))
response.headers["content-type"] = "video/webm"
return response
@Movies.route("/movies/get_movie/<imdb_id>/directors_cut")
@login_required
def get_movie_directors_cut(imdb_id):
movie_data = database.db_get_movie_by_imdb_id(imdb_id, directors_cut=1)
filename = movie_data["title"]+" ("+str(movie_data["year"])+").mkv"
response = make_response(send_from_directory(func.MOVIES_DIRECTORY, filename))
response.headers["content-type"] = "video/webm"
return response