Update app.py
Browse files
app.py
CHANGED
|
@@ -452,7 +452,7 @@ elif pagina == "🔐 Admin":
|
|
| 452 |
arquivos = st.file_uploader("Enviar arquivos", accept_multiple_files=True, key=f"{cat}_{tipo}")
|
| 453 |
|
| 454 |
if arquivos:
|
| 455 |
-
with st.spinner("⏳
|
| 456 |
for f in arquivos:
|
| 457 |
extensao = os.path.splitext(f.name)[1].lower()
|
| 458 |
nome_aleatorio = f"{random.randint(1000000, 9999999)}{extensao}"
|
|
@@ -462,5 +462,27 @@ elif pagina == "🔐 Admin":
|
|
| 462 |
|
| 463 |
final = os.path.join(path, nome_aleatorio)
|
| 464 |
|
| 465 |
-
|
| 466 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 452 |
arquivos = st.file_uploader("Enviar arquivos", accept_multiple_files=True, key=f"{cat}_{tipo}")
|
| 453 |
|
| 454 |
if arquivos:
|
| 455 |
+
with st.spinner("⏳ Processando arquivos..."):
|
| 456 |
for f in arquivos:
|
| 457 |
extensao = os.path.splitext(f.name)[1].lower()
|
| 458 |
nome_aleatorio = f"{random.randint(1000000, 9999999)}{extensao}"
|
|
|
|
| 462 |
|
| 463 |
final = os.path.join(path, nome_aleatorio)
|
| 464 |
|
| 465 |
+
if tipo != "Músicas":
|
| 466 |
+
# 🚀 Reencode leve para padronizar vídeo
|
| 467 |
+
subprocess.run([
|
| 468 |
+
"ffmpeg", "-i", temp,
|
| 469 |
+
"-vf", "scale=trunc(iw/2)*2:trunc(ih/2)*2,fps=30",
|
| 470 |
+
"-c:v", "libx264", "-preset", "veryfast", "-crf", "18",
|
| 471 |
+
"-y", final
|
| 472 |
+
], stdout=subprocess.DEVNULL, stderr=subprocess.DEVNULL)
|
| 473 |
+
os.remove(temp)
|
| 474 |
+
else:
|
| 475 |
+
# 🎵 Música não precisa reencodar
|
| 476 |
+
shutil.move(temp, final)
|
| 477 |
+
|
| 478 |
+
st.success("✅ Arquivos enviados com sucesso!")
|
| 479 |
+
|
| 480 |
+
st.write("Arquivos existentes:")
|
| 481 |
+
for arq in os.listdir(path):
|
| 482 |
+
col1, col2 = st.columns([5, 1])
|
| 483 |
+
with col1:
|
| 484 |
+
st.markdown(f"`{arq}`")
|
| 485 |
+
with col2:
|
| 486 |
+
if st.button("🗑", key=f"{tipo}_{cat}_{arq}"):
|
| 487 |
+
os.remove(os.path.join(path, arq))
|
| 488 |
+
st.rerun()
|