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
All checks were successful
ci / deploy (push) Successful in 5m53s
This commit is contained in:
1
air-support/.gitignore
vendored
Normal file
1
air-support/.gitignore
vendored
Normal file
@@ -0,0 +1 @@
|
||||
*.pls
|
||||
@@ -2,11 +2,11 @@
|
||||
|
||||
touch /songs/playlist.pls /jingles/playlist.pls
|
||||
|
||||
# fallback
|
||||
python /opt/je_te_met_en_pls.py /air-support
|
||||
|
||||
# Start background sync process
|
||||
/opt/ultrasync.sh &
|
||||
|
||||
# fallback
|
||||
python /opt/je_te_met_en_pls.py /air-support /air-support/playlist.pls
|
||||
|
||||
# Run Liquidsoap as zambla user
|
||||
runuser -l zambla -c 'liquidsoap /opt/radio.liq'
|
||||
|
||||
@@ -1,8 +1,36 @@
|
||||
#!/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.
|
||||
|
||||
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("")
|
||||
|
||||
for idx, file_path in enumerate(audio_files, start=1):
|
||||
# Get absolute path
|
||||
abs_path = os.path.abspath(file_path)
|
||||
filename = os.path.basename(file_path)
|
||||
for idx, path in enumerate(audio_files, start=1):
|
||||
file = Path(path)
|
||||
|
||||
pls_content.append(f"File{idx}={abs_path}")
|
||||
pls_content.append(f"Title{idx}={filename}")
|
||||
pls_content.append(f"Length{idx}=-1")
|
||||
pls_content.append(f"File{idx}={file.absolute()}")
|
||||
pls_content.append(f"Title{idx}={file.stem.replace('_', ' ')}")
|
||||
pls_content.append(f"Length{idx}={get_song_length(file)}")
|
||||
pls_content.append("")
|
||||
|
||||
pls_content.append("Version=2")
|
||||
|
||||
@@ -2,8 +2,12 @@
|
||||
|
||||
while true; do
|
||||
pip3 install -U yt-dlp
|
||||
/opt/je_te_met_en_pls.py /songs /songs/playlist.pls || true
|
||||
/opt/je_te_met_en_pls.py /jingles /jingles/playlist.pls || true
|
||||
/opt/je_te_met_en_pls.py /songs || true
|
||||
/opt/je_te_met_en_pls.py /jingles || 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
|
||||
done
|
||||
|
||||
@@ -11,7 +11,7 @@ if __name__ == "__main__":
|
||||
ydl_parameters = {
|
||||
"format": "bestaudio/best",
|
||||
"postprocessors": [{"key": "FFmpegExtractAudio", "preferredcodec": "vorbis"}],
|
||||
"outtmpl": f"{songs_folder}/%(title)s.godwin",
|
||||
"outtmpl": f"{songs_folder}/%(title)s",
|
||||
"ignoreerrors": True,
|
||||
"restrictfilenames": True,
|
||||
}
|
||||
@@ -23,7 +23,7 @@ if __name__ == "__main__":
|
||||
|
||||
# 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
|
||||
ydl = yt_dlp.YoutubeDL(ydl_parameters)
|
||||
ydl.extract_info(
|
||||
|
||||
Reference in New Issue
Block a user