Files
AccountForger-neuerUpload/debug_video_issue.py
Claude Project Manager 04585e95b6 Initial commit
2025-08-01 23:50:28 +02:00

267 Zeilen
11 KiB
Python

#!/usr/bin/env python3
"""
Debug Video Issue - Final Diagnostic Script
"""
import asyncio
import json
import logging
from pathlib import Path
from browser.playwright_manager import PlaywrightManager
logging.basicConfig(level=logging.DEBUG)
logger = logging.getLogger("video_debug")
async def debug_video_issue():
"""Comprehensive video issue debugging"""
print("🔍 STARTING COMPREHENSIVE VIDEO DEBUG ANALYSIS")
# Test with fresh manager
manager = PlaywrightManager(headless=False)
try:
page = manager.start()
print("📋 STEP 1: Navigating to Instagram...")
success = manager.navigate_to("https://www.instagram.com")
if not success:
print("❌ Failed to navigate to Instagram")
return
print("📋 STEP 2: Checking browser capabilities...")
# Check all video-related capabilities
capabilities = page.evaluate("""
() => {
const results = {
// Basic video support
video_element: !!document.createElement('video'),
video_can_play_mp4: document.createElement('video').canPlayType('video/mp4'),
video_can_play_webm: document.createElement('video').canPlayType('video/webm'),
// DRM Support
widevine_support: !!navigator.requestMediaKeySystemAccess,
media_source: !!window.MediaSource,
encrypted_media: !!window.MediaKeys,
// Chrome APIs
chrome_present: !!window.chrome,
chrome_runtime: !!(window.chrome && window.chrome.runtime),
chrome_app: window.chrome ? window.chrome.app : 'missing',
chrome_csi: !!(window.chrome && window.chrome.csi),
chrome_loadtimes: !!(window.chrome && window.chrome.loadTimes),
// Media Devices
media_devices: !!(navigator.mediaDevices),
enumerate_devices: !!(navigator.mediaDevices && navigator.mediaDevices.enumerateDevices),
get_user_media: !!(navigator.mediaDevices && navigator.mediaDevices.getUserMedia),
// Performance API
performance_now: !!performance.now,
performance_timing: !!performance.timing,
// Automation markers
webdriver_present: !!navigator.webdriver,
automation_markers: {
webdriver_script_fn: !!navigator.__webdriver_script_fn,
webdriver_evaluate: !!window.__webdriver_evaluate,
selenium_unwrapped: !!document.__selenium_unwrapped,
chrome_webdriver: !!(window.chrome && window.chrome.webdriver)
},
// User agent analysis
user_agent: navigator.userAgent,
platform: navigator.platform,
vendor: navigator.vendor,
languages: navigator.languages,
// Screen info
screen_width: screen.width,
screen_height: screen.height,
device_pixel_ratio: devicePixelRatio,
// Timing
page_load_time: performance.now()
};
return results;
}
""")
print("📊 BROWSER CAPABILITIES:")
for key, value in capabilities.items():
print(f" {key}: {value}")
print("\n📋 STEP 3: Testing video element creation...")
video_test = page.evaluate("""
() => {
// Create video element and test
const video = document.createElement('video');
video.style.display = 'none';
document.body.appendChild(video);
const results = {
video_created: true,
video_properties: {
autoplay: video.autoplay,
controls: video.controls,
muted: video.muted,
preload: video.preload,
crossOrigin: video.crossOrigin
},
video_methods: {
canPlayType: typeof video.canPlayType,
play: typeof video.play,
pause: typeof video.pause,
load: typeof video.load
},
codec_support: {
mp4_h264: video.canPlayType('video/mp4; codecs="avc1.42E01E"'),
mp4_h265: video.canPlayType('video/mp4; codecs="hev1.1.6.L93.B0"'),
webm_vp8: video.canPlayType('video/webm; codecs="vp8"'),
webm_vp9: video.canPlayType('video/webm; codecs="vp9"'),
audio_aac: video.canPlayType('audio/mp4; codecs="mp4a.40.2"'),
audio_opus: video.canPlayType('audio/webm; codecs="opus"')
}
};
document.body.removeChild(video);
return results;
}
""")
print("\n📊 VIDEO ELEMENT TEST:")
for key, value in video_test.items():
print(f" {key}: {value}")
print("\n📋 STEP 4: Checking console errors...")
# Wait a bit for any console errors
await asyncio.sleep(2)
# Check for specific Instagram video errors
print("\n📋 STEP 5: Looking for Instagram-specific issues...")
# Try to find any video elements or error messages
video_status = page.evaluate("""
() => {
const results = {
video_elements_count: document.querySelectorAll('video').length,
error_messages: [],
instagram_classes: {
video_error_present: !!document.querySelector('.x6s0dn4.xatbrnm.x9f619'),
video_containers: document.querySelectorAll('[class*="video"]').length,
error_spans: []
}
};
// Look for error messages
const errorSpans = document.querySelectorAll('span');
errorSpans.forEach(span => {
const text = span.textContent.trim();
if (text.includes('Video') || text.includes('video') || text.includes('abgespielt') || text.includes('richtig')) {
results.instagram_classes.error_spans.push({
text: text,
classes: span.className
});
}
});
return results;
}
""")
print("\n📊 INSTAGRAM VIDEO STATUS:")
for key, value in video_status.items():
print(f" {key}: {value}")
print("\n📋 STEP 6: Testing DRM capabilities...")
drm_test = page.evaluate("""
() => {
return new Promise((resolve) => {
if (!navigator.requestMediaKeySystemAccess) {
resolve({drm_support: false, error: 'No requestMediaKeySystemAccess'});
return;
}
navigator.requestMediaKeySystemAccess('com.widevine.alpha', [{
initDataTypes: ['cenc'],
videoCapabilities: [{contentType: 'video/mp4; codecs="avc1.42E01E"'}]
}]).then(access => {
resolve({
drm_support: true,
key_system: access.keySystem,
configuration: access.getConfiguration()
});
}).catch(error => {
resolve({
drm_support: false,
error: error.message
});
});
});
}
""")
print("\n📊 DRM TEST RESULTS:")
print(f" {drm_test}")
print("\n🎯 FINAL DIAGNOSIS:")
print("=" * 50)
# Analyze results
issues = []
if not capabilities.get('video_element'):
issues.append("❌ Video elements not supported")
if capabilities.get('webdriver_present'):
issues.append("❌ Webdriver detection present")
if not capabilities.get('widevine_support'):
issues.append("❌ Widevine DRM not supported")
if video_status.get('instagram_classes', {}).get('video_error_present'):
issues.append("❌ Instagram video error message detected")
if not drm_test.get('drm_support'):
issues.append(f"❌ DRM test failed: {drm_test.get('error', 'Unknown')}")
automation_markers = capabilities.get('automation_markers', {})
detected_markers = [k for k, v in automation_markers.items() if v]
if detected_markers:
issues.append(f"❌ Automation markers detected: {detected_markers}")
if issues:
print("🚨 CRITICAL ISSUES FOUND:")
for issue in issues:
print(f" {issue}")
else:
print("✅ No obvious technical issues detected")
print("🤔 The problem might be:")
print(" - Account-specific restrictions")
print(" - Geographic blocking")
print(" - Instagram A/B testing")
print(" - Specific video content restrictions")
print("\n📋 RECOMMENDATION:")
if len(issues) > 3:
print(" 🔄 Technical fixes needed - automation still detectable")
elif len(issues) > 0:
print(" 🔧 Some technical issues remain")
else:
print(" 💡 Technical setup appears correct - likely policy/account issue")
except Exception as e:
logger.error(f"Debug failed: {e}")
print(f"❌ Debug script failed: {e}")
finally:
manager.close()
if __name__ == "__main__":
asyncio.run(debug_video_issue())