salomonsky commited on
Commit
7e948ae
·
1 Parent(s): 165e808

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -14
app.py CHANGED
@@ -53,19 +53,17 @@ with st.sidebar:
53
  funciones = [youtube]
54
 
55
  def download_all_button(cut_files):
56
- if st.button("Descargar Todos"):
57
- # Crear un archivo ZIP
58
- zip_buffer = BytesIO()
59
- with zipfile.ZipFile(zip_buffer, 'w') as zip_file:
60
- for cut_file in cut_files:
61
- zip_file.write(cut_file, os.path.basename(cut_file))
62
 
63
- # Generar enlace para descargar el ZIP
64
- zip_filename = 'cortes_videos.zip'
65
- zip_data = zip_buffer.getvalue()
66
- b64 = base64.b64encode(zip_data).decode()
67
- href = f'<a href="data:application/zip;base64,{b64}" download="{zip_filename}">Descargar Todos</a>'
68
- st.markdown(href, unsafe_allow_html=True)
69
 
70
  if seleccionado:
71
  indice = opciones.index(seleccionado)
@@ -92,8 +90,8 @@ if seleccionado:
92
  info_list = [f"{titulo_video}_cut_{i+1}", cut_file, thumbnail_file, cuts[i][0], cuts[i][1]]
93
  session(info_list)
94
 
95
- download_all_button(cut_files) # Esta línea ahora está después de la generación de los archivos de corte
96
- else: # Descargar Completo
97
  if st.button(f"Descargar {seleccionado}"):
98
  video_file, titulo_video, video_info, thumbnail_file = funcion(video_link)
99
  file_size = os.path.getsize(video_file)
 
53
  funciones = [youtube]
54
 
55
  def download_all_button(cut_files):
56
+ st.markdown("### Descargar Todos")
57
+ zip_buffer = BytesIO()
58
+ with zipfile.ZipFile(zip_buffer, 'w') as zip_file:
59
+ for cut_file in cut_files:
60
+ zip_file.write(cut_file, os.path.basename(cut_file))
 
61
 
62
+ zip_filename = 'cortes_videos.zip'
63
+ zip_data = zip_buffer.getvalue()
64
+ b64 = base64.b64encode(zip_data).decode()
65
+ href = f'<a href="data:application/zip;base64,{b64}" download="{zip_filename}">Descargar Todos</a>'
66
+ st.markdown(href, unsafe_allow_html=True)
 
67
 
68
  if seleccionado:
69
  indice = opciones.index(seleccionado)
 
90
  info_list = [f"{titulo_video}_cut_{i+1}", cut_file, thumbnail_file, cuts[i][0], cuts[i][1]]
91
  session(info_list)
92
 
93
+ download_all_button(cut_files)
94
+ else:
95
  if st.button(f"Descargar {seleccionado}"):
96
  video_file, titulo_video, video_info, thumbnail_file = funcion(video_link)
97
  file_size = os.path.getsize(video_file)