Initial commit: Video metadata registration service
- Add FastAPI server for video metadata registration - PostgreSQL database models for videos, video_streams, audio_streams, subtitle_streams - Batch registration script for .probe.json files - RESTful API endpoints for CRUD operations - Search functionality by title, artist, codec, resolution
This commit is contained in:
39
scripts/register_batch.py
Normal file
39
scripts/register_batch.py
Normal file
@@ -0,0 +1,39 @@
|
||||
#!/usr/bin/env python3
|
||||
import os
|
||||
import sys
|
||||
from pathlib import Path
|
||||
|
||||
sys.path.insert(0, str(Path(__file__).parent.parent))
|
||||
|
||||
from app.database import SessionLocal
|
||||
from app.services.video_register import VideoRegisterService
|
||||
|
||||
|
||||
def main():
|
||||
if len(sys.argv) < 2:
|
||||
print("Usage: python register_batch.py <directory>")
|
||||
print("Example: python register_batch.py ../test_video")
|
||||
sys.exit(1)
|
||||
|
||||
directory = sys.argv[1]
|
||||
|
||||
if not os.path.isdir(directory):
|
||||
print(f"Error: Directory not found: {directory}")
|
||||
sys.exit(1)
|
||||
|
||||
print(f"Scanning directory: {directory}")
|
||||
print("=" * 60)
|
||||
|
||||
db = SessionLocal()
|
||||
try:
|
||||
service = VideoRegisterService(db)
|
||||
videos = service.register_batch(directory)
|
||||
|
||||
print("=" * 60)
|
||||
print(f"Total registered: {len(videos)} videos")
|
||||
finally:
|
||||
db.close()
|
||||
|
||||
|
||||
if __name__ == "__main__":
|
||||
main()
|
||||
Reference in New Issue
Block a user