Compare commits
5 Commits
c28027c5ce
...
main
Author | SHA1 | Date | |
---|---|---|---|
2ed003a11b | |||
f3ac6cd344 | |||
7f47b65521 | |||
716ef2a009 | |||
c904e90f6d |
37
plex-media-converter/main.py
Normal file
37
plex-media-converter/main.py
Normal 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()
|
21
plex-media-converter/utils/directory.py
Normal file
21
plex-media-converter/utils/directory.py
Normal 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
|
@ -1,2 +1,10 @@
|
|||||||
|
click==8.1.7
|
||||||
ffmpeg-python==0.2.0
|
ffmpeg-python==0.2.0
|
||||||
future==1.0.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
|
||||||
|
Reference in New Issue
Block a user