[tree_stream] Utilisation du MIMEtype (0.1.1)
All checks were successful
/ 🐍 Build & Publish Python Packages (push) Successful in 1m1s
All checks were successful
/ 🐍 Build & Publish Python Packages (push) Successful in 1m1s
This commit is contained in:
@ -2,7 +2,7 @@ from setuptools import setup, find_packages
|
|||||||
|
|
||||||
setup(
|
setup(
|
||||||
name="tree-stream",
|
name="tree-stream",
|
||||||
version="0.1.0",
|
version="0.1.1",
|
||||||
description="Affiche une arborescence enrichie des fichiers vidéo avec chapitres et flux",
|
description="Affiche une arborescence enrichie des fichiers vidéo avec chapitres et flux",
|
||||||
author="TonNom",
|
author="TonNom",
|
||||||
packages=find_packages(),
|
packages=find_packages(),
|
||||||
|
@ -4,6 +4,7 @@ import os
|
|||||||
import sys
|
import sys
|
||||||
import argparse
|
import argparse
|
||||||
import ffmpeg
|
import ffmpeg
|
||||||
|
import mimetypes
|
||||||
|
|
||||||
# Codes des couleurs ANSI
|
# Codes des couleurs ANSI
|
||||||
NOIR = "\033[30m"
|
NOIR = "\033[30m"
|
||||||
@ -31,11 +32,17 @@ SOULIGNE = "\033[4m" # Souligné
|
|||||||
CLIGNOTANT = "\033[5m" # Clignotant
|
CLIGNOTANT = "\033[5m" # Clignotant
|
||||||
INVERSE = "\033[7m" # Inversé (texte clair sur fond sombre)
|
INVERSE = "\033[7m" # Inversé (texte clair sur fond sombre)
|
||||||
|
|
||||||
|
def est_fichier_video(chemin):
|
||||||
|
"""
|
||||||
|
Vérifie si le fichier est de type vidéo en se basant sur son type MIME.
|
||||||
|
"""
|
||||||
|
type_mime, _ = mimetypes.guess_type(chemin)
|
||||||
|
return type_mime is not None and type_mime.startswith("video/")
|
||||||
|
|
||||||
def couleur(nom_fichier, est_dossier):
|
def couleur(nom_fichier, est_dossier):
|
||||||
if est_dossier:
|
if est_dossier:
|
||||||
return BLEU + nom_fichier + NORMAL
|
return BLEU + nom_fichier + NORMAL
|
||||||
elif nom_fichier.lower().endswith(('.mp4', '.mkv', '.avi')):
|
elif est_fichier_video(nom_fichier):
|
||||||
return VIOLET + nom_fichier + NORMAL # 💜 fichier vidéo
|
return VIOLET + nom_fichier + NORMAL # 💜 fichier vidéo
|
||||||
else:
|
else:
|
||||||
return nom_fichier
|
return nom_fichier
|
||||||
@ -209,7 +216,7 @@ def afficher_arborescence(dossier, prefixe="", tout_afficher=False, niveau_max=N
|
|||||||
niveau_max=niveau_max,
|
niveau_max=niveau_max,
|
||||||
niveau_actuel=niveau_actuel + 1
|
niveau_actuel=niveau_actuel + 1
|
||||||
)
|
)
|
||||||
elif nom.lower().endswith(('.mp4', '.mkv', '.avi')):
|
elif est_fichier_video(chemin_complet):
|
||||||
infos = analyser_fichier_video(chemin_complet)
|
infos = analyser_fichier_video(chemin_complet)
|
||||||
for i, ligne in enumerate(infos):
|
for i, ligne in enumerate(infos):
|
||||||
print(prefixe + sous_prefixe + ("└── " if i == len(infos) - 1 else "├── ") + ligne)
|
print(prefixe + sous_prefixe + ("└── " if i == len(infos) - 1 else "├── ") + ligne)
|
||||||
|
Reference in New Issue
Block a user