48 lines
1.1 KiB
Python
Executable File
48 lines
1.1 KiB
Python
Executable File
#!/usr/bin/env python3
|
|
|
|
import argparse
|
|
import logging
|
|
import os
|
|
import sys
|
|
|
|
from src.metadata_extractor import MetadataExtractor
|
|
|
|
|
|
def main():
|
|
logging.basicConfig(
|
|
level=logging.INFO,
|
|
format="[%(levelname)s] %(message)s"
|
|
)
|
|
|
|
parser = argparse.ArgumentParser(
|
|
description="Extract metadata from video files and save as JSON"
|
|
)
|
|
parser.add_argument(
|
|
"input",
|
|
help="Path to input video file or directory"
|
|
)
|
|
parser.add_argument(
|
|
"-o", "--output",
|
|
help="Directory path where the output JSON files will be saved"
|
|
)
|
|
args = parser.parse_args()
|
|
|
|
input_path = args.input
|
|
output_dir = args.output
|
|
|
|
extractor: MetadataExtractor = MetadataExtractor()
|
|
|
|
success = False
|
|
if os.path.isfile(input_path):
|
|
success = extractor.process_file(input_path, output_dir)
|
|
elif os.path.isdir(input_path):
|
|
success = extractor.process_directory(input_path, output_dir)
|
|
else:
|
|
logging.error(f"Path not found: {input_path}")
|
|
|
|
if not success:
|
|
sys.exit(1)
|
|
|
|
if __name__ == "__main__":
|
|
main()
|