Update app.py
Browse files
app.py
CHANGED
@@ -2,15 +2,11 @@ import streamlit as st
|
|
2 |
import os
|
3 |
import json
|
4 |
import time
|
5 |
-
from huggingface_hub import list_repo_files, hf_hub_url
|
6 |
|
7 |
BASE_FOLDER = "uploaded_files"
|
8 |
CATEGORIES = ["AVATAR WORLD", "BLOX FRUITS", "TOCA LIFE"]
|
9 |
EXPIRATION_FILE = "expirations.json"
|
10 |
|
11 |
-
# Dataset onde o vídeo generator salva os vídeos
|
12 |
-
DATASET_REPO = "pcdoido2/video-gerados"
|
13 |
-
|
14 |
# --- Estilos CSS ---
|
15 |
st.markdown("""
|
16 |
<style>
|
@@ -69,6 +65,7 @@ def remove_expired_files():
|
|
69 |
|
70 |
# --- Apagar arquivos vencidos ao iniciar ---
|
71 |
remove_expired_files()
|
|
|
72 |
# --- Upload ---
|
73 |
|
74 |
st.header("📤 Upload de Arquivos")
|
@@ -102,14 +99,14 @@ if categoria:
|
|
102 |
st.success("Arquivos enviados com sucesso!")
|
103 |
st.rerun()
|
104 |
|
105 |
-
# --- Lista de Arquivos
|
106 |
-
st.header("📄 Arquivos
|
107 |
|
108 |
for categoria in CATEGORIES:
|
109 |
folder = os.path.join(BASE_FOLDER, categoria)
|
110 |
files = os.listdir(folder)
|
111 |
|
112 |
-
st.subheader(f"📁 {categoria}
|
113 |
|
114 |
if not files:
|
115 |
st.info("Nenhum arquivo na categoria.")
|
@@ -157,42 +154,4 @@ for categoria in CATEGORIES:
|
|
157 |
st.success(f"Arquivo '{file}' baixado e removido.")
|
158 |
st.rerun()
|
159 |
|
160 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
161 |
-
# --- Função para listar arquivos do Dataset ---
|
162 |
-
def listar_arquivos_dataset(categoria):
|
163 |
-
"""
|
164 |
-
Lista arquivos na categoria escolhida do Dataset.
|
165 |
-
"""
|
166 |
-
arquivos = []
|
167 |
-
try:
|
168 |
-
todos_arquivos = list_repo_files(DATASET_REPO, repo_type="dataset")
|
169 |
-
prefixo = f"{categoria}/"
|
170 |
-
|
171 |
-
for arquivo in todos_arquivos:
|
172 |
-
if arquivo.startswith(prefixo):
|
173 |
-
arquivos.append(arquivo[len(prefixo):]) # Remove o prefixo da pasta
|
174 |
-
except Exception as e:
|
175 |
-
st.error(f"Erro ao listar arquivos do Dataset: {e}")
|
176 |
-
return arquivos
|
177 |
-
|
178 |
-
# --- Lista de Arquivos do Dataset ---
|
179 |
-
st.header("🌐 Vídeos Gerados (Dataset)")
|
180 |
-
|
181 |
-
for categoria in CATEGORIES:
|
182 |
-
arquivos_dataset = listar_arquivos_dataset(categoria)
|
183 |
-
|
184 |
-
st.subheader(f"📁 {categoria} (Dataset)")
|
185 |
-
|
186 |
-
if not arquivos_dataset:
|
187 |
-
st.info("Nenhum arquivo nesta categoria no Dataset.")
|
188 |
-
else:
|
189 |
-
for arquivo in arquivos_dataset:
|
190 |
-
url = hf_hub_url(
|
191 |
-
repo_id=DATASET_REPO,
|
192 |
-
filename=f"{categoria}/{arquivo}",
|
193 |
-
repo_type="dataset"
|
194 |
-
)
|
195 |
-
st.markdown(f"<div class='file-box'>", unsafe_allow_html=True)
|
196 |
-
st.markdown(f"<div class='file-name'>{arquivo}</div>", unsafe_allow_html=True)
|
197 |
-
st.markdown(f"[⬇ Download]({url})", unsafe_allow_html=True)
|
198 |
-
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
2 |
import os
|
3 |
import json
|
4 |
import time
|
|
|
5 |
|
6 |
BASE_FOLDER = "uploaded_files"
|
7 |
CATEGORIES = ["AVATAR WORLD", "BLOX FRUITS", "TOCA LIFE"]
|
8 |
EXPIRATION_FILE = "expirations.json"
|
9 |
|
|
|
|
|
|
|
10 |
# --- Estilos CSS ---
|
11 |
st.markdown("""
|
12 |
<style>
|
|
|
65 |
|
66 |
# --- Apagar arquivos vencidos ao iniciar ---
|
67 |
remove_expired_files()
|
68 |
+
|
69 |
# --- Upload ---
|
70 |
|
71 |
st.header("📤 Upload de Arquivos")
|
|
|
99 |
st.success("Arquivos enviados com sucesso!")
|
100 |
st.rerun()
|
101 |
|
102 |
+
# --- Lista de Arquivos agrupada por pasta ---
|
103 |
+
st.header("📄 Arquivos Disponíveis")
|
104 |
|
105 |
for categoria in CATEGORIES:
|
106 |
folder = os.path.join(BASE_FOLDER, categoria)
|
107 |
files = os.listdir(folder)
|
108 |
|
109 |
+
st.subheader(f"📁 {categoria}")
|
110 |
|
111 |
if not files:
|
112 |
st.info("Nenhum arquivo na categoria.")
|
|
|
154 |
st.success(f"Arquivo '{file}' baixado e removido.")
|
155 |
st.rerun()
|
156 |
|
157 |
+
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|