diff --git a/app.py b/app.py index c8cc333..f70f2b2 100644 --- a/app.py +++ b/app.py @@ -286,17 +286,7 @@ def player_fullscreen(player_id): @login_required @admin_required def delete_player(player_id): - player = Player.query.get_or_404(player_id) - - # Delete all media related to the player - media_items = Content.query.filter_by(player_id=player_id).all() - for media in media_items: - db.session.delete(media) - - # Delete the player - db.session.delete(player) - db.session.commit() - + delete_player_util(player_id) return redirect(url_for('dashboard')) # Update the add_player function diff --git a/enviroment.txt b/enviroment.txt index a3c8edc..4cedbb5 100644 --- a/enviroment.txt +++ b/enviroment.txt @@ -12,4 +12,14 @@ python3 setup.py bdist_wheel flask for installing all the requirements -pip install -r requirements.txt \ No newline at end of file +pip install -r requirements.txt + + + +sudo apt-get update +sudo apt-get install -y \ + ffmpeg \ + libpoppler-cpp-dev \ + poppler-utils \ + libreoffice \ + libmagic1 \ No newline at end of file diff --git a/ppt b/ppt deleted file mode 100644 index a7baa0c..0000000 --- a/ppt +++ /dev/null @@ -1,30 +0,0 @@ -def convert_ppt_to_images(input_file, output_folder): - """ - Converts a PowerPoint file (.ppt or .pptx) to images using LibreOffice. - Each slide is saved as a separate image in the output folder. - """ - if not os.path.exists(output_folder): - os.makedirs(output_folder) - - # Convert the PowerPoint file to images using LibreOffice - command = [ - 'libreoffice', - '--headless', - '--convert-to', 'png', - '--outdir', output_folder, - input_file - ] - try: - subprocess.run(command, check=True, stdout=subprocess.PIPE, stderr=subprocess.PIPE) - print(f"PPT file converted to images: {input_file}") - except subprocess.CalledProcessError as e: - print(f"Error converting PPT to images: {e.stderr.decode()}") - return False - - # Rename the generated images to follow the naming convention - base_name = os.path.splitext(os.path.basename(input_file))[0] - for i, file_name in enumerate(sorted(os.listdir(output_folder))): - if file_name.endswith('.png'): - new_name = f"{base_name}_{i + 1}.png" - os.rename(os.path.join(output_folder, file_name), os.path.join(output_folder, new_name)) - return True \ No newline at end of file diff --git a/requirements.txt b/requirements.txt index 2dfa519..2326d7a 100644 --- a/requirements.txt +++ b/requirements.txt @@ -19,3 +19,7 @@ gunicorn==20.1.0 pdf2image==1.17.0 python-pptx==0.6.21 cairosvg==2.7.0 +Pillow==10.0.1 +ffmpeg-python==0.2.0 +python-magic==0.4.27 +PyPDF2==3.0.1 diff --git a/utils/__pycache__/uploads.cpython-311.pyc b/utils/__pycache__/uploads.cpython-311.pyc index 1c0af4f..4b81569 100644 Binary files a/utils/__pycache__/uploads.cpython-311.pyc and b/utils/__pycache__/uploads.cpython-311.pyc differ diff --git a/utils/uploads.py b/utils/uploads.py index 4547a95..5f80b95 100644 --- a/utils/uploads.py +++ b/utils/uploads.py @@ -40,12 +40,8 @@ def add_image_to_playlist(app, file, filename, duration, target_type, target_id) # Video conversion functions def convert_video(input_file, output_folder): - """ Converts a video file to MP4 format with H.264 codec, 720p resolution, and 30 FPS. - Args: - input_file (str): Path to the input video file. - output_folder (str): Path to the folder where the converted video will be saved. - Returns: - str: Path to the converted video file, or None if conversion fails. + """ + Converts a video file to MP4 format with H.264 codec. """ if not os.path.exists(output_folder): os.makedirs(output_folder) @@ -78,6 +74,9 @@ def convert_video(input_file, output_folder): return None def convert_video_and_update_playlist(app, file_path, original_filename, target_type, target_id, duration): + """ + Converts a video and updates the playlist database. + """ print(f"Starting video conversion for: {file_path}") converted_file = convert_video(file_path, app.config['UPLOAD_FOLDER']) if converted_file: