def unset_fav(_id): movies = get_movies() for movie in movies: if movie['id'] == _id: movie['is_fav'] = False break write_movies('movies.json', movies) return redirect('/')
def unwatch_movie(_id): movies = get_movies() for movie in movies: if movie['id'] == _id: movie['is_watch'] = False movie['is_current'] = False break write_movies('movies.json', movies) return redirect('/')
def randomizer(len_movies): movies = get_movies() for movie in movies: try: if movie['is_current']: movie['is_current'] = False except KeyError: movie['is_current'] = False current_movies = movie_selector(1)[0] for movie in movies: if movie['id'] == current_movies['id']: movie['is_current'] = True break write_movies('movies.json', movies) return redirect('/')
def index(): current_movies = get_current_movies() movies = get_movies() total_movies = len(movies) if not current_movies: current_movies = movie_selector(1)[0] for movie in movies: if movie['id'] == current_movies['id']: movie['is_current'] = True break write_movies('movies.json', movies) else: current_movies = current_movies[0] return render_template("index.html", current=current_movies, movies=movies, total_movies=total_movies, rows=int(total_movies / 4))