add convert scan output

This commit is contained in:
Brandon Egger 2024-06-08 21:14:36 -05:00
parent f3ac6cd344
commit 2ed003a11b
2 changed files with 26 additions and 1 deletions

View File

@ -1,6 +1,8 @@
import typer
from rich import print
from utils.directory import is_mounted_directory
from utils.directory import is_mounted_directory, recursive_scan
import time
import os
app = typer.Typer()
@ -14,6 +16,16 @@ def scan(directory: str):
if is_mounted_directory(directory):
print("Directory is detected as mounted. To improve file I/O performance, when performing conversions the mkv file will be copied locally during video encoding.")
time_start = time.time()
matches = recursive_scan(directory)
duration = time.time() - time_start
[print(os.path.basename(match)) for match in matches]
print("\n\n")
print("Found", len(matches), "files in", round(duration, 2), "seconds.")
print("Use the 'convert' command to convert these files.")
@app.command()
def convert(directory: str):
"""

View File

@ -6,3 +6,16 @@ def is_mounted_directory(path: str) -> bool:
Check if a directory is a mounted directory.
"""
return os.path.ismount(path)
def recursive_scan(path: str):
"""
Recursively scan a directory for mkv files.
"""
inputs = []
for root, _, files in os.walk(path):
for file in files:
if file.endswith('.mkv'):
inputs.append(os.path.join(root, file))
return inputs