From 1326543418b4c9e30d20315edbd1ee4dbd74e0e3 Mon Sep 17 00:00:00 2001 From: ske087 Date: Fri, 1 Aug 2025 10:23:38 +0300 Subject: [PATCH] updated to 4k images from pptx --- app.py | 19 ++++---- instance/dashboard.db | Bin 40960 -> 40960 bytes templates/create_group.html | 45 ++++++++++++++++++ templates/edit_player.html | 7 +++ templates/player_page.html | 8 +++- .../group_player_management.cpython-311.pyc | Bin 16047 -> 16093 bytes utils/__pycache__/uploads.cpython-311.pyc | Bin 18302 -> 17996 bytes utils/group_player_management.py | 5 +- utils/uploads.py | 28 ++++------- 9 files changed, 82 insertions(+), 30 deletions(-) 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 9fbfd2a901bde5a1ff764fad595aef73b6a58707..67f6fdd6d9f7b78a9aa67e00bcef9a62fe0b9b2f 100644 GIT binary patch delta 1033 zcmbu7zfaU)9LC=s<&KKI9>jPdD!kj_(DL?u+v|_X=0xN`Bm^)d5>l@3afiM3DCLkr zk27(XFcJotTpY9sqhWA&adY$!&`slH5tUz;81*}Sm-qR+&+~mY4-%UPiDy@s-mR;J zfnFe$7+&}aIBo}|KMC*nZ|S%E{q7GJcDwhuomZ`ET=bE%65QitD%;n`JiQl*7n2P1 zgDUkxJFNO1oVBJ3x2>r`Ie#5a+?|FKGvnjiL;PoMq$8EhW|=3o?ZNc?<@Qga_4HVe zT3PoVOn63qdbP3alhK)Br&#mX0?nQyF7?Nin~pI=8V_ABtTo&@S(YoLxDkCB;L)Wn zz8?rLgn1#8ev>Zp@A)~tKkCUO`KHmuf`T>a+8Z>0xr*;D+BgT-?N#Vdmxk2A2&*E} zMI=L{nTVJwmXJmaS=mT+f|g~C-myl8VY%v3m|F=JO1?uE$^_}OBx@omYnrGKRTB+N z%cA0FR5pmSXd_*!drP?{T&ugj?NA4n{Q%Za|KlV(Z(_wnvZUnYyn@4I%+~&oeTZ(J zXUn;^SVh&a7Iel~VikNZj4%5SexdCgdJX-bR-3;wZwtkSswvSpi zH|Y^m#u6rmq2sX*7A*ZxZ2r33A0*F(a-@dy2G&OtEGQjka;$X5Ydfn=6yNno3+Zvd zvkVI!ov&jxtiX!D8hUmuZdp*TieckqS4#o4&vaEa2{IKdDH>9BjR)~$01y@qm*a^B gGDU%TzSY{@o6Nkv(UoC^ePKW9fiDH7xYfG#9l+il#{d8T delta 175 zcmV;g08syczyg540+1U42$38^9|!<0V*w2h_y7qB;{Xot56=!B4#W+B3?mBV3+f5u zvk?$w3A39CK>`U{1_u`z83Bb4v*im00h3w^Ad@c*%n2g{2NxF?0fHry1P)!Zg$_Lt zHECF3GE#0sR7q-OR&X*`N;PPBGIM23VrVfkFmy#UZ#FS?GGtdcRZL+sNp&wudM-(1 dNiMVZ9}O_G1b_q(qX>Wyvj{N!AF~87{13_cGXekr 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 830f25c05c875d8178451a9a3a3930ff61607ae2..e4c0fbdd1418fdb6df25784806fb4dab2ef57ae8 100644 GIT binary patch delta 425 zcmZ2qd$*Q%IWI340}x0A^<)%o=ux04Qmm54J*(jZkXB<2^fokA&Yksi`?W1qJoU_lN%*v8964; zmvrJ5DDnm>DRKi6lRwIcPG*#nWE7t)C@ajy0~FHaoUAV;B`FS5Qsf6>X#$C2kb4v+ z$4IF#UYpz~wMgIryU+&)Mpn%mvKk$1S2(05D+-EiHkVdrVw}4+O=Zc|BjK?0W**W;m^}1TZ*Vo)|IeTWv^kZVULF^ zs$l~1*kI~wn2U64*cPx)c2pLfypoxJ@@5HjVfJ`VxI7DzJd>oEGJ8DOc949D7)%ud zLlzH=y?}ReqmU}2?Bw%?QY?%NHSCi&N;)y}PyQllG1*W`M4Y2Y5~#FD7DRY}2u~2< zH91jAn1ut#oLniT!gy@5ytvBbLsE5<6$M2$r${R^G0xiDA^VSsans~>g(Zv!C+jFa zXI!~iL@AVs@$lv>mGvx)r#4Gzrm!)7++44(%*HFr$iPsn10)(4K1fVfP?DIeZSAs| j+w3kLLlrp<*mHyK5Q8HGMDpb}b>-hSVHZoO^SwcS@nY0I{-0=jNvuyzy^MXQW0#AWQ3t)p)B>`vyq zB}5R7ArN^JqcOx8lMw_Hurd0__)Bz=A8oQ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P|TvaueVgKuMN@HG4q`xU3) z`{#mQwGt$?$|W^f>5vL)ZAk|~*M5MTP-$3&85O2MYLC$;2z3{}YH!4r%_S~g=Hf*z zPDtV2*38o)B8Aaydo71c&YrTfr&yVAYuoq=$qU>6*5DVRXUA#R<8qZMiB)ns0e|lB q;!|Mm{MlKL?F(o*^uuB&&$VIK0(uNn7$RM6W&!nM?2tB)eE$bgL9qM) 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}"