Research-Stack/4-Infrastructure/NoDupeLabs/nodupe/tools/video/video_plugin.py

76 lines
2 KiB
Python

# SPDX-License-Identifier: Apache-2.0
# Copyright (c) 2025 Allaun
"""Video Processing Tool for NoDupeLabs.
Provides video analysis capabilities as a tool.
"""
from typing import List, Dict, Any, Optional, Callable
from nodupe.core.tool_system.base import Tool
from . import get_video_backend_manager
class VideoTool(Tool):
"""Video processing capabilities tool."""
@property
def name(self) -> str:
"""Get tool name.
Returns:
Tool name identifier
"""
return "video_tool"
@property
def version(self) -> str:
"""Get tool version.
Returns:
Version string in semver format
"""
return "1.0.0"
@property
def dependencies(self) -> List[str]:
"""Get tool dependencies.
Returns:
List of dependency names
"""
return []
@property
def api_methods(self) -> Dict[str, Callable[..., Any]]:
"""Get API methods exposed by this tool.
Returns:
Dictionary mapping method names to callable functions
"""
return {
'extract_frames': self.manager.extract_frames,
'get_metadata': self.manager.get_video_metadata,
'compute_phash': self.manager.compute_perceptual_hash
}
def __init__(self):
"""Initialize the tool."""
self.manager = get_video_backend_manager()
def initialize(self, container: Any) -> None:
"""Initialize the tool and register services."""
container.register_service('video_manager', self.manager)
def shutdown(self) -> None:
"""Shutdown the tool."""
def get_capabilities(self) -> Dict[str, Any]:
"""Get tool capabilities."""
return {
'backends': [b.__class__.__name__ for b in self.manager.backends],
'available': len(self.manager.backends) > 0
}
def register_tool():
"""Register the video tool."""
return VideoTool()