L'oncle claude ce nulos il sait pas déterminenr combien de temps ça dure une musique
All checks were successful
ci / deploy (push) Successful in 5m53s

This commit is contained in:
2026-01-19 23:01:47 +01:00
parent 1a5453a714
commit cc5ffc0133
5 changed files with 47 additions and 16 deletions

1
air-support/.gitignore vendored Normal file
View File

@@ -0,0 +1 @@
*.pls

View File

@@ -2,11 +2,11 @@
touch /songs/playlist.pls /jingles/playlist.pls touch /songs/playlist.pls /jingles/playlist.pls
# fallback
python /opt/je_te_met_en_pls.py /air-support
# Start background sync process # Start background sync process
/opt/ultrasync.sh & /opt/ultrasync.sh &
# fallback
python /opt/je_te_met_en_pls.py /air-support /air-support/playlist.pls
# Run Liquidsoap as zambla user # Run Liquidsoap as zambla user
runuser -l zambla -c 'liquidsoap /opt/radio.liq' runuser -l zambla -c 'liquidsoap /opt/radio.liq'

View File

@@ -1,8 +1,36 @@
#!/usr/bin/env python3 #!/usr/bin/env python3
import glob, os, sys import glob
import os
import sys
import subprocess
from pathlib import Path
def generate_pls(directory: str, output_file: str = None) -> None: def get_song_length(file: Path) -> float:
ret = subprocess.run(
[
"ffprobe",
"-i",
str(file.absolute()),
"-show_entries",
"format=duration",
"-v",
"quiet",
"-of",
"csv=p=0",
],
stdout=subprocess.PIPE,
)
if ret.returncode != 0:
return -1
try:
return float(ret.stdout)
except ValueError:
return -1
def generate_pls(directory: str, output_file: str | None = None) -> None:
"""Generate a .pls playlist file from all audio files in a directory. """Generate a .pls playlist file from all audio files in a directory.
Args: Args:
@@ -38,14 +66,12 @@ def generate_pls(directory: str, output_file: str = None) -> None:
pls_content.append(f"NumberOfEntries={len(audio_files)}") pls_content.append(f"NumberOfEntries={len(audio_files)}")
pls_content.append("") pls_content.append("")
for idx, file_path in enumerate(audio_files, start=1): for idx, path in enumerate(audio_files, start=1):
# Get absolute path file = Path(path)
abs_path = os.path.abspath(file_path)
filename = os.path.basename(file_path)
pls_content.append(f"File{idx}={abs_path}") pls_content.append(f"File{idx}={file.absolute()}")
pls_content.append(f"Title{idx}={filename}") pls_content.append(f"Title{idx}={file.stem.replace('_', ' ')}")
pls_content.append(f"Length{idx}=-1") pls_content.append(f"Length{idx}={get_song_length(file)}")
pls_content.append("") pls_content.append("")
pls_content.append("Version=2") pls_content.append("Version=2")

View File

@@ -2,8 +2,12 @@
while true; do while true; do
pip3 install -U yt-dlp pip3 install -U yt-dlp
/opt/je_te_met_en_pls.py /songs /songs/playlist.pls || true /opt/je_te_met_en_pls.py /songs || true
/opt/je_te_met_en_pls.py /jingles /jingles/playlist.pls || true /opt/je_te_met_en_pls.py /jingles || true
/opt/yt_sync.py || true /opt/yt_sync.py || true
/opt/je_te_met_en_pls.py /songs || true
/opt/je_te_met_en_pls.py /jingles || true
sleep 6h sleep 6h
done done

View File

@@ -11,7 +11,7 @@ if __name__ == "__main__":
ydl_parameters = { ydl_parameters = {
"format": "bestaudio/best", "format": "bestaudio/best",
"postprocessors": [{"key": "FFmpegExtractAudio", "preferredcodec": "vorbis"}], "postprocessors": [{"key": "FFmpegExtractAudio", "preferredcodec": "vorbis"}],
"outtmpl": f"{songs_folder}/%(title)s.godwin", "outtmpl": f"{songs_folder}/%(title)s",
"ignoreerrors": True, "ignoreerrors": True,
"restrictfilenames": True, "restrictfilenames": True,
} }
@@ -23,7 +23,7 @@ if __name__ == "__main__":
# Radio Bullshit Jingles # Radio Bullshit Jingles
## change output path for Radio Bullshit jingles ## change output path for Radio Bullshit jingles
ydl_parameters["outtmpl"] = f"{jingles_folder}/%(title)s.godwin" ydl_parameters["outtmpl"] = f"{jingles_folder}/%(title)s"
## download ## download
ydl = yt_dlp.YoutubeDL(ydl_parameters) ydl = yt_dlp.YoutubeDL(ydl_parameters)
ydl.extract_info( ydl.extract_info(