Files
DanceVideos/app/playlists/playlist_page.py
Gabriel Radureau 65d63ec828 playlist edition
2025-10-13 16:53:15 +02:00

36 lines
1.4 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
# playlists/playlist_page.py
import streamlit as st
from playlists import playlist_db
from playlists.playlist_model import Playlist
from playlists.playlist_controller import playlist_manual_editor, playlist_dynamic_editor
from playlists.playlist_controller import RuleSet
def main():
st.title("🎵 Gestion des Playlists")
playlists = playlist_db.load_all_playlists()
selected = st.selectbox("Playlists existantes", ["(Nouvelle)"] + [p.name for p in playlists])
# playlists/playlist_page.py (partie création)
if selected == "(Nouvelle)":
st.subheader(" Nouvelle playlist")
name = st.text_input("Nom")
desc = st.text_area("Description")
type_choice = st.radio("Type", ["manual", "dynamic"])
if st.button("Créer"):
if not name.strip():
st.error("Le nom ne peut pas être vide.")
else:
pl = Playlist(name=name.strip(), description=desc or "", type=type_choice, rules=RuleSet())
pl.save()
st.success("Playlist créée ✅")
# Recharge immédiate : rerun force tout à re-exécuter
st.rerun()
else:
current = next(p for p in playlists if p.name == selected)
if current.type == "manual":
playlist_manual_editor(current)
else:
playlist_dynamic_editor(current)