def add_movie(name,year, minutes, category_id): db.connect() category = db.get_category(category_id) movie = Movie(name=name, year=year, minutes=minutes, category=category) db.add_movie(movie) print(name + " was added to database.\n")
def main(): display_welcome() try: movies = db.read_movies() except DataAccessError as e: print("DataAccessError:", e) print("Terminating program.") sys.exit() while True: command = input("Command: ") if command == "list": display_movies(movies) elif command == "add": movie = get_movie() db.add_movie(movies, movie) print(movie[0] + " was added.\n") elif command == "del": number = get_movie_number(movies) movie = db.delete_movie(movies, number - 1) print(movie[0] + " was deleted.\n") elif command == "exit": break else: print("Not a valid command. Please try again.\n") print("Bye!")
def add_movie(): name = input("Name: ") year = int(input("Year: ")) minutes = int(input("Minutes: ")) category_id = int(input("Category ID: ")) category = db.get_category(category_id) movie = Movie(name=name, year=year, minutes=minutes, category=category) db.add_movie(movie) print(name + " was added to database.\n")
def add_movie(): name = input("Name: ") year = int(input("Year: ")) minutes = int(input("Minutes: ")) category_id = int(input("Category ID: ")) category = db.get_category(category_id) if category == None: print("There is no category with that ID. Movie NOT added.\n") else: movie = Movie(name=name, year=year, minutes=minutes, category=category) db.add_movie(movie) print(name + " was added to database.\n")
def saveMovie(self): movieTitle = self.movieTitle.get() year = int(self.year.get()) category = self.category.get() minutes = int(self.minutes.get()) category = db.get_category_by_name(category) movie = Movie(name=movieTitle, year=year, minutes=minutes, category=category) db.add_movie(movie) self.confirmMovieAdd(movieTitle) mof = MovieOutputFrame(self) mof.refresh_record_view()
def movie_save(id): name = request.form['name'] category = request.form['category'] genre = request.form['genre'] tags = request.form['tags'] poster = request.form['poster'] db.remove_movie_by_id(DATABASE_URL, id) movie = db.add_movie(DATABASE_URL, id) return redirect(url_for('movie_details', id=movie['id']))
def movie_add(): name = request.form['name'] category = request.form['category'] genre = request.form['genre'] tags = request.form['tags'] poster = request.form['poster'] movie = db.add_movie(DATABASE_URL, name, category, genre, tags, poster) # if request.method == 'POST': # file = request.files['file'] # if file and allowed_file(file.filename): # filename = secure_filename(file.filename) # file.save(os.path.join(app.config['UPLOAD_FOLDER'], filename)) # return redirect(url_for('movie_details', # id=movie, filename=filename)) return redirect(url_for('movie_details', id=movie))
6. exit Your selection: """ welcome = "Welcome to the watchlist app!" db.create_tables() print(welcome) while ((user_input := input(menu)) != '6'): if user_input == "1": title = input("What is the title of the movie? ") release = input("What is the movie realse date in mm-dd-yr ") db.add_movie(title, release) elif user_input == "2": if db.get_upcoming_movies() != None: for movie in db.get_upcoming_movies(): print(movie) elif user_input == "3": for movie in db.get_all_movies(): print(movie) elif user_input == "4": watched = input("What movie would you like to watch? ").strip() for movie in db.get_all_movies(): if movie[0] == watched: db.watch_movie(watched)