Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions ffconv/args.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,8 +3,8 @@
import click

from ffconv.helper import (
read_json,
files_in_dir,
read_json,
replace_conflicting_characters_in_filename,
)

Expand Down Expand Up @@ -86,8 +86,8 @@ def __call__(self, ctx, param, value):
if p.suffix:
if not p.parent.is_dir():
raise FileNotFoundError(
f"The parent directory `{str(p.parent)}` "
f"for output argument `{str(p)}` does not exist."
f"The parent directory `{p.parent!s}` "
f"for output argument `{p!s}` does not exist."
)
else:
current_batch = {
Expand Down
36 changes: 12 additions & 24 deletions ffconv/cli.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,27 +3,27 @@
from pathlib import Path

import click
from loguru import logger
from rich.prompt import IntPrompt

from ffconv.args import (
AutoAudioFlagChecker,
InputPathChecker,
OutputPathChecker,
PresetPathChecker,
OptionalValueChecker,
OutputPathChecker,
PresetOptionalChecker,
AutoAudioFlagChecker,
PresetPathChecker,
)
from ffconv.exception import StreamOrderError, StreamTypeMissingError
from ffconv.helper import (
split_list_of_dicts_by_key,
combine_arguments_by_batch,
remove_empty_dict_values,
dict_to_list,
preprocess_streams,
remove_empty_dict_values,
split_list_of_dicts_by_key,
)
from ffconv.process import ProcessCommand
from ffconv.table import table_print_stream_options
from loguru import logger # noqa


def validate_stream_order(mkvmerge_identify_result, file_details):
Expand Down Expand Up @@ -116,21 +116,9 @@ def stream_user_input(mkvmerge_identify_result):
{
"id": cs["id"],
"codec": cs["properties"]["codec_id"],
"language": (
cs["properties"]["language"]
if "language" in cs["properties"]
else "n/a"
),
"title": (
cs["properties"]["track_name"]
if "track_name" in cs["properties"]
else "n/a"
),
"default": (
cs["properties"]["default_track"]
if "default_track" in cs["properties"]
else "n/a"
),
"language": cs["properties"].get("language", "n/a"),
"title": cs["properties"].get("track_name", "n/a"),
"default": cs["properties"].get("default_track", "n/a"),
}
for cs in stream_info["streams"]
]
Expand Down Expand Up @@ -302,7 +290,7 @@ def ffmpeg_convert_file(
audio_map_index = "0:" + str(stream_mapping["audio"]["id"])

# Filter complex subtitle map requires this escaped monstrosity for Windows
lit_file = str(input_file).replace("\\", "\\\\").replace(":", "\:")
lit_file = str(input_file).replace("\\", "\\\\").replace(":", r"\:")
filter_complex_map = (
"subtitles='" + lit_file + "':si=" + str(stream_mapping["subtitles"]["id"]),
)
Expand All @@ -326,7 +314,7 @@ def ffmpeg_convert_file(
filter_complex_map_concat = ",".join(filter_complex_map)
filter_complex_map_complete = f"[{video_map_index}]{filter_complex_map_concat}"

current_datetime = datetime.now()
current_datetime = datetime.now().astimezone()
metadata_encoded_date = (
f'comment=Encoded on {current_datetime.strftime("%Y-%m-%d %H:%M:%S")}'
)
Expand Down Expand Up @@ -467,7 +455,7 @@ def cli(
for current_file_path_index, current_file_path in enumerate(
current_input_files
):
mkvmerge_identify_result, mapping = mkvmerge_identify_streams(
_mkvmerge_identify_result, mapping = mkvmerge_identify_streams(
current_file_path,
total_current_input_files,
current_file_path_index,
Expand Down
5 changes: 4 additions & 1 deletion ffconv/helper.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@
from pathlib import Path


def files_in_dir(path: Path, file_types=["*.mkv"]):
def files_in_dir(path: Path, file_types=None):
"""
Returns a list of files in the given directory that match the specified file types.

Expand All @@ -18,6 +18,9 @@ def files_in_dir(path: Path, file_types=["*.mkv"]):
List[Path]: A list of paths to the files in the directory that match the specified file types.
"""

if file_types is None:
file_types = ["*.mkv"]

file_list = [
f
for f in path.rglob("*")
Expand Down
4 changes: 2 additions & 2 deletions ffconv/process.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import subprocess as sp

from ffconv.exception import MKVmergeError, ProcessError, FFmpegError
from ffconv.exception import FFmpegError, MKVmergeError, ProcessError


class ProcessCommand:
Expand Down Expand Up @@ -43,7 +43,7 @@ def run(self, process, command):
f"The following {process} command will be executed: {' '.join(command)}"
)

response = sp.run(command, stdout=sp.PIPE, stderr=sp.PIPE)
response = sp.run(command, capture_output=True, check=False)
return_code = response.returncode
if return_code == 0:
self.logger.info(f"{process} completed.")
Expand Down
2 changes: 1 addition & 1 deletion ffconv/table.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,7 @@ def table_print_stream_options(tracks: list) -> None:
table = Table(show_header=True, header_style="bold cyan")

# Header
for key in tracks[0].keys():
for key in tracks[0]:
table.add_column(key.capitalize())

# Rows
Expand Down
2 changes: 1 addition & 1 deletion requirements.dev.txt
Original file line number Diff line number Diff line change
@@ -1,3 +1,3 @@
ruff==0.15.20
ruff==0.16.4
mypy==2.3.1
black==26.5.1
3 changes: 2 additions & 1 deletion setup.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
from setuptools import setup, find_packages # type: ignore
import os

from setuptools import find_packages, setup # type: ignore

VERSION = "3.0.0"


Expand Down