def search_movie_by_title(): title = request.args["title"] print(title) movie_list = movies.get_movie_list(title) if movie_list == 0: title = "Movie: " + title + "is not in the database" return render_template("error.html", message=title) return render_template("movielist.html", title="Search result for: " + title, movies=movie_list)
def main(): if request.method == "GET": movie_list = movies.get_movie_list() return render_template("main.html", movies=movie_list) if request.method == "POST": sort = request.form.get("sort") if sort == "newest": movie_list = movies.get_movie_list_newest() elif sort == "oldest": movie_list = movies.get_movie_list_oldest() elif sort == "best": movie_list = movies.get_movie_list_best() elif sort == "worst": movie_list = movies.get_movie_list_worst() elif sort == "latest": movie_list = movies.get_movie_list() else: movie_list = movies.get_movie_list() return render_template("main.html", movies=movie_list)
def first_time(user): user_rating = ask_user() movie_list = get_movie_list() #this part will need to be changed, i added a new class called movies.py so that i dont need to run the scraper everytime to get the movie info order_in_preference = [] for item in user_rating: for movie in movie_list: if item['Genre'] in movie['Genre'] and movie not in order_in_preference: order_in_preference.append(movie) print("--------------------------------------------------------------") print("Based on your prefernces, we recommend that you watch one of the following movies:") limit = min(5,len(order_in_preference)) for i in range (0,limit): print(f"{i+1}. " + order_in_preference[i]['Original_title']) watched = int(input(f"Which movie (1-{limit}) have you watched?\n")) while True: if watched < 1 or watched > limit: watched = int(input(f"Please select a number between 1 and {limit}:\n")) else: break print(f"Your selection ({order_in_preference[watched-1]['Original_title'].strip()}) has been saved!") with DatabaseHandler(user) as db: db.store(order_in_preference[watched-1])
from wtforms import StringField, IntegerField from wtforms.validators import DataRequired from movies import get_movie_list, match_movie from recommender import get_recommendations from database_handler import DatabaseHandler SECRET_KEY = os.urandom(32) app = Flask(__name__) app.config['SECRET_KEY'] = SECRET_KEY class MyForm(FlaskForm): name = StringField('Title', validators=[DataRequired()]) rating = IntegerField('Rating', validators=[DataRequired()]) movies_list = get_movie_list() @app.route('/') @app.route('/home') def home(): return render_template('home.html', title='Home') @app.route('/history', methods=['GET', 'POST']) def add_to_history(): if request.method == 'POST': title = request.form['name'] rating = request.form['rating'] #print("POSTing title: " + title + " with rating: " + rating) movie = match_movie(title, movies_list)
import movies import fresh_tomatoes # Get the list of movies to be displayed movies = movies.get_movie_list() # Pass the movies List to be viewed on the browser fresh_tomatoes.open_movies_page(movies)