- tools/run.py: pygame.mixer subsystem — polls session/ambience.md, crossfades tracks, shows ♫ in status bar - tools/music-fetch.py: search/download from YouTube via yt-dlp, auto-increment filenames, --replace and --dry-run modes - tools/ambience.py: companion CLI to set ambience state - session/ambience.md: current ambience state file (DM writes here) - session/ambience_options.md: ambience → file mapping table - session/ambience_sources.md: file → YouTube URL tracking for re-download - session/audio/ added to .gitignore (audio files not tracked in git)
45 lines
1.1 KiB
Python
Executable File
45 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
"""Companion CLI to set ambience for the TUI.
|
|
|
|
Usage:
|
|
python3 tools/ambience.py <name>
|
|
python3 tools/ambience.py silence
|
|
"""
|
|
|
|
import sys
|
|
from pathlib import Path
|
|
|
|
SESSION = Path(__file__).resolve().parent.parent / 'session'
|
|
AMBIENCE_PATH = SESSION / 'ambience.md'
|
|
|
|
|
|
def main():
|
|
if len(sys.argv) < 2:
|
|
names = _available()
|
|
print(f"Usage: python3 tools/ambience.py <name>")
|
|
print(f"Available: {', '.join(names)}")
|
|
sys.exit(1)
|
|
|
|
name = sys.argv[1].lower()
|
|
AMBIENCE_PATH.write_text(name + '\n')
|
|
print(f"♫ ambience set to: {name}")
|
|
|
|
|
|
def _available():
|
|
path = SESSION / 'ambience_options.md'
|
|
if not path.exists():
|
|
return ['silence']
|
|
names = ['silence']
|
|
for line in path.read_text().splitlines():
|
|
s = line.strip()
|
|
if s.startswith('|') and s.endswith('|'):
|
|
parts = [p.strip() for p in s.split('|')]
|
|
parts = [p for p in parts if p]
|
|
if parts and parts[0].lower() not in ('ambience', '---'):
|
|
names.append(parts[0])
|
|
return names
|
|
|
|
|
|
if __name__ == '__main__':
|
|
main()
|