ci(ffmpeg_handling): add main restriction for build task #2
No files matched your search
@@ -10,7 +10,6 @@ from .audio_commands import (
|
||||
cmd_remove_russian_from_db,
|
||||
cmd_set_primary_audio,
|
||||
)
|
||||
from .helpers import logger
|
||||
from .metadata_commands import cmd_apply_chapters, cmd_set_metadata, cmd_show_metadata
|
||||
from .video_commands import (
|
||||
cmd_convert_audio,
|
||||
@@ -24,13 +23,6 @@ from .video_commands import (
|
||||
)
|
||||
|
||||
|
||||
def cmd_test(args):
|
||||
from .run_test import run_tests
|
||||
|
||||
logger.debug("Running the unittest suite for command %s", args.command)
|
||||
return run_tests(), "nooutputneeded"
|
||||
|
||||
|
||||
def add_command(subparsers, name, func, help_text, *, aliases=(), parents=()):
|
||||
parser = subparsers.add_parser(
|
||||
name, aliases=list(aliases), parents=list(parents), help=help_text
|
||||
@@ -62,10 +54,6 @@ def build_parser():
|
||||
base.add_argument("--dry-run", action="store_true")
|
||||
subparsers = parser.add_subparsers(dest="command", required=True)
|
||||
|
||||
add_command(
|
||||
subparsers, "test", cmd_test, "Run the unittest suite",
|
||||
aliases=("t",), parents=(base,),
|
||||
)
|
||||
add_command(
|
||||
subparsers, "info", cmd_info, "Inspect media metadata",
|
||||
aliases=("i",), parents=(base,),
|
||||
|
||||
@@ -2,6 +2,7 @@
|
||||
"""Command-line media utility backed by the ffmpeg and ffprobe executables."""
|
||||
|
||||
import re
|
||||
import shutil
|
||||
import subprocess
|
||||
import sys
|
||||
from pathlib import Path
|
||||
@@ -19,7 +20,6 @@ from .helpers import (
|
||||
)
|
||||
|
||||
COMMANDS = {
|
||||
"test": {"name": "test", "output": False},
|
||||
"info": {"name": "info", "output": False},
|
||||
"convert-av": {"name": "convert-av", "output": True},
|
||||
"convert-av-all": {"name": "convert-av-all", "output": True},
|
||||
@@ -65,21 +65,21 @@ def _fill_required_options(args):
|
||||
|
||||
|
||||
def _process_input(args, parser) -> int:
|
||||
if args.command != "test":
|
||||
if args.input is None:
|
||||
args.input = Path(ensure(None, f"Input file ({Path.cwd()})"))
|
||||
args.input = args.input.expanduser().resolve()
|
||||
if not args.input.exists():
|
||||
parser.error(f"Input path does not exist: {args.input}")
|
||||
if args.input is None:
|
||||
input_value = ensure(None, f"Input file ({Path.cwd()})")
|
||||
else:
|
||||
input_value = args.input
|
||||
input_path = Path(input_value).expanduser().resolve()
|
||||
args.input = input_path
|
||||
if not input_path.exists():
|
||||
parser.error(f"Input path does not exist: {input_path}")
|
||||
|
||||
if COMMANDS[args.command]["output"] and args.output is None:
|
||||
if args.input is None:
|
||||
parser.error("An output path is required")
|
||||
default_output = (
|
||||
args.input.with_name(f"{args.input.stem}_overwrite{args.input.suffix}")
|
||||
input_path.with_name(f"{input_path.stem}_overwrite{input_path.suffix}")
|
||||
if args.overwrite
|
||||
else args.input.with_name(
|
||||
f"{args.input.stem}_{args.command}{args.input.suffix}"
|
||||
else input_path.with_name(
|
||||
f"{input_path.stem}_{args.command}{input_path.suffix}"
|
||||
)
|
||||
)
|
||||
if args.overwrite:
|
||||
@@ -91,11 +91,7 @@ def _process_input(args, parser) -> int:
|
||||
)
|
||||
|
||||
_fill_required_options(args)
|
||||
if args.command == "test":
|
||||
succeeded, _ = args.func(args)
|
||||
return 0 if succeeded else 1
|
||||
|
||||
input_path = args.input
|
||||
files_move_from = []
|
||||
files_move_to = []
|
||||
if input_path.is_dir():
|
||||
@@ -141,6 +137,9 @@ def main(argv=None) -> int:
|
||||
parser = build_parser()
|
||||
args = parser.parse_args(argv)
|
||||
setup_logging(args.log_level, "ffmpeg_handling")
|
||||
if shutil.which("ffmpeg") is None:
|
||||
logger.error("FFmpeg is not installed or not available on PATH")
|
||||
return 1
|
||||
try:
|
||||
return _process_input(args, parser)
|
||||
except (OSError, ValueError, subprocess.CalledProcessError) as error:
|
||||
|
||||
Reference in new issue
Block a user