83 lines
3.0 KiB
Python
83 lines
3.0 KiB
Python
#!/usr/bin/env python3
|
|
"""
|
|
Test script to verify the enhanced logging without running the full GUI
|
|
"""
|
|
import os
|
|
import json
|
|
|
|
def simulate_playback_check():
|
|
"""Simulate the playback logic to see what would happen"""
|
|
|
|
base_dir = os.path.dirname(os.path.abspath(__file__))
|
|
media_dir = os.path.join(base_dir, 'media')
|
|
playlists_dir = os.path.join(base_dir, 'playlists')
|
|
|
|
# Supported extensions
|
|
VIDEO_EXTENSIONS = ['.mp4', '.avi', '.mkv', '.mov', '.webm']
|
|
IMAGE_EXTENSIONS = ['.jpg', '.jpeg', '.png', '.bmp', '.gif']
|
|
|
|
# Load playlist
|
|
playlist_file = os.path.join(playlists_dir, 'server_playlist_v8.json')
|
|
with open(playlist_file, 'r') as f:
|
|
data = json.load(f)
|
|
|
|
playlist = data.get('playlist', [])
|
|
|
|
print("=" * 80)
|
|
print("SIMULATING PLAYBACK SEQUENCE")
|
|
print("=" * 80)
|
|
|
|
for idx, media_item in enumerate(playlist):
|
|
file_name = media_item.get('file_name', '')
|
|
duration = media_item.get('duration', 10)
|
|
|
|
print(f"\n[STEP {idx + 1}] ===== Playing item {idx + 1}/{len(playlist)} =====")
|
|
print(f" File: {file_name}")
|
|
print(f" Duration: {duration}s")
|
|
|
|
# Construct path
|
|
media_path = os.path.join(media_dir, file_name)
|
|
print(f" Full path: {media_path}")
|
|
|
|
# Check existence
|
|
if not os.path.exists(media_path):
|
|
print(f" \u274c Media file not found: {media_path}")
|
|
print(f" ACTION: Skipping to next media...")
|
|
continue
|
|
|
|
file_size = os.path.getsize(media_path)
|
|
print(f" \u2713 File exists (size: {file_size:,} bytes)")
|
|
|
|
# Check extension
|
|
file_extension = os.path.splitext(file_name)[1].lower()
|
|
print(f" Extension: {file_extension}")
|
|
|
|
if file_extension in VIDEO_EXTENSIONS:
|
|
print(f" Media type: VIDEO")
|
|
print(f" ACTION: play_video('{media_path}', {duration})")
|
|
print(f" - Creating Video widget...")
|
|
print(f" - Adding to content area...")
|
|
print(f" - Scheduling next media in {duration}s")
|
|
print(f" \u2713 Media started successfully")
|
|
elif file_extension in IMAGE_EXTENSIONS:
|
|
print(f" Media type: IMAGE")
|
|
print(f" ACTION: play_image('{media_path}', {duration})")
|
|
print(f" - Creating AsyncImage widget...")
|
|
print(f" - Adding to content area...")
|
|
print(f" - Scheduling next media in {duration}s")
|
|
print(f" \u2713 Image displayed successfully")
|
|
else:
|
|
print(f" \u274c Unsupported media type: {file_extension}")
|
|
print(f" Supported: .mp4/.avi/.mkv/.mov/.webm/.jpg/.jpeg/.png/.bmp/.gif")
|
|
print(f" ACTION: Skipping to next media...")
|
|
continue
|
|
|
|
print(f"\n [After {duration}s] Transitioning to next media (was index {idx})")
|
|
|
|
print("\n" + "=" * 80)
|
|
print("END OF PLAYLIST - Would restart from beginning")
|
|
print("=" * 80)
|
|
|
|
if __name__ == '__main__':
|
|
simulate_playback_check()
|