Compare commits

...

5 Commits

Author SHA1 Message Date
2ed003a11b add convert scan output 2024-06-08 21:14:36 -05:00
f3ac6cd344 add note if directory mounted 2024-06-08 21:08:00 -05:00
7f47b65521 rename project, format 2024-06-08 21:02:56 -05:00
716ef2a009 add typer 2024-06-08 21:02:29 -05:00
c904e90f6d rename 2024-06-08 21:02:19 -05:00
4 changed files with 66 additions and 0 deletions

View File

@ -0,0 +1,37 @@
import typer
from rich import print
from utils.directory import is_mounted_directory, recursive_scan
import time
import os
app = typer.Typer()
@app.command()
def scan(directory: str):
"""
Scan a path for mkv files. Used to test the directory before running a conversion job.
"""
print("Scanning directory:", directory)
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):
"""
Convert all mkv files in a directory to mp4 and split subtitles.
"""
pass
if __name__ == "__main__":
app()

View File

@ -0,0 +1,21 @@
import os
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

View File

@ -1,2 +1,10 @@
click==8.1.7
ffmpeg-python==0.2.0
future==1.0.0
markdown-it-py==3.0.0
mdurl==0.1.2
Pygments==2.18.0
rich==13.7.1
shellingham==1.5.4
typer==0.12.3
typing_extensions==4.12.2

View File