#!/usr/bin/env python3 """ Test ImgInn with visible browser to debug Cloudflare issues """ import sys import os from pathlib import Path from datetime import datetime # Add modules directory to path sys.path.insert(0, str(Path(__file__).parent)) from modules.imginn_module import ImgInnDownloader def main(): print("=" * 60) print("ImgInn Browser Test - Visible Mode (CHROMIUM)") print("=" * 60) print(f"Date: {datetime.now().strftime('%Y-%m-%d %H:%M:%S')}") print("=" * 60) print() print("This will open a visible Chromium browser so you can watch") print("the Cloudflare interaction and see how it handles the challenge.") print() # Get username from command line or use default if len(sys.argv) > 1: username = sys.argv[1] else: username = "evalongoria" print(f"Testing with username: {username}") print() # Create downloader with VISIBLE browser downloader = ImgInnDownloader( api_key="cf57fdb7577ada64d150431d6589c8f4", headless=False, # THIS MAKES THE BROWSER VISIBLE show_progress=True, use_database=False # Skip database for testing ) print(f"Starting download test for @{username}...") print("Watch the browser window to see Cloudflare behavior!") print() try: # Try to download just 1 post to test files = downloader.download_posts( username=username, days_back=14, max_posts=1 # Just test with 1 post ) print("\n" + "=" * 60) print("RESULTS") print("=" * 60) if files: print(f"✅ Successfully downloaded {len(files)} file(s)") for f in files: print(f" - {Path(f).name}") else: print("❌ No files downloaded - check what happened in the browser") except KeyboardInterrupt: print("\n\n⚠️ Interrupted by user") except Exception as e: print(f"\n\n❌ Error: {e}") import traceback traceback.print_exc() if __name__ == "__main__": main()