gnosticdev commited on
Commit
e1854f1
verified
1 Parent(s): 9d50291

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +19 -0
app.py CHANGED
@@ -6,6 +6,8 @@ from PIL import Image, ImageDraw
6
  import tempfile
7
  import os
8
  import logging
 
 
9
 
10
  # Configuraci贸n de logging
11
  logging.basicConfig(
@@ -100,6 +102,23 @@ def generate_video(audio_file, image_file):
100
  raise Exception("Error: El archivo de video no se gener贸 correctamente.")
101
 
102
  logger.info(f"Video guardado correctamente: {output_path}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
103
  return output_path # Retornar la ruta completa
104
 
105
  except Exception as e:
 
6
  import tempfile
7
  import os
8
  import logging
9
+ import threading
10
+ import time
11
 
12
  # Configuraci贸n de logging
13
  logging.basicConfig(
 
102
  raise Exception("Error: El archivo de video no se gener贸 correctamente.")
103
 
104
  logger.info(f"Video guardado correctamente: {output_path}")
105
+
106
+ # Programar eliminaci贸n del archivo despu茅s de 30 minutos
107
+ def delete_file_after_delay(file_path, delay_minutes):
108
+ time.sleep(delay_minutes * 60) # Convertir minutos a segundos
109
+ try:
110
+ if os.path.exists(file_path):
111
+ os.remove(file_path)
112
+ logger.info(f"Archivo eliminado: {file_path}")
113
+ temp_dir = os.path.dirname(file_path)
114
+ if os.path.exists(temp_dir):
115
+ os.rmdir(temp_dir)
116
+ logger.info(f"Directorio temporal eliminado: {temp_dir}")
117
+ except Exception as e:
118
+ logger.error(f"Error al eliminar archivo o directorio: {e}")
119
+
120
+ threading.Thread(target=delete_file_after_delay, args=(output_path, 30)).start()
121
+
122
  return output_path # Retornar la ruta completa
123
 
124
  except Exception as e: