aircox-radiocampus/aircox/management/commands/sounds_monitor.py
Chris Tactic fd4c765dc4 #123: Sound Monitoring (#125)
110fac70a6 n'est pas lié à #123 (tu peux l'ignorer ici mais rc/aircox#122 (comment))

04f5c3208a : nettoyage d'anciens tests, je ne suis pas parvenu à rétablir le dernier, je l'ai préfixé avec broken_. Il y aurait aussi à supprimer/corriger aircox/tests/management/_test_sound_monitor.py

5a75f42808 : le correctif qui permet d'ajouter des sons dans une émission à l'aide de la commande `sounds_scan`.

Co-authored-by: Christophe Siraut <d@tobald.eu.org>
Reviewed-on: rc/aircox#125
Co-authored-by: Chris Tactic <chris@tacticasbl.be>
Co-committed-by: Chris Tactic <chris@tacticasbl.be>
2023-11-08 18:38:49 +01:00

67 lines
2.0 KiB
Python
Executable File

#! /usr/bin/env python3
"""Monitor sound files; For each program, check for:
- new files;
- deleted files;
- differences between files and sound;
- quality of the files;
It tries to parse the file name to get the date of the diffusion of an
episode and associate the file with it; We use the following format:
yyyymmdd[_n][_][name]
Where:
'yyyy' the year of the episode's diffusion;
'mm' the month of the episode's diffusion;
'dd' the day of the episode's diffusion;
'n' the number of the episode (if multiple episodes);
'name' the title of the sound;
To check quality of files, call the command sound_quality_check using the
parameters given by the setting SOUND_QUALITY. This script requires
Sox (and soxi).
"""
import logging
from argparse import RawTextHelpFormatter
from django.core.management.base import BaseCommand
from aircox.controllers.sound_monitor import SoundMonitor
logger = logging.getLogger("aircox.commands")
class Command(BaseCommand):
help = __doc__
def add_arguments(self, parser):
parser.formatter_class = RawTextHelpFormatter
parser.add_argument(
"-q",
"--quality_check",
action="store_true",
help="Enable quality check using sound_quality_check on all " "sounds marqued as not good",
)
parser.add_argument(
"-s",
"--scan",
action="store_true",
help="Scan programs directories for changes, plus check for a "
" matching diffusion on sounds that have not been yet assigned",
)
parser.add_argument(
"-m",
"--monitor",
action="store_true",
help="Run in monitor mode, watch for modification in the " "filesystem and react in consequence",
)
def handle(self, *args, **options):
monitor = SoundMonitor()
if options.get("scan"):
monitor.scan()
if options.get("monitor"):
monitor.monitor()