diff --git a/app.py b/app.py index 78d263c..584e58b 100755 --- a/app.py +++ b/app.py @@ -327,7 +327,8 @@ def edit_player(player_id): hostname = request.form['hostname'] password = request.form['password'] if request.form['password'] else None quickconnect_password = request.form['quickconnect_password'] if request.form['quickconnect_password'] else None - edit_player_util(player_id, username, hostname, password, quickconnect_password) + orientation = request.form.get('orientation', player.orientation) # <-- Get orientation + edit_player_util(player_id, username, hostname, password, quickconnect_password, orientation) # <-- Pass orientation flash(f'Player "{username}" updated successfully.', 'success') return redirect(url_for('player_page', player_id=player.id)) @@ -648,14 +649,14 @@ def create_admin(username, password): from models.create_default_user import create_default_user -with app.app_context(): - try: - db.session.execute(db.select(User).limit(1)) - except Exception as e: - print("Database not initialized or missing tables. Re-initializing...") - db.create_all() - # Always ensure default user exists - create_default_user(db, User, bcrypt) +if not app.debug or os.environ.get('WERKZEUG_RUN_MAIN') == 'true': + with app.app_context(): + try: + db.session.execute(db.select(User).limit(1)) + except Exception as e: + print("Database not initialized or missing tables. Re-initializing...") + db.create_all() + create_default_user(db, User, bcrypt) # Add this at the end of app.py if __name__ == '__main__': diff --git a/instance/dashboard.db b/instance/dashboard.db index 9fbfd2a..67f6fdd 100644 Binary files a/instance/dashboard.db and b/instance/dashboard.db differ diff --git a/templates/create_group.html b/templates/create_group.html index 748ee56..8545775 100644 --- a/templates/create_group.html +++ b/templates/create_group.html @@ -49,11 +49,23 @@ +
+
+ + +
+
+
Back to Dashboard @@ -61,5 +73,38 @@
+ \ No newline at end of file diff --git a/templates/edit_player.html b/templates/edit_player.html index 56ed80b..8fa17d0 100644 --- a/templates/edit_player.html +++ b/templates/edit_player.html @@ -60,6 +60,13 @@ +
+ + +
Back to Player Page diff --git a/templates/player_page.html b/templates/player_page.html index a4b0a3b..3ba5814 100644 --- a/templates/player_page.html +++ b/templates/player_page.html @@ -106,8 +106,12 @@ ☰
- -
+ +
+ thumbnail

Media Name: {{ media.file_name }}

diff --git a/utils/__pycache__/group_player_management.cpython-311.pyc b/utils/__pycache__/group_player_management.cpython-311.pyc index 830f25c..e4c0fbd 100644 Binary files a/utils/__pycache__/group_player_management.cpython-311.pyc and b/utils/__pycache__/group_player_management.cpython-311.pyc differ diff --git a/utils/__pycache__/uploads.cpython-311.pyc b/utils/__pycache__/uploads.cpython-311.pyc index 22b1f34..5ebc474 100644 Binary files a/utils/__pycache__/uploads.cpython-311.pyc and b/utils/__pycache__/uploads.cpython-311.pyc differ diff --git a/utils/group_player_management.py b/utils/group_player_management.py index cdd1d32..2d4c960 100644 --- a/utils/group_player_management.py +++ b/utils/group_player_management.py @@ -130,7 +130,7 @@ def add_player(username, hostname, password, quickconnect_password, orientation= log_player_created(username, hostname) return new_player -def edit_player(player_id, username, hostname, password=None, quickconnect_password=None): +def edit_player(player_id, username, hostname, password=None, quickconnect_password=None, orientation=None): """ Edit an existing player's details. """ @@ -147,6 +147,9 @@ def edit_player(player_id, username, hostname, password=None, quickconnect_passw if quickconnect_password: player.quickconnect_password = bcrypt.generate_password_hash(quickconnect_password).decode('utf-8') + if orientation: + player.orientation = orientation + db.session.commit() log_player_edited(username) return player diff --git a/utils/uploads.py b/utils/uploads.py index f7d27a6..2d0ab53 100644 --- a/utils/uploads.py +++ b/utils/uploads.py @@ -105,23 +105,14 @@ def convert_video_and_update_playlist(app, file_path, original_filename, target_ print(f"Video conversion failed for: {file_path}") # PDF conversion functions -def convert_pdf_to_images(pdf_file, output_folder, delete_pdf=True): +def convert_pdf_to_images(pdf_file, output_folder, delete_pdf=True, dpi=600): """ - Convert a PDF file to images in sequential order. - - Args: - pdf_file (str): Path to the PDF file - output_folder (str): Path to save the images - delete_pdf (bool): Whether to delete the PDF file after processing - - Returns: - list: List of generated image filenames in page order, or empty list if conversion failed + Convert a PDF file to images in sequential order at high resolution (4K). """ - print(f"Converting PDF to images: {pdf_file}") + print(f"Converting PDF to images: {pdf_file} at {dpi} DPI") try: # Convert PDF to images - images = convert_from_path(pdf_file, dpi=300) - print(f"Number of pages in PDF: {len(images)}") + images = convert_from_path(pdf_file, dpi=dpi) base_name = os.path.splitext(os.path.basename(pdf_file))[0] image_filenames = [] @@ -240,6 +231,7 @@ def process_pptx(input_file, output_folder, duration, target_type, target_id): '--headless', '--convert-to', 'pdf', '--outdir', output_folder, + '--printer-resolution', '600', input_file ] @@ -251,7 +243,7 @@ def process_pptx(input_file, output_folder, duration, target_type, target_id): print(f"LibreOffice errors (if any): {result.stderr.decode()}") # Step 2: Convert PDF to images and update playlist - image_filenames = convert_pdf_to_images(pdf_file, output_folder, True) + image_filenames = convert_pdf_to_images(pdf_file, output_folder, True, dpi=600) # Verify we got images if not image_filenames: @@ -306,7 +298,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target if media_type == 'image': add_image_to_playlist(app, file, filename, duration, target_type, target_id) result['message'] = f"Image {filename} added to playlist" - log_upload('image', filename, target_type, target_name) + log_upload('image', filename, target_type, target_id) elif media_type == 'video': # For videos, add to playlist then start conversion in background @@ -329,7 +321,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target threading.Thread(target=convert_video_and_update_playlist, args=(app, file_path, filename, target_type, target_id, duration)).start() result['message'] = f"Video {filename} added to playlist and being processed" - log_upload('video', filename, target_type, target_name) + log_upload('video', filename, target_type, target_id) elif media_type == 'pdf': # For PDFs, convert to images and update playlist @@ -337,7 +329,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target duration, target_type, target_id) if success: result['message'] = f"PDF {filename} processed successfully" - log_process('pdf', filename, target_type, target_name) + log_process('pdf', filename, target_type, target_id) else: result['success'] = False result['message'] = f"Error processing PDF file: {filename}" @@ -348,7 +340,7 @@ def process_uploaded_files(app, files, media_type, duration, target_type, target duration, target_type, target_id) if success: result['message'] = f"PowerPoint {filename} processed successfully" - log_process('ppt', filename, target_type, target_name) + log_process('ppt', filename, target_type, target_id) else: result['success'] = False result['message'] = f"Error processing PowerPoint file: {filename}"