#!/usr/bin/env python3
"""
Subprocess wrapper for Instagram Client (direct API) operations.
Runs in an isolated subprocess to avoid asyncio event loop conflicts.

Uses the common wrapper factory from base_subprocess_wrapper.
"""

import sys
from pathlib import Path

# Add parent directory to path
sys.path.insert(0, str(Path(__file__).parent.parent))

from wrappers.base_subprocess_wrapper import create_download_wrapper, run_wrapper_main


def create_instagram_client_downloader(config, unified_db):
    """Factory function to create an Instagram Client downloader instance."""
    from modules.instagram_client_module import InstagramClientDownloader

    return InstagramClientDownloader(
        show_progress=True,
        use_database=True,
        log_callback=None,  # Module uses universal logger
        unified_db=unified_db
    )


# Create the download function using the factory
run_instagram_client_download = create_download_wrapper(
    "InstagramClient", "instagram_client", create_instagram_client_downloader
)


if __name__ == '__main__':
    run_wrapper_main(run_instagram_client_download)
