Update app.py
Browse files
app.py
CHANGED
|
@@ -113,6 +113,9 @@ st.subheader("Selecione uma categoria:")
|
|
| 113 |
categoria = st.radio("Categoria:", CATEGORIES, index=None)
|
| 114 |
hard_mode = st.checkbox("Ativar randomização HARD (vídeos apenas)")
|
| 115 |
|
|
|
|
|
|
|
|
|
|
| 116 |
if categoria:
|
| 117 |
uploaded_files = st.file_uploader(
|
| 118 |
f"Selecione arquivos para '{categoria}'",
|
|
@@ -123,6 +126,10 @@ if categoria:
|
|
| 123 |
|
| 124 |
if uploaded_files:
|
| 125 |
for uploaded_file in uploaded_files:
|
|
|
|
|
|
|
|
|
|
|
|
|
| 126 |
folder = os.path.join(BASE_FOLDER, categoria)
|
| 127 |
os.makedirs(folder, exist_ok=True)
|
| 128 |
|
|
@@ -155,8 +162,8 @@ if categoria:
|
|
| 155 |
with open(EXPIRATION_FILE, "w") as f:
|
| 156 |
json.dump(expirations, f)
|
| 157 |
|
| 158 |
-
|
| 159 |
-
|
| 160 |
|
| 161 |
# --- Lista de Arquivos agrupada por pasta ---
|
| 162 |
st.header("📄 Arquivos Disponíveis")
|
|
@@ -201,7 +208,6 @@ for categoria in CATEGORIES:
|
|
| 201 |
with open(EXPIRATION_FILE, "w") as f:
|
| 202 |
json.dump(expirations, f)
|
| 203 |
st.success(f"Arquivo '{file}' excluído.")
|
| 204 |
-
st.rerun()
|
| 205 |
|
| 206 |
with col3:
|
| 207 |
with open(os.path.join(folder, file), "rb") as f_obj:
|
|
@@ -211,6 +217,5 @@ for categoria in CATEGORIES:
|
|
| 211 |
with open(EXPIRATION_FILE, "w") as f:
|
| 212 |
json.dump(expirations, f)
|
| 213 |
st.success(f"Arquivo '{file}' baixado e removido.")
|
| 214 |
-
st.rerun()
|
| 215 |
|
| 216 |
st.markdown("</div>", unsafe_allow_html=True)
|
|
|
|
| 113 |
categoria = st.radio("Categoria:", CATEGORIES, index=None)
|
| 114 |
hard_mode = st.checkbox("Ativar randomização HARD (vídeos apenas)")
|
| 115 |
|
| 116 |
+
if "last_upload" not in st.session_state:
|
| 117 |
+
st.session_state.last_upload = None
|
| 118 |
+
|
| 119 |
if categoria:
|
| 120 |
uploaded_files = st.file_uploader(
|
| 121 |
f"Selecione arquivos para '{categoria}'",
|
|
|
|
| 126 |
|
| 127 |
if uploaded_files:
|
| 128 |
for uploaded_file in uploaded_files:
|
| 129 |
+
# Evita processar o mesmo arquivo em loop
|
| 130 |
+
if st.session_state.last_upload == uploaded_file.name:
|
| 131 |
+
continue
|
| 132 |
+
|
| 133 |
folder = os.path.join(BASE_FOLDER, categoria)
|
| 134 |
os.makedirs(folder, exist_ok=True)
|
| 135 |
|
|
|
|
| 162 |
with open(EXPIRATION_FILE, "w") as f:
|
| 163 |
json.dump(expirations, f)
|
| 164 |
|
| 165 |
+
st.session_state.last_upload = uploaded_file.name
|
| 166 |
+
st.success(f"Arquivo '{new_name}' enviado com sucesso!")
|
| 167 |
|
| 168 |
# --- Lista de Arquivos agrupada por pasta ---
|
| 169 |
st.header("📄 Arquivos Disponíveis")
|
|
|
|
| 208 |
with open(EXPIRATION_FILE, "w") as f:
|
| 209 |
json.dump(expirations, f)
|
| 210 |
st.success(f"Arquivo '{file}' excluído.")
|
|
|
|
| 211 |
|
| 212 |
with col3:
|
| 213 |
with open(os.path.join(folder, file), "rb") as f_obj:
|
|
|
|
| 217 |
with open(EXPIRATION_FILE, "w") as f:
|
| 218 |
json.dump(expirations, f)
|
| 219 |
st.success(f"Arquivo '{file}' baixado e removido.")
|
|
|
|
| 220 |
|
| 221 |
st.markdown("</div>", unsafe_allow_html=True)
|