Give alias and random suffix for whatsapp videos without created timestamp

This commit is contained in:
Gabriel Radureau
2025-10-16 17:28:26 +02:00
parent 78313ffbef
commit fbe3c01de7
10 changed files with 131 additions and 25 deletions

View File

@@ -77,6 +77,11 @@ def update_video_difficulty(file_name, level):
conn.execute("UPDATE videos SET difficulty_level = ? WHERE file_name = ?", (level, file_name))
conn.commit()
def update_video_alias(file_name, alias):
with get_conn() as conn:
conn.execute("UPDATE videos SET alias = ? WHERE file_name = ?", (alias, file_name))
conn.commit()
def get_unique_days():
"""Retourne la liste unique des jours de la semaine enregistrés dans la base."""
with get_conn() as conn:

View File

@@ -18,6 +18,7 @@ class Video(BaseModel):
long: Optional[float] = None
address: Optional[str] = None
difficulty_level: Optional[str] = Field("Tout niveau", description="Niveau de difficulté")
alias: Optional[str] = None
# --- propriétés pratiques ---
@property
@@ -28,7 +29,7 @@ class Video(BaseModel):
@property
def title(self) -> str:
"""Nom court à afficher."""
return self.mp4_file_name or self.file_name
return self.alias or self.mp4_file_name or self.file_name
@property
def difficulty_display(self) -> str:

View File

@@ -44,6 +44,7 @@ def playlist_manual_editor(playlist: Playlist):
preselected_labels=preselected,
editable_labels=False,
editable_difficulty=False,
editable_alias=False,
playlist=playlist,
playlist_video_ids=playlist_video_ids,
video_playlists=playlists
@@ -129,6 +130,7 @@ def playlist_dynamic_editor(playlist: Playlist):
preselected_labels=preselected,
editable_labels=False,
editable_difficulty=False,
editable_alias=False,
playlist=playlist,
playlist_video_ids=playlist_video_ids,
video_playlists=playlists

View File

@@ -39,7 +39,7 @@ def video_filter_sidebar(unlabeled=False):
show_unlabeled_only=show_unlabeled_only
)
def video_list_view(filters: dict, editable_labels=True, editable_difficulty=True, playlist=None):
def video_list_view(filters: dict, editable_labels=True, editable_difficulty=True, editable_alias=True, playlist=None):
"""Affiche les vidéos selon les filtres fournis."""
st.markdown(f"""
<style>
@@ -93,7 +93,7 @@ def video_list_view(filters: dict, editable_labels=True, editable_difficulty=Tru
css_class = "unlabeled" if not preselected else ""
with st.container():
st.markdown(f"<div class='{css_class}'>", unsafe_allow_html=True)
show_video_row(video, preselected, editable_labels, editable_difficulty, playlist)
show_video_row(video, preselected, editable_labels, editable_difficulty, editable_alias, playlist)
st.markdown("</div>", unsafe_allow_html=True)
# lazy loading bouton

View File

@@ -11,6 +11,7 @@ def show_video_row(
preselected_labels,
editable_labels=True,
editable_difficulty=True,
editable_alias=True,
playlist=None,
playlist_video_ids=None,
video_playlists=None,
@@ -19,7 +20,7 @@ def show_video_row(
Affiche une ligne Streamlit pour une vidéo :
- miniature + lecture conditionnelle
- métadonnées et labels
- édition des labels et difficulté
- édition des labels, difficulté et alias
- (optionnel) ajout/retrait d'une playlist
"""
@@ -100,6 +101,11 @@ def show_video_row(
if new_level != video.difficulty_display:
db.update_video_difficulty(video.file_name, new_level)
st.success(f"Niveau mis à jour pour {video.file_name}")
if editable_alias:
alias = st.text_input("Alias (optionnel)", value=video.alias, key=f'new_alias_{video.id}')
if alias != video.alias:
db.update_video_alias(video.file_name, alias.strip())
st.success(f"Alias mis à jour pour {video.file_name}")
# --- Colonne 4 : action playlist ---
if col4 and playlist: