127 lines
4.7 KiB
Python
127 lines
4.7 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Debug script for the Annabelle → Harry Potter webhook processing bug
|
|
Tests the webhook isolation fixes in v1.3.1
|
|
"""
|
|
|
|
import requests
|
|
import json
|
|
import time
|
|
from datetime import datetime
|
|
|
|
def test_webhook_isolation():
|
|
"""Test that movie webhooks process the correct movie"""
|
|
print("🔍 Testing Webhook Isolation Fixes (v1.3.1)")
|
|
print("=" * 60)
|
|
|
|
# Test case from the bug report
|
|
test_cases = [
|
|
{
|
|
"imdb_id": "tt3322940",
|
|
"title": "Annabelle (2014)",
|
|
"path": "/mnt/unionfs/Media/Movies/movies6/Annabelle (2014) [tt3322940]",
|
|
"expected_container_path": "/media/Movies/movies6/Annabelle (2014) [tt3322940]"
|
|
},
|
|
{
|
|
"imdb_id": "tt8350360",
|
|
"title": "Annabelle Comes Home (2019)",
|
|
"path": "/mnt/unionfs/Media/Movies/movies6/Annabelle Comes Home (2019) [tt8350360]",
|
|
"expected_container_path": "/media/Movies/movies6/Annabelle Comes Home (2019) [tt8350360]"
|
|
}
|
|
]
|
|
|
|
for i, test_case in enumerate(test_cases, 1):
|
|
print(f"\n{i}. Testing {test_case['title']} ({test_case['imdb_id']})")
|
|
print("-" * 50)
|
|
|
|
# Create webhook payload
|
|
webhook_payload = {
|
|
"eventType": "Download",
|
|
"movie": {
|
|
"id": i,
|
|
"title": test_case["title"],
|
|
"imdbId": test_case["imdb_id"],
|
|
"path": test_case["path"]
|
|
},
|
|
"movieFile": {
|
|
"id": i,
|
|
"path": f"{test_case['path']}/movie.mkv"
|
|
}
|
|
}
|
|
|
|
print(f"📤 Sending webhook...")
|
|
print(f" Radarr Path: {test_case['path']}")
|
|
print(f" Expected Container Path: {test_case['expected_container_path']}")
|
|
|
|
try:
|
|
response = requests.post(
|
|
"http://localhost:8080/webhook/radarr",
|
|
json=webhook_payload,
|
|
headers={"Content-Type": "application/json"},
|
|
timeout=10
|
|
)
|
|
|
|
if response.status_code == 200:
|
|
result = response.json()
|
|
print(f" ✅ Webhook accepted: {result.get('message', 'Success')}")
|
|
|
|
# Check if batch key uses new prefixed format
|
|
if 'movie:' in result.get('message', ''):
|
|
print(f" ✅ Using prefixed batch key (isolation working)")
|
|
else:
|
|
print(f" ⚠️ Batch key format unclear")
|
|
|
|
else:
|
|
print(f" ❌ Webhook rejected: {response.status_code}")
|
|
print(f" Error: {response.text}")
|
|
|
|
# This might be expected if path doesn't exist (validation working)
|
|
if "does not exist" in response.text:
|
|
print(f" ✅ Path validation working (rejects non-existent paths)")
|
|
|
|
except Exception as e:
|
|
print(f" ❌ Error: {e}")
|
|
|
|
# Small delay between tests
|
|
time.sleep(1)
|
|
|
|
print(f"\n📋 Next Steps:")
|
|
print(f"1. Check NFOGuard logs to see which movies were actually processed")
|
|
print(f"2. Verify logs show 'Batch validation passed' messages")
|
|
print(f"3. Ensure no 'BATCH VALIDATION FAILED' errors")
|
|
print(f"4. Confirm correct movies are processed (not Harry Potter)")
|
|
|
|
# Get batch status
|
|
print(f"\n📊 Current Batch Status:")
|
|
try:
|
|
response = requests.get("http://localhost:8080/batch/status", timeout=5)
|
|
if response.status_code == 200:
|
|
data = response.json()
|
|
print(f" Pending: {data.get('pending_count', 0)}")
|
|
print(f" Processing: {data.get('processing_count', 0)}")
|
|
if data.get('pending_items'):
|
|
print(f" Keys: {data['pending_items']}")
|
|
else:
|
|
print(f" Could not get batch status: {response.status_code}")
|
|
except Exception as e:
|
|
print(f" Batch status error: {e}")
|
|
|
|
def test_path_mapping():
|
|
"""Test path mapping configuration"""
|
|
print(f"\n🗺️ Testing Path Mapping")
|
|
print("=" * 30)
|
|
|
|
test_paths = [
|
|
"/mnt/unionfs/Media/Movies/movies6/Annabelle (2014) [tt3322940]",
|
|
"/mnt/unionfs/Media/Movies/movies6/Annabelle Comes Home (2019) [tt8350360]",
|
|
"/mnt/unionfs/Media/Movies/movies/Some Movie (2023) [tt1234567]"
|
|
]
|
|
|
|
for path in test_paths:
|
|
print(f"Testing: {path}")
|
|
# This would need to be implemented in NFOGuard as a debug endpoint
|
|
print(f" → Expected: /media/Movies/movies6/... (if movies6 mapping exists)")
|
|
|
|
if __name__ == "__main__":
|
|
test_webhook_isolation()
|
|
test_path_mapping() |