refactor: extract launch script + adapt metadata extractor
This commit is contained in:
47
scripts/extract_metadata.py
Executable file
47
scripts/extract_metadata.py
Executable file
@ -0,0 +1,47 @@
|
||||
#!/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()
|
Reference in New Issue
Block a user