All done, last bug remaining and we done

parent ad16d978
...@@ -3830,29 +3830,62 @@ class QtVideoPlayer(QObject): ...@@ -3830,29 +3830,62 @@ class QtVideoPlayer(QObject):
try: try:
logger.debug(f"DEBUG: Searching for intro video file for match_id: {match_id}") logger.debug(f"DEBUG: Searching for intro video file for match_id: {match_id}")
# Priority 1: Check for INTRO.mp4 in the unzipped ZIP file of the match # Priority 1: Check for INTRO.mp4 in the ZIP file for the match
if match_id: if match_id:
import zipfile
from ..database.manager import DatabaseManager from ..database.manager import DatabaseManager
from ..config.settings import get_user_data_dir from ..config.settings import get_user_data_dir
# Get database manager (assuming it's available via message bus or settings) # Get database manager
# For now, we'll use a simplified approach db_manager = self._get_database_manager()
user_data_dir = get_user_data_dir() if db_manager:
temp_dir_pattern = f"match_{match_id}_" session = db_manager.get_session()
try:
# Look for temp directories created by _unzip_match_zip_file # Get the match from database
import tempfile from ..database.models import MatchModel
import os match = session.query(MatchModel).filter_by(id=match_id).first()
temp_base = Path(tempfile.gettempdir())
logger.debug(f"DEBUG: Looking for match temp dirs in: {temp_base} with pattern: {temp_dir_pattern}") if match and match.zip_filename:
# Determine ZIP file location
for temp_dir in temp_base.glob(f"{temp_dir_pattern}*"): user_data_dir = get_user_data_dir()
if temp_dir.is_dir(): zip_file_path = user_data_dir / "zip_files" / match.zip_filename
intro_file = temp_dir / "INTRO.mp4"
logger.debug(f"DEBUG: Checking for INTRO.mp4 in match ZIP: {intro_file}") logger.debug(f"DEBUG: Checking ZIP file: {zip_file_path}")
if intro_file.exists():
logger.info(f"Found INTRO.mp4 in match ZIP: {intro_file}") if zip_file_path.exists():
return intro_file # Check if INTRO.mp4 exists in the ZIP file without extracting
try:
with zipfile.ZipFile(str(zip_file_path), 'r') as zip_ref:
file_list = zip_ref.namelist()
if "INTRO.mp4" in file_list:
logger.info(f"Found INTRO.mp4 in ZIP file: {zip_file_path}")
# Ensure the ZIP is extracted so we can access the file
unzip_success = self._unzip_match_zip_file(match_id)
if unzip_success:
# Find the extracted INTRO.mp4 file
import tempfile
temp_base = Path(tempfile.gettempdir())
temp_dir_pattern = f"match_{match_id}_"
for temp_dir in temp_base.glob(f"{temp_dir_pattern}*"):
if temp_dir.is_dir():
intro_file = temp_dir / "INTRO.mp4"
if intro_file.exists():
logger.info(f"Using INTRO.mp4 from match ZIP: {intro_file}")
return intro_file
else:
logger.warning(f"Failed to extract ZIP file containing INTRO.mp4: {zip_file_path}")
else:
logger.debug(f"INTRO.mp4 not found in ZIP file: {zip_file_path}")
except zipfile.BadZipFile:
logger.warning(f"Invalid ZIP file: {zip_file_path}")
except Exception as zip_error:
logger.error(f"Error checking ZIP file contents: {zip_error}")
else:
logger.debug(f"ZIP file not found: {zip_file_path}")
finally:
session.close()
# Priority 2: Check for uploaded intro video # Priority 2: Check for uploaded intro video
# This would need to be implemented based on how uploaded intro videos are stored # This would need to be implemented based on how uploaded intro videos are stored
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment