From 3ba635cbcaa2213f5dff2778116826f5eeaa7d5b Mon Sep 17 00:00:00 2001 From: lionel <.> Date: Thu, 15 May 2025 22:46:23 +0200 Subject: [PATCH] =?UTF-8?q?[HandBrake=5Frecursive]=20export=5Fxlsx=20sans?= =?UTF-8?q?=20=C3=A9craser=20le=20fichier=20existant?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- HandBrake_recursive/HandBrake_recursive.py | 19 ++++++++++++++----- 1 file changed, 14 insertions(+), 5 deletions(-) diff --git a/HandBrake_recursive/HandBrake_recursive.py b/HandBrake_recursive/HandBrake_recursive.py index bf0f8b1..62dceda 100644 --- a/HandBrake_recursive/HandBrake_recursive.py +++ b/HandBrake_recursive/HandBrake_recursive.py @@ -9,13 +9,15 @@ import math import json import argparse import ffmpeg - +from datetime import datetime import pydbus as dbus import openpyxl from openpyxl.styles import PatternFill from openpyxl.formatting.rule import CellIsRule +date = datetime.now().strftime("%Y-%m-%d_%Hh%M") + def inhibit_arret(application, raison): inhibiteurs = {} @@ -95,10 +97,17 @@ def set_column_width(ws, column_range, width=15): ws.column_dimensions[col].width = width def export_xlsx(lignes, fichier_sortie="résumé.xlsx"): - # Créer un nouveau classeur et sélectionner la feuille active - wb = openpyxl.Workbook() - ws = wb.active - ws.title = "Résumé" + # Charger le classeur existant ou en créer un nouveau + if os.path.exists(fichier_sortie): + wb = openpyxl.load_workbook(fichier_sortie) + else: + wb = openpyxl.Workbook() + # Supprimer la feuille par défaut si on ajoute une nouvelle + default_sheet = wb.active + wb.remove(default_sheet) + + # Créer une nouvelle feuille + ws = wb.create_sheet(title=date) # En-têtes headers = ["Fichier", "Codec", "Résolution", "Action", "Durée", "Taille SRC", "Bitrate SRC",