- Remove session-ses_2f27.md (161KB raw session log) - Remove 49 ROOT_* duplicate files across REFERENCE/ - Remove 14 duplicate files between REFERENCE/ root and history/ - Remove asr_legacy.rs (dead code, replaced by asr.rs) - Remove src/core/worker/ (duplicate JobWorker) - Remove src/core/layers/ (empty directory) - Remove 4 .bak files in src/ - Remove 7 dead private methods in worker/processor.rs - Remove backup directory from git tracking
67 lines
2.2 KiB
Python
Executable File
67 lines
2.2 KiB
Python
Executable File
#!/usr/bin/env python3
|
||
"""測試場景識別 API"""
|
||
|
||
import requests
|
||
import sys
|
||
|
||
API_KEY = "muser_68600856036340bcafc01930eb4bd839_1774418104_97221b69"
|
||
BASE_URL = "http://localhost:3003"
|
||
|
||
def test_scene_classification(video_uuid: str):
|
||
"""測試場景識別 API"""
|
||
print(f"測試場景識別 API: {video_uuid}")
|
||
print(f"API URL: {BASE_URL}/api/v1/scene/{video_uuid}")
|
||
|
||
headers = {
|
||
"X-API-Key": API_KEY
|
||
}
|
||
|
||
try:
|
||
response = requests.get(
|
||
f"{BASE_URL}/api/v1/scene/{video_uuid}",
|
||
headers=headers,
|
||
timeout=300
|
||
)
|
||
|
||
print(f"\nHTTP 狀態碼:{response.status_code}")
|
||
|
||
if response.status_code == 200:
|
||
result = response.json()
|
||
print("\n✓ 場景識別成功")
|
||
print(f"處理時間:{result.get('processing_time', 0):.2f} 秒")
|
||
print(f"場景數量:{len(result.get('scenes', []))}")
|
||
|
||
if result.get('scenes'):
|
||
print("\n場景詳情:")
|
||
for i, scene in enumerate(result['scenes'][:3]):
|
||
print(f" {i+1}. {scene.get('scene_type')} ({scene.get('confidence', 0)*100:.1f}%)")
|
||
print(f" 時間:{scene.get('start_time', 0):.1f}s - {scene.get('end_time', 0):.1f}s")
|
||
|
||
return True
|
||
else:
|
||
print(f"\n✗ API 請求失敗:{response.status_code}")
|
||
print(f"回應:{response.text[:200]}")
|
||
return False
|
||
|
||
except requests.exceptions.RequestException as e:
|
||
print(f"\n✗ 請求錯誤:{e}")
|
||
print("\n請確認:")
|
||
print("1. Playground 伺服器已啟動 (port 3003)")
|
||
print("2. API key 正確")
|
||
print("3. 影片 UUID 存在")
|
||
return False
|
||
|
||
def main():
|
||
if len(sys.argv) < 2:
|
||
print("使用方式:python3 scripts/test_scene_api.py <video_uuid>")
|
||
print("\n範例:")
|
||
print(" python3 scripts/test_scene_api.py 384b0ff44aaaa1f1")
|
||
sys.exit(1)
|
||
|
||
video_uuid = sys.argv[1]
|
||
success = test_scene_classification(video_uuid)
|
||
sys.exit(0 if success else 1)
|
||
|
||
if __name__ == "__main__":
|
||
main()
|