#!/usr/bin/env python3 """Test push notification with image thumbnail attachment""" import sys import json from pathlib import Path sys.path.insert(0, str(Path(__file__).parent)) sys.path.insert(0, str(Path(__file__).parent / 'modules')) from modules.pushover_notifier import PushoverNotifier def load_config(): config_path = Path(__file__).parent / 'config' / 'settings.json' with open(config_path, 'r') as f: return json.load(f) # Load config config = load_config() pushover_config = config.get('pushover', {}) # Create notifier notifier = PushoverNotifier( user_key=pushover_config.get('user_key'), api_token=pushover_config.get('api_token'), enabled=True ) # Test 1: Instagram with multiple images print("=" * 60) print("Test 1: Instagram Notification with Thumbnail") print("=" * 60) # Find some actual images for testing instagram_images = [ "/opt/immich/md/forums/PicturePub/Teri Hatcher & Eva Longoria - Desperate Housewives S08E14_ Get Out of My Life 2012, 80x/638100294_rere-12.jpg", "/opt/immich/md/forums/PicturePub/Teri Hatcher & Eva Longoria - Desperate Housewives S08E14_ Get Out of My Life 2012, 80x/638100582_rere-194.jpg", "/opt/immich/md/forums/PicturePub/Teri Hatcher & Eva Longoria - Desperate Housewives S08E14_ Get Out of My Life 2012, 80x/638100577_rere-191.jpg" ] # Simulate Instagram download - mixed content downloads = [] # Add 5 posts for i in range(5): downloads.append({ 'source': 'evalongoria', 'content_type': 'post', 'filename': f'post_{i}.jpg', 'file_path': instagram_images[i % len(instagram_images)] # Use actual images }) # Add 3 stories for i in range(3): downloads.append({ 'source': 'evalongoria', 'content_type': 'story', 'filename': f'story_{i}.jpg', 'file_path': instagram_images[i % len(instagram_images)] }) # Add 2 reels for i in range(2): downloads.append({ 'source': 'evalongoria', 'content_type': 'reel', 'filename': f'reel_{i}.mp4', 'file_path': None # Videos won't be selected as thumbnails }) print(f"Sending Instagram notification with thumbnail...") print(f" - 5 posts + 3 stories + 2 reels = 10 items") print(f" - Random thumbnail will be selected from images") print() success = notifier.notify_batch_download( platform='instagram', downloads=downloads, search_term=None ) print(f"{'✅' if success else '❌'} Instagram notification sent: {success}") print() # Test 2: Forum notification with thumbnail print("=" * 60) print("Test 2: Forum Notification with Thumbnail") print("=" * 60) forum_downloads = [] for i, img_path in enumerate(instagram_images): forum_downloads.append({ 'source': 'HQCelebCorner', 'content_type': 'image', 'filename': Path(img_path).name, 'file_path': img_path }) print(f"Sending forum notification with thumbnail...") print(f" - {len(forum_downloads)} images") print(f" - Search term: Eva Longoria") print() success = notifier.notify_batch_download( platform='forum', downloads=forum_downloads, search_term='Eva Longoria' ) print(f"{'✅' if success else '❌'} Forum notification sent: {success}") print() # Show stats print("=" * 60) print(f"Notification Stats: {notifier.get_stats()}") print("=" * 60) print() print("Check your Pushover app for notifications with thumbnails!")