示例#1
0
def screen_it(movie_id):
    movie_repo = MovieRepository(get_db())
    movie = movie_repo.find_by_id(movie_id)
    if movie is None:
        flash('Requested movie not found')
        return redirect(request.url)

    return render_template('watch/index.html', movie=movie)
示例#2
0
def search_movies(search_text, page, size):
    movie_repo = MovieRepository(get_db())
    if search_text is None:
        movies = movie_repo.find_all(page, size)
    else:
        movies = movie_repo.find_by_keyword(search_text, page, size)

    return jsonify(movies)
示例#3
0
def hsl_fragment(movie_id, file_name):
    movie_repo = MovieRepository(get_db())
    movie = movie_repo.find_by_id(movie_id)

    if movie is None:
        abort(404, "Movie could not be found")

    if movie.is_mp4:
        abort(404,
              "Could not find an HSL converted movie with the provided id")

    file_dir = os.path.join(current_app.config['HLS_DIR'], movie.blob_id)
    return send_from_directory(file_dir, file_name)
示例#4
0
def mp4_video(movie_id):
    movie_repo = MovieRepository(get_db())
    movie = movie_repo.find_by_id(movie_id)

    if movie is None:
        abort(404, "Movie could not be found")

    if not movie.is_mp4:
        abort(404, "Could not find an MP4 movie with the provided id")

    file_path = os.path.join(current_app.config['UPLOAD_FOLDER'],
                             movie.blob_id)
    start, end = get_range(request)
    return partial_response(file_path, start, end)
示例#5
0
def _upload_secured_movie(filename, force_replace, movie_title):
    movie_repo = MovieRepository(get_db())
    filepath = os.path.join(current_app.config['UPLOAD_FOLDER'], filename)
    movie_id = ''
    if 'convert' in request.form:
        model = vidconvert.make_default_req(filename, filepath)
        conversion = vidconvert.convert_mp4(model, force_replace)

        if conversion["succeeded"]:
            new_movie = Movie(title=movie_title,
                              blob_id=filename,
                              is_mp4=False)
            movie_id = movie_repo.insert(new_movie)
        else:
            os.remove(filepath)
            flash(conversion['reason'])
            return redirect(request.url)
    else:
        new_movie = Movie(title=movie_title, blob_id=filename, is_mp4=True)
        movie_id = movie_repo.insert(new_movie)
    return redirect(url_for('upload.uploaded_movie', movie_id=movie_id))
示例#6
0
def index():
    # todo: grab "featured" movies
    movie_repo = MovieRepository(get_db())
    movies = movie_repo.find_all(1, 10)
    return render_template('home/index.html', movies=movies)
示例#7
0
def uploaded_movie(movie_id):
    movie_repo = MovieRepository(get_db())
    movie = movie_repo.find_by_id(movie_id)
    return render_template('upload/movie_uploaded.html', movie=movie)