-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathcommand_manager.py
More file actions
27 lines (22 loc) · 941 Bytes
/
command_manager.py
File metadata and controls
27 lines (22 loc) · 941 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
import shlex
import subprocess
from pathlib import Path
from typing import List
from loguru import logger
class CommandManager:
@staticmethod
def build_normalize_command(song_path: Path, target_level: float, sample_rate: int,
temp_output_path: str) -> List[str]:
command = shlex.split(f'ffmpeg-normalize '
f'"{song_path}" '
f'-t {target_level} '
f'-ar {sample_rate} '
f'-o "{temp_output_path}" '
f'-c:a libvorbis '
f'-q')
return command
@staticmethod
def execute_normalize_command(command: List[str], filename: Path) -> str:
logger.info(f'Processing {filename.name}')
return_value = subprocess.run(command)
return filename.name if return_value.returncode == 0 else ''