suppression de vidéos
This commit is contained in:
@@ -11,6 +11,10 @@ def get_conn():
|
||||
conn.execute("PRAGMA foreign_keys = ON;")
|
||||
return conn
|
||||
|
||||
def delete_video(file_name):
|
||||
with get_conn() as conn:
|
||||
conn.execute("DELETE FROM videos WHERE file_name = ?", (file_name,))
|
||||
conn.commit()
|
||||
|
||||
def load_videos():
|
||||
with get_conn() as conn:
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
# video_views.py
|
||||
import os
|
||||
import shutil
|
||||
import streamlit as st
|
||||
import db
|
||||
from models import Video
|
||||
@@ -51,15 +52,25 @@ def show_video_row(
|
||||
|
||||
st.caption(video.file_name or video.mp4_file_name)
|
||||
|
||||
c1, c2 = st.columns(2)
|
||||
c1, c2, c3 = st.columns(3)
|
||||
with c1:
|
||||
if st.button("▶️ Lire", key=f"play_{video.file_name}"):
|
||||
if st.button("▶️", key=f"play_{video.file_name}"):
|
||||
st.session_state[play_key] = True
|
||||
(st.rerun if hasattr(st, "rerun") else st.experimental_rerun)()
|
||||
with c2:
|
||||
if st.button("⏸️ Stop", key=f"stop_{video.file_name}"):
|
||||
if st.button("⏸️", key=f"stop_{video.file_name}"):
|
||||
st.session_state[play_key] = False
|
||||
(st.rerun if hasattr(st, "rerun") else st.experimental_rerun)()
|
||||
with c3:
|
||||
if st.button("🗑️", key=f"del_{video.file_name}"):
|
||||
st.session_state[play_key] = False
|
||||
if os.path.exists(video.raw_file ):
|
||||
os.remove(video.raw_file)
|
||||
if os.path.exists(video.mp4_file):
|
||||
shutil.rmtree(os.path.dirname(video.mp4_file))
|
||||
db.delete_video(video.file_name)
|
||||
st.warning("Vidéo supprimée.")
|
||||
(st.rerun if hasattr(st, "rerun") else st.experimental_rerun)()
|
||||
|
||||
if st.session_state[play_key]:
|
||||
mp4_path = getattr(video, "mp4_file", None)
|
||||
|
||||
Reference in New Issue
Block a user