Files
sammykumar-ComfyUI-SwissArm…/__init__.py
T
Sam Kumar a78e5ca94e ✨ (media_selection): introduce new Media Selection nodes for advanced video processing workflows, including Media Selection, Frame Extractor, and Multi-Caption Combiner to enhance modularity and flexibility in media handling.
📝 (README): add comprehensive documentation for new nodes, including usage examples, workflow guides, and technical details to assist users in implementing the new features effectively.

🐛 (media_selection): fix issues with media type detection and improve error handling for media selection from Reddit and local paths to ensure robustness and user-friendly feedback.

✅ (test_nodes): add test script for Media Selection and Frame Extraction nodes to validate functionality and ensure reliability of the new features.

💡 (subreddit_randomization): implement a new feature for randomizing media selection from subreddits, enhancing user experience by providing more diverse media sources.

♻️ (frame_extractor): refactor frame extraction logic to support multiple extraction methods and improve performance and usability.

🔧 (configuration): update configuration files to accommodate new nodes and ensure compatibility with existing workflows.
2025-10-08 06:27:55 -05:00

93 lines
3.5 KiB
Python

import os
from .nodes.nodes import NODE_CLASS_MAPPINGS as MAIN_NODE_CLASS_MAPPINGS
from .nodes.nodes import NODE_DISPLAY_NAME_MAPPINGS as MAIN_NODE_DISPLAY_NAME_MAPPINGS
from .nodes.helper_nodes import HELPER_NODE_CLASS_MAPPINGS
from .nodes.helper_nodes import HELPER_NODE_DISPLAY_NAME_MAPPINGS
# Import control panel node
try:
from .nodes.utils.control_panel import CONTROL_PANEL_NODE_CLASS_MAPPINGS
from .nodes.utils.control_panel import CONTROL_PANEL_NODE_DISPLAY_NAME_MAPPINGS
except ImportError as e:
print(f"Warning: Could not import control panel node: {e}")
CONTROL_PANEL_NODE_CLASS_MAPPINGS = {}
CONTROL_PANEL_NODE_DISPLAY_NAME_MAPPINGS = {}
# Import lora_manager nodes
try:
from .nodes.lora_manager import NODE_CLASS_MAPPINGS as LORA_MANAGER_NODE_CLASS_MAPPINGS
from .nodes.lora_manager import NODE_DISPLAY_NAME_MAPPINGS as LORA_MANAGER_NODE_DISPLAY_NAME_MAPPINGS
except ImportError as e:
print(f"Warning: Could not import lora_manager nodes: {e}")
LORA_MANAGER_NODE_CLASS_MAPPINGS = {}
LORA_MANAGER_NODE_DISPLAY_NAME_MAPPINGS = {}
# Import media_selection nodes
try:
from .nodes.media_selection.media_selection import MediaSelection
from .nodes.media_selection.frame_extractor import FrameExtractor
from .nodes.media_selection.multi_caption_combiner import MultiCaptionCombiner
MEDIA_SELECTION_NODE_CLASS_MAPPINGS = {
"MediaSelection": MediaSelection,
"FrameExtractor": FrameExtractor,
"MultiCaptionCombiner": MultiCaptionCombiner,
}
MEDIA_SELECTION_NODE_DISPLAY_NAME_MAPPINGS = {
"MediaSelection": "Media Selection",
"FrameExtractor": "Frame Extractor",
"MultiCaptionCombiner": "Multi-Caption Combiner",
}
except ImportError as e:
print(f"Warning: Could not import media_selection nodes: {e}")
MEDIA_SELECTION_NODE_CLASS_MAPPINGS = {}
MEDIA_SELECTION_NODE_DISPLAY_NAME_MAPPINGS = {}
# Register config API routes
try:
from .nodes.config_api import register_config_routes
from server import PromptServer
app = getattr(PromptServer.instance, "app", None) or PromptServer.instance
if app:
register_config_routes(app)
print("Swiss Army Knife: Registered config API routes")
except Exception as e:
print(f"Swiss Army Knife: Could not register config API routes: {e}")
# Get version from pyproject.toml for cache busting
def get_version():
try:
import tomllib
pyproject_path = os.path.join(os.path.dirname(__file__), "pyproject.toml")
with open(pyproject_path, "rb") as f:
data = tomllib.load(f)
return data["project"]["version"]
except Exception:
# Fallback to timestamp if version reading fails
import time
return str(int(time.time()))
# Combine main nodes, helper nodes, control panel, lora_manager, and media_selection nodes
NODE_CLASS_MAPPINGS = {
**MAIN_NODE_CLASS_MAPPINGS,
**HELPER_NODE_CLASS_MAPPINGS,
**CONTROL_PANEL_NODE_CLASS_MAPPINGS,
**LORA_MANAGER_NODE_CLASS_MAPPINGS,
**MEDIA_SELECTION_NODE_CLASS_MAPPINGS
}
NODE_DISPLAY_NAME_MAPPINGS = {
**MAIN_NODE_DISPLAY_NAME_MAPPINGS,
**HELPER_NODE_DISPLAY_NAME_MAPPINGS,
**CONTROL_PANEL_NODE_DISPLAY_NAME_MAPPINGS,
**LORA_MANAGER_NODE_DISPLAY_NAME_MAPPINGS,
**MEDIA_SELECTION_NODE_DISPLAY_NAME_MAPPINGS
}
WEB_DIRECTORY = "./web"
VERSION = get_version()
# Load DEBUG setting from environment
DEBUG = os.environ.get("DEBUG", "false").lower() in ("true", "1", "yes")
__all__ = ["NODE_CLASS_MAPPINGS", "NODE_DISPLAY_NAME_MAPPINGS", "WEB_DIRECTORY", "VERSION", "DEBUG"]